| // Software License Agreement (BSD License) |
| // |
| // Copyright (c) 2010-2015, Deusty, LLC |
| // All rights reserved. |
| // |
| // Redistribution and use of this software in source and binary forms, |
| // with or without modification, are permitted provided that the following conditions are met: |
| // |
| // * Redistributions of source code must retain the above copyright notice, |
| // this list of conditions and the following disclaimer. |
| // |
| // * Neither the name of Deusty nor the names of its contributors may be used |
| // to endorse or promote products derived from this software without specific |
| // prior written permission of Deusty, LLC. |
| |
| /** |
| * Legacy macros used for 1.9.x backwards compatibility. |
| * |
| * Imported by default when importing a DDLog.h directly and DD_LEGACY_MACROS is not defined and set to 0. |
| **/ |
| #if DD_LEGACY_MACROS |
| |
| #warning CocoaLumberjack 1.9.x legacy macros enabled. \ |
| Disable legacy macros by importing CocoaLumberjack.h or DDLogMacros.h instead of DDLog.h or add `#define DD_LEGACY_MACROS 0` before importing DDLog.h. |
| |
| #ifndef LOG_LEVEL_DEF |
| #define LOG_LEVEL_DEF ddLogLevel |
| #endif |
| |
| #define LOG_FLAG_ERROR DDLogFlagError |
| #define LOG_FLAG_WARN DDLogFlagWarning |
| #define LOG_FLAG_INFO DDLogFlagInfo |
| #define LOG_FLAG_DEBUG DDLogFlagDebug |
| #define LOG_FLAG_VERBOSE DDLogFlagVerbose |
| |
| #define LOG_LEVEL_OFF DDLogLevelOff |
| #define LOG_LEVEL_ERROR DDLogLevelError |
| #define LOG_LEVEL_WARN DDLogLevelWarning |
| #define LOG_LEVEL_INFO DDLogLevelInfo |
| #define LOG_LEVEL_DEBUG DDLogLevelDebug |
| #define LOG_LEVEL_VERBOSE DDLogLevelVerbose |
| #define LOG_LEVEL_ALL DDLogLevelAll |
| |
| #define LOG_ASYNC_ENABLED YES |
| |
| #define LOG_ASYNC_ERROR ( NO && LOG_ASYNC_ENABLED) |
| #define LOG_ASYNC_WARN (YES && LOG_ASYNC_ENABLED) |
| #define LOG_ASYNC_INFO (YES && LOG_ASYNC_ENABLED) |
| #define LOG_ASYNC_DEBUG (YES && LOG_ASYNC_ENABLED) |
| #define LOG_ASYNC_VERBOSE (YES && LOG_ASYNC_ENABLED) |
| |
| #define LOG_MACRO(isAsynchronous, lvl, flg, ctx, atag, fnct, frmt, ...) \ |
| [DDLog log : isAsynchronous \ |
| level : lvl \ |
| flag : flg \ |
| context : ctx \ |
| file : __FILE__ \ |
| function : fnct \ |
| line : __LINE__ \ |
| tag : atag \ |
| format : (frmt), ## __VA_ARGS__] |
| |
| #define LOG_MAYBE(async, lvl, flg, ctx, fnct, frmt, ...) \ |
| do { if(lvl & flg) LOG_MACRO(async, lvl, flg, ctx, nil, fnct, frmt, ##__VA_ARGS__); } while(0) |
| |
| #define LOG_OBJC_MAYBE(async, lvl, flg, ctx, frmt, ...) \ |
| LOG_MAYBE(async, lvl, flg, ctx, __PRETTY_FUNCTION__, frmt, ## __VA_ARGS__) |
| |
| #define DDLogError(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_ERROR, LOG_LEVEL_DEF, LOG_FLAG_ERROR, 0, frmt, ##__VA_ARGS__) |
| #define DDLogWarn(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_WARN, LOG_LEVEL_DEF, LOG_FLAG_WARN, 0, frmt, ##__VA_ARGS__) |
| #define DDLogInfo(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_INFO, LOG_LEVEL_DEF, LOG_FLAG_INFO, 0, frmt, ##__VA_ARGS__) |
| #define DDLogDebug(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_DEBUG, LOG_LEVEL_DEF, LOG_FLAG_DEBUG, 0, frmt, ##__VA_ARGS__) |
| #define DDLogVerbose(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_VERBOSE, LOG_LEVEL_DEF, LOG_FLAG_VERBOSE, 0, frmt, ##__VA_ARGS__) |
| |
| #endif |