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
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
51
Flexbox all the things
ksmandersen
2
170
Static Websites with Gulp & AWS
ksmandersen
0
140
Practical MVVM
ksmandersen
0
230
Practical Swift
ksmandersen
1
210
Other Decks in Programming
See All in Programming
SREの積み重ねがAI駆動開発のガードレールになった ― 7つの実践/SRE Guardrails The 7
tomoyakitaura
9
6k
人間の目はかわらない、だからJPEGは30年もつ
yuzneri
12
17k
komatsuna「分散システムにおけるバグ分析手法」
komatsunaqa
0
150
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
3
730
FDEが実現するAI駆動経営の現在地
gonta
2
250
JAWS-UG横浜 #102 AWSサ終供養LT会 成仏できない AWS サービスたち 〜本日、三体供養します〜
maroon1st
0
300
為什麼你並不需要ViewModel / No, you don't need a ViewModel
lovee
1
470
Haskell/Servantを通してWebミドルウェアを捉え直す
pizzacat83
1
630
Built Our Own Background Agent at LayerX #aidevex_findy
layerx
PRO
9
4.5k
React本体のコードリーディング
high_g_engineer
1
130
Prismを使った型安全な暗号化_関数型まつり2026
_fhhmm
0
160
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
3.4k
Featured
See All Featured
Making the Leap to Tech Lead
cromwellryan
135
10k
WENDY [Excerpt]
tessaabrams
11
39k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
790
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.3k
We Are The Robots
honzajavorek
0
290
The untapped power of vector embeddings
frankvandijk
2
1.8k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
230
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Design in an AI World
tapps
1
270
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