DDLog使用筆記

Log levels: off, error, warn, info, debug, verbose

一、用到的:

#import <CocoaLumberjack/CocoaLumberjack.h>
#import <CocoaLumberjack/DDTTYLogger.h>

// Per-file log level for CocoaLumbejack (logging framework)
#if DEBUG
static const int ddLogLevel = DDLogLevelVerbose;
#else
static const int ddLogLevel = DDLogLevelWarn;
#endif
#pragma unused(ddLogLevel)

    [DDLog addLogger:[DDTTYLogger sharedInstance]];//寫終端
    [DDLog addLogger:[DDFileLogger new]]; //寫文件
//這里是0. 
    NSLog(@"%d",DD_LEGACY_MACROS);



    DDLogVerbose(@"Creating database instance...");
      DDLogError(@"Unable to register extension: order");


CocoaLumberjack.h
DDLogMacros.h

或者
#define DD_LEGACY_MACROS 0
DDLog.h
新版本。

二、用不到的
1.9.x的老版本。
DDLog.h

#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.

DDLog.h
#ifndef DD_LEGACY_MACROS
    #define DD_LEGACY_MACROS 1
#endif
// DD_LEGACY_MACROS is checked in the file itself
#import "DDLegacyMacros.h"





#ifndef x //先測試x是否被宏定義過
#define x
程序段1 //如果x沒有被宏定義過,定義x,并編譯程序段 1
#else
程序段2 //如果x已經定義過了則編譯程序段2的語句,“忽視”程序段 1。
#endif//終止if


 #if(條件滿足)   
  執(zhí)行代碼1   
  #else   
  執(zhí)行代碼2   
  #endif   

#if 0 
 ...............
#endif
當中的語句, 不會被編譯(在預編譯是被刪掉了)。
說白了, 就是沒有用的語句
1,      
    DDLogVerbose(@"Creating view...");



do { if(ddLogLevel & DDLogFlagVerbose) [DDLog log : __objc_yes level : ddLogLevel flag : DDLogFlagVerbose context : 0 file : "/Users/huchu/Documents/apple/iOS/UI/UITableViewEdit/UITableViewEdit/AppDelegate.m" function : __PRETTY_FUNCTION__ line : 84 tag : ((void *)0) format : (@"Creating database instance...")]; } while(0);



2,         DDLogError(@"Unable to register extension: order");

 
        do { if(ddLogLevel & DDLogFlagError) [DDLog log : __objc_no level : ddLogLevel flag : DDLogFlagError context : 0 file : "/Users/huchu/Documents/apple/iOS/UI/UITableViewEdit/UITableViewEdit/AppDelegate.m" function : __PRETTY_FUNCTION__ line : 99 tag : ((void *)0) format : (@"Unable to register extension: order")]; } while(0);




 #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_MAYBE(async, lvl, flg, ctx, tag, fnct, frmt, ...) \
        do { if(lvl & flg) LOG_MACRO(async, lvl, flg, ctx, tag, fnct, frmt, ##__VA_ARGS__); } while(0)




#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_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__]


日志顏色

安裝插件 https://github.com/robbiehanson/XcodeColors
./update_compat.sh

xcode插件無效解決方法: https://github.com/inket/update_xcode_plugins
gem install update_xcode_plugins
update_xcode_plugins
update_xcode_plugins --unsign
update_xcode_plugins --install-launch-agent

添加環(huán)境變量 XcodeColors:YES

管理插件的插件https://github.com/alcatraz/Alcatraz/issues/475

Select Package Manager from the Window menu, then check or uncheck packages to install or remove them. You'll need to restart Xcode after installing plugins or templates. Installed plugins are checked and updated each time Alcatraz is launched.

rm -rf ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/Alcatraz.xcplugin
To remove all packages installed via Alcatraz, run rm -rf ~/Library/Application\ Support/Alcatraz/

image.png
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom閱讀 3,232評論 0 3
  • 因為要結局swift3.0中引用snapKit的問題,看到一篇介紹Xcode8,swift3變化的文章,覺得很詳細...
    uniapp閱讀 4,877評論 0 12
  • 他們在談愛情。都是發(fā)生在他們身上的。一個師生戀,一個伙伴之間。 他們在談愛情。平日不多說的話活絡起來,精神起來。 ...
    黑和暗閱讀 112評論 0 0
  • 今天一大早,我們一家三口出門給親戚拜年,到現在才回家。 這是濱弟第一次過年,親戚們很是喜愛這個小家伙。 一整天帶著...
    小玲00閱讀 468評論 0 2
  • 有一類知識具有很特別的屬性:不可逆。就是當你知道了以后,你的世界就完全不同了,而且沒有辦法回到原來的樣子(賭徒謬誤...
    守住這塊熱土閱讀 129評論 0 0

友情鏈接更多精彩內容