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(条件满足)   
  执行代码1   
  #else   
  执行代码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

添加环境变量 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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 7,938评论 0 3
  • 因为要结局swift3.0中引用snapKit的问题,看到一篇介绍Xcode8,swift3变化的文章,觉得很详细...
    uniapp阅读 10,133评论 0 12
  • 他们在谈爱情。都是发生在他们身上的。一个师生恋,一个伙伴之间。 他们在谈爱情。平日不多说的话活络起来,精神起来。 ...
    黑和暗阅读 1,049评论 0 0
  • 今天一大早,我们一家三口出门给亲戚拜年,到现在才回家。 这是滨弟第一次过年,亲戚们很是喜爱这个小家伙。 一整天带着...
    小玲00阅读 3,047评论 0 2
  • 有一类知识具有很特别的属性:不可逆。就是当你知道了以后,你的世界就完全不同了,而且没有办法回到原来的样子(赌徒谬误...
    守住这块热土阅读 1,072评论 0 0

友情链接更多精彩内容