Comments (4)
First of all thanks for taking the time to describe everything in such detail, including recommendations!
Downgrade of Warning to Info
You're right that this is incorrect! They should be upgraded to error, which is what the .warning
function on Logger
in OSLog
does as well:
Btw. there was an open source implementation of Logger in the Swift repository. While it was only used for tests, I could imagine it being pretty close to the real thing...
Missing messages in Console.app
I'm a bit torn here...
Reading a bit further in the forum you linked, I found this answer by Quinn.
Using CocoaLumberjack version 3.8.4, I was able to reproduce his findings:
Everything logged with .info
or above is visible in Console.app:
This lines up with .debug
messages not being shown, which was also classified as bug by Quinn in the forums.
Also matching Quinn's findings, I'm able to see these messages when using the Terminal:
Last but not least, I see all messages in Xcode's Console as well (Xcode 15.2):
Long story short, I don't think it's that simple to add a workaround in CocoaLumberjack.
In its current form, the bug seems to only affect the Console.app, not the logging SDK itself.
Personally, I've never used the Console.app to read Simulator logs, though I can see that it might be helpful to see other logs (not only the application's logs).
Given that all log messages show up correctly in Xcode, we shouldn't generally raise .debug
logs to a higher level.
I could imagine adding a "level mapper" of sorts to DDOSLogger
, though. This could be used to map our log levels to the ones of OSLog. We'd then provide two default implementations:
- One that basically does what the current implantation does.
- One that's only available when building for Simulator, that raises
.debug
to either.default
or.info
.
Users of CocoaLumberjack would then still need to add a little more code, but not implement the whole workaround themselves.
What do you think?
from cocoalumberjack.
You're right that this is incorrect! [Warning logs] should be upgraded to error
I left something out from my description. I've noticed that off-the-shelf there is not a neutral DDLogMessage()
or DDLog()
or DDLogDefault()
etc method that logs at a neutral level equivalent with os_log(...)
(OSLogType .default
). If Warning logs get upgraded to Error, then there's still no way to produce a log that is higher than a debug/info but not an error.
This is of particular importance when viewing logs in Xcode.app or the Console.app where error and fault logs are given special UI treatment (little yellow dots in Console.app, for example) and filter capabilities. If every log that would otherwise be logged at a neutral level (i.e. warning) gets lifted to an error, then there's no way to distinguish between true error logs and neutral logs. Everything will look like an error.
Neutral-level system logs (OSLogType.default) can also provide critical information in production builds. Debug and Info type logs cannot be enabled in a production build (at least not without jumping through hoops requiring the installation of a special debugging profile), but neutral/default type logs are enabled by default. That means I can ask an end user to install my app from the App Store, run it, export a sysarchive, and view logs from that device without having to log everything at an error level. I've had to do this on projects before (that didn't use CocoaLumberjack) and it was a lifesaver.
from cocoalumberjack.
I could imagine adding a "level mapper" of sorts to DDOSLogger, though
I think this idea is interesting. I've worked on projects where logging requirements change as different platform teams become subject to belated cross-platform logging standards. These standards can force teams to raise or lower log levels across the board, which can potentially wreak havoc on a codebase as thousands of log statements have to be audited to raise or lower the level to the new standard. It would be far easier to define a level mapping in one place, and leave call sites and team-specific logging practices untouched.
from cocoalumberjack.
I've noticed that off-the-shelf there is not a neutral DDLogMessage() or DDLog() or DDLogDefault() etc method that logs at a neutral level equivalent with os_log(...) (OSLogType .default).
That's due to CocoaLumberjack not having a 'neutral' log level. To be honest, I haven't really understood the concept of a 'neutral' log level - and have often seen it being overused if there was one.
FWIW, I've changed the default
in the switch to use the OS_LOG_TYPE_DEFAULT
in #1410.
I think this idea is interesting.
Feel free to have a look at #1410 and see if the solution I've implemented there would fit your needs.
from cocoalumberjack.
Related Issues (20)
- crash in [DDLogMessage initWithFormat:args:level:flag:context:file:function:line:tag:options:timestamp] HOT 3
- Log messages dispatched using the swift-log backend are missing normal swift-log formatting. HOT 1
- The `dynamicLogLevel` isn't taken in account when using `swift-log` HOT 3
- Question about CocoaLumberjack Behavior - Deleting All Files when logFilesDiskQuota is Reached HOT 1
- Deprecated message at DDLogInfo
- Thread running at QOS_CLASS_USER_INTERACTIVE waiting on a lower QoS thread running at QOS_CLASS_BACKGROUND. Investigate ways to avoid priority inversions HOT 2
- Privacy manifest for new sensitive APIs HOT 5
- Race condition when configuring DDLogFileManagerDefault HOT 1
- Library is not visible in ObjC when using SPM HOT 6
- pod 'CocoaLumberjack/Swift' 报错:Function Parameter Count Violation: Function should have 5 parameters or less: it currently has 10 (function_parameter_count) HOT 2
- Bump `IPHONEOS_DEPLOYMENT_TARGET` in podspec to appease Cocoapods on Xcode15 HOT 3
- NSGenericDeallocHandler release crash when calling registeredClasses HOT 1
- CocoaLumberjack v3.8.3 - Privacy Manifest - Missing an expected key: 'NSPrivacyCollectedDataTypes' HOT 3
- Multiple commands produce PrivacyInfo.xcprivacy HOT 8
- Add optional custom format specifiers to DDLogMessageFormat HOT 1
- Compilation Error with Xcode 15 during Archive Operation HOT 1
- Confused about DDFileLog。 HOT 2
- When will visionOS be supported
- osLogTypeForLogFlag for FAULT HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cocoalumberjack.