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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Kristian Andersen
February 13, 2014
Programming
120
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction to CocoaLumberjack
Presented at Cocoaheads Copenhagen on 13 Februrary 2014
Kristian Andersen
February 13, 2014
More Decks by Kristian Andersen
See All by Kristian Andersen
Isomorphic Web Apps with React
ksmandersen
0
49
Flexbox all the things
ksmandersen
2
160
Static Websites with Gulp & AWS
ksmandersen
0
140
Practical MVVM
ksmandersen
0
220
Practical Swift
ksmandersen
1
210
Other Decks in Programming
See All in Programming
「正の参照」と 「負の導出」で組む ハーネスエンジニアリング
cottpan
1
130
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
240
AI時代の仕事技芸論〜ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ(スクフェス仙台 2026バージョン)
kuranuki
0
500
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
500
【やさしく解説 設計編 #0】DDDのコード、読めるのに分からない人へ
panda728
PRO
2
240
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
4.9k
はてなアカウント基盤 State of the Union
cockscomb
1
1.3k
地域 SRE コミュニティ最前線 - ホンマでっかSRE勉強会
tk3fftk
0
190
フィードバックで育てるAI開発
kotaminato
1
110
どこまでゆるくて許されるのか
tk3fftk
0
450
Haskell/Servantを通してWebミドルウェアを捉え直す
pizzacat83
1
460
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
390
Featured
See All Featured
How to Think Like a Performance Engineer
csswizardry
28
2.7k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.6k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.1k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.2k
Visualization
eitanlees
152
17k
A Soul's Torment
seathinner
6
3k
How to Ace a Technical Interview
jacobian
281
24k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
410
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.4k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Become a Pro
speakerdeck
PRO
31
6k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
410
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