How to set a default global log level and have override it in some of the source files?

1,500 views
Skip to first unread message

DrummerB

unread,
Jul 25, 2012, 4:32:13 PM7/25/12
to cocoalu...@googlegroups.com
Is it possible to set up Lumberjack in a way, that I don't have to import or add anything to my source files except the log macros? I tried importing DDLog.h and declaring ddLogLevel in the prefix header of my project. The problem with this approach is, that I can't set a different log level on a per file basis, can I? I can't redeclare the static int ddLogLevel variable. 

gamm...@gmail.com

unread,
Jan 9, 2013, 11:39:42 AM1/9/13
to cocoalu...@googlegroups.com
I'm also interessed by this behavior, but can't find a way to nicely integrate it inside my project. Ideally it would be :
  • a Global logging level which can be configurable based on config (Debug or Release)
  • a way to customize the logging level per implementation-file/class also based on config
Anyone with a suggestion ?

Joe Francia

unread,
Jan 9, 2013, 3:39:33 PM1/9/13
to cocoalu...@googlegroups.com


--
You received this message because you are subscribed to the Google Groups "CocoaLumberjack" group.
To post to this group, send email to cocoalu...@googlegroups.com.
To unsubscribe from this group, send email to cocoalumberja...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/cocoalumberjack/-/luzJyy0saGQJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Gamma Tora

unread,
Jan 10, 2013, 2:41:13 AM1/10/13
to cocoalu...@googlegroups.com
These suggestions are powerful, yet the one thing that's negative with Lumberjack is that we need to define ddLogLevel in every single file/class.

We would prefer, like a said, a single/global definition for the whole project with custom file/class level, on demand (the on-demand problem is clearly solved with the links you supplied).

In short, we want to integrate Lumberjack without modifying hundred of files. If it doesn't fit our need we don't want to modify this files a second times.

Piotr Laskowski

unread,
Feb 27, 2014, 5:25:32 AM2/27/14
to cocoalu...@googlegroups.com
I had same requirement, here is mine solution:
In your project's .pch file put:
    #define GLOBAL_LOG_LEVEL LOG_LEVEL_INFO
    #define LOCAL_LOG_LEVEL GLOBAL_LOG_LEVEL
    #define LOG_LEVEL_DEF LOCAL_LOG_LEVEL

To give code in .m file different log level do in given .m:
        #undef LOCAL_LOG_LEVEL
        #define LOCAL_LOG_LEVEL LOG_LEVEL_DEBUG
Reply all
Reply to author
Forward
0 new messages