Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Introduction to CocoaLumberjack
Search
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
36
Flexbox all the things
ksmandersen
2
150
Static Websites with Gulp & AWS
ksmandersen
0
130
Practical MVVM
ksmandersen
0
210
Practical Swift
ksmandersen
1
200
Other Decks in Programming
See All in Programming
【Streamlit x Snowflake】データ基盤からアプリ開発・AI活用まで、すべてをSnowflake内で実現
ayumu_yamaguchi
1
120
複数人でのCLI/Infrastructure as Codeの暮らしを良くする
shmokmt
5
2.2k
全員アーキテクトで挑む、 巨大で高密度なドメインの紐解き方
agatan
8
20k
20251127_ぼっちのための懇親会対策会議
kokamoto01_metaps
2
420
テストやOSS開発に役立つSetup PHP Action
matsuo_atsushi
0
150
안드로이드 9년차 개발자, 프론트엔드 주니어로 커리어 리셋하기
maryang
1
110
WebRTC と Rust と8K 60fps
tnoho
2
1.9k
認証・認可の基本を学ぼう後編
kouyuume
0
180
Microservices Platforms: When Team Topologies Meets Microservices Patterns
cer
PRO
1
1k
connect-python: convenient protobuf RPC for Python
anuraaga
0
400
STYLE
koic
0
160
C-Shared Buildで突破するAI Agent バックテストの壁
po3rin
0
380
Featured
See All Featured
Balancing Empowerment & Direction
lara
5
790
Producing Creativity
orderedlist
PRO
348
40k
Done Done
chrislema
186
16k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.3k
Thoughts on Productivity
jonyablonski
73
5k
The Language of Interfaces
destraynor
162
25k
A designer walks into a library…
pauljervisheath
210
24k
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Bash Introduction
62gerente
615
210k
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