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/
