Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Introduction to CocoaLumberjack
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Kristian Andersen
February 13, 2014
Programming
0
110
Introduction to CocoaLumberjack
Presented at Cocoaheads Copenhagen on 13 Februrary 2014
Kristian Andersen
February 13, 2014
Tweet
Share
More Decks by Kristian Andersen
See All by Kristian Andersen
Isomorphic Web Apps with React
ksmandersen
0
39
Flexbox all the things
ksmandersen
2
160
Static Websites with Gulp & AWS
ksmandersen
0
130
Practical MVVM
ksmandersen
0
220
Practical Swift
ksmandersen
1
200
Other Decks in Programming
See All in Programming
OCaml 5でモダンな並列プログラミングを Enjoyしよう!
haochenx
0
160
SourceGeneratorのススメ
htkym
0
610
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
1
1k
Claude Codeと2つの巻き戻し戦略 / Two Rewind Strategies with Claude Code
fruitriin
0
180
24時間止められないシステムを守る-医療ITにおけるランサムウェア対策の実際
koukimiura
2
170
あなたはユーザーではない #PdENight
kajitack
4
200
AIプロダクト時代のQAエンジニアに求められること
imtnd
1
440
Gemini for developers
meteatamel
0
120
朝日新聞のデジタル版を支えるGoバックエンド ー価値ある情報をいち早く確実にお届けするために
junkiishida
1
200
atmaCup #23でAIコーディングを活用した話
ml_bear
4
610
今から始めるClaude Code超入門
448jp
8
9.4k
文字コードの話
qnighy
35
12k
Featured
See All Featured
The browser strikes back
jonoalderson
0
710
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.4k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
199
72k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
90
Between Models and Reality
mayunak
1
210
30 Presentation Tips
portentint
PRO
1
240
Become a Pro
speakerdeck
PRO
31
5.8k
GraphQLとの向き合い方2022年版
quramy
50
14k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
120
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
Transcript
CocoaLumberjack
Hi! I’m Kristian @ksmandersen
None
None
CocoaLumberjack
Why? • NSLog is inflexible • NSLog is slow •
NSLog has no levels
Performance “[…] I switched out all the logging statements from
using NSLog to use CocoaLumberjacks DDLog instead, and saw an increase in performance of almost 6x […]”
Performance “[…] I switched out all the logging statements from
using NSLog to use CocoaLumberjacks DDLog instead, and saw an increase in performance of almost 6x […]”
Performance 1. Open a new connection to ASL daemon 2.
Send message to ASL daemon 3. Close that connection 4. Write the same message to STDERR 5. for each NSLog statement: GOTO 1;
CocoaLumberjack • Multiple outputs • Different logging levels • Much
faster! • Very flexible
Getting started [DDLog addLogger:[DDTTYLogger sharedInstance]];
LEVELS DDLogError(@"Some error %@, %@", error, error.userInfo); DDLogWarn(@"Unexpected thing"); DDLogInfo(@"Heads
up here"); DDLogDebug(@"Bug bug debug"); DDLogVerbose(@"Extreme verbosity");
Replacing NSLOG // Making NSLog use Cocoa Lumberjack #define NSLog
DDLogInfo
Replacing NSLOG // Making NSLog use Cocoa Lumberjack #define NSLog
DDLogInfo
Colors https://github.com/robbiehanson/XcodeColors
AFNetworking AFNetworkActivityLogger *logger = [AFNetworkActivityLogger sharedLogger]; ! [logger setLevel:AFLoggerLevelInfo]]; [logger
startLogging];
AFNetworking GET http://example.com/foo/bar.json 200 http://example.com/foo/bar.json ! POST http://example.com/other/url.json 503 http://example.com/other/url.json
Crashlytics [DDLog addLogger:[CrashlyticsLogger sharedInstance]];
Formatters DDLogError(@"Paper Jam!"); // E | Paper Jam! DDLogWarn(@"Low toner.");
// W | Low toner. DDLogInfo(@"Doc printed."); // I | Doc printed. DDLogDebug(@"Debugging"); // D | Debugging DDLogVerbose(@"Init doc_parse"); // V | Init doc_parse.
Formatters - (NSString *)formatLogMessage:(DDLogMessage *)logMessage { NSString *logLevel; switch (logMessage->logFlag)
{ case LOG_FLAG_ERROR : logLevel = @"E"; break; case LOG_FLAG_WARN : logLevel = @"W"; break; case LOG_FLAG_INFO : logLevel = @"I"; break; case LOG_FLAG_DEBUG : logLevel = @"D"; break; default : logLevel = @"V"; break; } return [NSString stringWithFormat:@"%@ | %@\n", logLevel, logMessage->logMsg]; }
Per logger levels [DDLog addLogger:[DDTTYLogger sharedInstance] withLogLevel:LOG_LEVEL_INFO];
PER CLASS LEVEL + (NSArray *)registeredClasses; + (NSArray *)registeredClassNames; !
+ (int)logLevelForClass:(Class)aClass; + (int)logLevelForClassWithName:(NSString *)aClassName; ! + (void)setLogLevel:(int)logLevel forClass:(Class)aClass; + (void)setLogLevel:(int)logLevel forClassWithName:(NSString *)aClassName;
App broken w/ no crash
App broken w/ no crash
Rolling Logs DDFileLogger *fileLogger = [[DDFileLogger alloc] init]; ! [fileLogger
setRollingFrequency:60 * 60 * 24]; [fileLogger setMaximumFileSize:1024 * 1024 * 2]; [fileLogger.logFileManager setMaximumNumberOfLogFiles:7]; [DDLog addLogger:fileLogger];
DEMO
Questions? @ksmandersen
jobs.robo.cat