Last active
September 12, 2015 06:00
-
-
Save DanSkeel/9631d0b8b55cce8bd5a8 to your computer and use it in GitHub Desktop.
Logging configuration header for global/local levels in CocoaLumberjack (2.0.0)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by DanSkeel on 23.04.15. | |
#import "CocoaLumberjack.h" | |
#define DS_LogScopeGlobal extern | |
#define DS_LogScopeLocal static | |
#define DS_LogMutableYes | |
#define DS_LogMutableNo const | |
#define DS_LogValueGlobal ; | |
#define DS_LogValueLocal(lvl) = lvl | |
#define DS_Setup_Log(scope, mutablility, value) scope mutablility DDLogLevel ddLogLevel value | |
/** To setup loggin enviroment for particular file use one of these macros | |
* | |
* @note Use CocoaLumberjack as usual (https://github.com/CocoaLumberjack/CocoaLumberjack/blob/master/Documentation/GettingStarted.md): | |
* | |
* 1. just import DSLoggin.h in source file instead of CocoaLumberjack.h | |
* | |
* 2. Use one of these macros to setup loggin enviroment for the file. | |
* Note: there should one of these macros in EACH file that uses CocoaLumberjack macroses. | |
* @example To enable logging for file with globally defined level you can make convinient snippet: | |
* @code | |
* #import "DSLogging.h" | |
* DSLogLevelSetupGlobal | |
* @endcode | |
* | |
* Use @b SetupGlobal to setup files that will use global level from @p DSLogging.m file | |
* | |
* Use @b SetupMutableGlobal to be able to change global level at runtime (assign new level to ddLogLevel variable) | |
* | |
* Use @b Setup(DDLogLevel) to set local log level | |
* | |
* Use @b SetupMutable(DDLogLevel) to be able to modify local level at runtime ((assign new level to ddLogLevel variable)) | |
* | |
* This approach preserves a lot of CocoaLumberjack advantages. See SO http://stackoverflow.com/a/29837945/991816 | |
* | |
* @remarks details: these macros just help you define/reference ddLogLevel value. So if you | |
* see warning about <i> undeclared identifier </i> it should remind you to use one of these macros in this file. | |
*/ | |
extern char optionClickMeToSeePrettyDoc; | |
#define DSLogLevelSetupMutableGlobal DS_Setup_Log(DS_LogScopeGlobal, DS_LogMutableYes, DS_LogValueGlobal) | |
#define DSLogLevelSetupGlobal DS_Setup_Log(DS_LogScopeGlobal, DS_LogMutableNo, DS_LogValueGlobal) | |
#define DSLogLevelSetupMutable(lvl) DS_Setup_Log(DS_LogScopeLocal, DS_LogMutableYes, DS_LogValueLocal(lvl)) | |
#define DSLogLevelSetup(lvl) DS_Setup_Log(DS_LogScopeLocal, DS_LogMutableNo, DS_LogValueLocal(lvl)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by DanSkeel on 23.04.15. | |
#import "DSLogging.h" | |
DDLogLevel ddLogLevel = DDLogLevelVerbose; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment