-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Fix" conflicts with 3rd party libraries using CocoaLumberjack #172
"Fix" conflicts with 3rd party libraries using CocoaLumberjack #172
Conversation
As discussed in CocoaLumberjack#162, there's no solution to sharing `ddLogLevel` between libraries and the client application: * Apps/libraries may define `ddLogLevel` as a const, extern, int, a function returning an int, etc. Each one incompatible with the other. * Even more, if apps/libraries used a compatible and shared `ddLogLevel` there would be no way to manage separately log levels from each one. The solution is to define a `LOG_LEVEL_DEF` by default equal to `ddLogLevel` so apps can continue to work as usual. 3rd party libraries simple redefine `LOG_LEVEL_DEF` to something different: ```obj-c // #undef LOG_LEVEL_DEF // Undefine first only if needed #define LOG_LEVEL_DEF myLibLogLevel ``` 3rd party frameworks **need** to be updated.
Looks good @rivera-ernesto . Thanks for doing this |
"Fix" conflicts with 3rd party libraries using CocoaLumberjack
Now we need to ask library devs to update their CocoaLumberjack usage:
We'll also need some proper documentation for this in the README and/or Wiki. |
Creating a 1.6.4 release so they can point this release in their specs' requirements. |
Looks like a great solution. Thanks for working it out. |
https://github.com/robbiehanson/CocoaLumberjack/wiki/XcodeTricks - this is still true, considering last changes? I am recieving error, when building with CocoaLumberjack and MagicalRecord as pods:
How can I supress this, from my side? Or this requires changes from MagicalRecord? |
It is, but only for the host application. Frameworks could do the same with their levels: #ifdef DEBUG
static const int myLibLogLevel = LOG_LEVEL_WARN; // Probably not VERBOSE here!
#else
static const int myLibLogLevel = LOG_LEVEL_ERROR;
#endif |
For now you could redefine #define LOG_LEVEL_DEF myAppLogLevel
// Just before
#import <DDLog/DDLog.h> Then you replace |
@rivera-ernesto thanks for this hints!
including this define along with whole library - will override pch setting for application log level. The only solution that I see - to import DDLog.h with LOG_LEVEL_DEF redefine at top of every .m file in my project (but after all other imports). |
Yes, you have to define
|
I'm trying to make CocoaLumberjack optional for my libraries (sample). Use it if available, else fallback to NSLog.
This could be extended to other log frameworks allowing app developers to use the one they prefer. |
As discussed in #162, there's no solution to sharing
ddLogLevel
between libraries and the client application:ddLogLevel
as a const, extern, int, a function returning an int, etc. Each one incompatible with the other.ddLogLevel
there would be no way to manage separately log levels from each one.The solution is to define a
LOG_LEVEL_DEF
by default equal toddLogLevel
so apps can continue to work as usual.3rd party libraries simple redefine
LOG_LEVEL_DEF
to something different:3rd party frameworks need to be updated.