SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Downloaden Sie, um offline zu lesen
CocoaLumberjack
Hi!
I’m
Kristian
@ksmandersen
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!");
DDLogWarn(@"Low toner.");
DDLogInfo(@"Doc printed.");
DDLogDebug(@"Debugging");
DDLogVerbose(@"Init doc_parse");

//
//
//
//
//

E
W
I
D
V

|
|
|
|
|

Paper Jam!
Low toner.
Doc printed.
Debugging
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

Weitere Àhnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
 Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
 
Learn ELK in docker
Learn ELK in dockerLearn ELK in docker
Learn ELK in docker
 
MongoDB World 2019: Distributed Transactions: With Great Power Comes Great Re...
MongoDB World 2019: Distributed Transactions: With Great Power Comes Great Re...MongoDB World 2019: Distributed Transactions: With Great Power Comes Great Re...
MongoDB World 2019: Distributed Transactions: With Great Power Comes Great Re...
 
Logmanagement with Icinga2 and ELK
Logmanagement with Icinga2 and ELKLogmanagement with Icinga2 and ELK
Logmanagement with Icinga2 and ELK
 
Clustering and load balancing : jboss
Clustering and load balancing : jbossClustering and load balancing : jboss
Clustering and load balancing : jboss
 
pgWALSync
pgWALSyncpgWALSync
pgWALSync
 
JavaDay Lviv: Serverless Archtiectures
JavaDay Lviv: Serverless ArchtiecturesJavaDay Lviv: Serverless Archtiectures
JavaDay Lviv: Serverless Archtiectures
 
What the HTML? - The Holy Grail
What the HTML? - The Holy GrailWhat the HTML? - The Holy Grail
What the HTML? - The Holy Grail
 
Serverless Computing with AWS
Serverless Computing with AWSServerless Computing with AWS
Serverless Computing with AWS
 
Consul - service discovery and others
Consul - service discovery and othersConsul - service discovery and others
Consul - service discovery and others
 
Node js
Node jsNode js
Node js
 
Fine tuning Hybrid Mobile App
Fine tuning Hybrid Mobile AppFine tuning Hybrid Mobile App
Fine tuning Hybrid Mobile App
 
DNS Server benchmarking
DNS Server benchmarkingDNS Server benchmarking
DNS Server benchmarking
 
High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014High Performance Systems in Go - GopherCon 2014
High Performance Systems in Go - GopherCon 2014
 
Clack: glue for web apps
Clack: glue for web appsClack: glue for web apps
Clack: glue for web apps
 
I can't believe it's not a queue: Kafka and Spring
I can't believe it's not a queue: Kafka and SpringI can't believe it's not a queue: Kafka and Spring
I can't believe it's not a queue: Kafka and Spring
 
Clouds presentation, aws meetup v2
Clouds presentation, aws meetup   v2Clouds presentation, aws meetup   v2
Clouds presentation, aws meetup v2
 
Local Lambda Debugging
Local Lambda DebuggingLocal Lambda Debugging
Local Lambda Debugging
 
Aurora Serverless, 서ëČ„ëŠŹìŠ€ RDB의 서막 - 튾랙2, Community Day 2018 re:Invent íŠč집
Aurora Serverless, 서ëČ„ëŠŹìŠ€ RDB의 서막 - 튾랙2, Community Day 2018 re:Invent íŠč집Aurora Serverless, 서ëČ„ëŠŹìŠ€ RDB의 서막 - 튾랙2, Community Day 2018 re:Invent íŠč집
Aurora Serverless, 서ëČ„ëŠŹìŠ€ RDB의 서막 - 튾랙2, Community Day 2018 re:Invent íŠč집
 
RSYSLOG v8 improvements and how to write plugins in any language.
RSYSLOG v8 improvements and how to write plugins in any language.RSYSLOG v8 improvements and how to write plugins in any language.
RSYSLOG v8 improvements and how to write plugins in any language.
 

Ähnlich wie Introduction to CocoaLumberjack

gdscWorkShopJavascriptintroductions.pptx
gdscWorkShopJavascriptintroductions.pptxgdscWorkShopJavascriptintroductions.pptx
gdscWorkShopJavascriptintroductions.pptx
sandeshshahapur
 
Messaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkMessaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new framework
Tomas Doran
 
Lotuscript for large systems
Lotuscript for large systemsLotuscript for large systems
Lotuscript for large systems
Bill Buchan
 
Buildingsocialanalyticstoolwithmongodb
BuildingsocialanalyticstoolwithmongodbBuildingsocialanalyticstoolwithmongodb
Buildingsocialanalyticstoolwithmongodb
MongoDB APAC
 
London devops logging
London devops loggingLondon devops logging
London devops logging
Tomas Doran
 

Ähnlich wie Introduction to CocoaLumberjack (20)

Building microservices with Kotlin
Building microservices with KotlinBuilding microservices with Kotlin
Building microservices with Kotlin
 
Lecture 5: Client Side Programming 1
Lecture 5: Client Side Programming 1Lecture 5: Client Side Programming 1
Lecture 5: Client Side Programming 1
 
Into The Box 2018 Ortus Keynote
Into The Box 2018 Ortus KeynoteInto The Box 2018 Ortus Keynote
Into The Box 2018 Ortus Keynote
 
Don't Fear the Platform
Don't Fear the PlatformDon't Fear the Platform
Don't Fear the Platform
 
Test like a_boss
Test like a_bossTest like a_boss
Test like a_boss
 
Rails israel 2013
Rails israel 2013Rails israel 2013
Rails israel 2013
 
Untangling spring week10
Untangling spring week10Untangling spring week10
Untangling spring week10
 
gdscWorkShopJavascriptintroductions.pptx
gdscWorkShopJavascriptintroductions.pptxgdscWorkShopJavascriptintroductions.pptx
gdscWorkShopJavascriptintroductions.pptx
 
Messaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new frameworkMessaging, interoperability and log aggregation - a new framework
Messaging, interoperability and log aggregation - a new framework
 
Rust kafka-5-2019-unskip
Rust kafka-5-2019-unskipRust kafka-5-2019-unskip
Rust kafka-5-2019-unskip
 
Solid And Sustainable Development in Scala
Solid And Sustainable Development in ScalaSolid And Sustainable Development in Scala
Solid And Sustainable Development in Scala
 
Lotuscript for large systems
Lotuscript for large systemsLotuscript for large systems
Lotuscript for large systems
 
Fedora Developer's Conference 2014 Talk
Fedora Developer's Conference 2014 TalkFedora Developer's Conference 2014 Talk
Fedora Developer's Conference 2014 Talk
 
Buildingsocialanalyticstoolwithmongodb
BuildingsocialanalyticstoolwithmongodbBuildingsocialanalyticstoolwithmongodb
Buildingsocialanalyticstoolwithmongodb
 
London devops logging
London devops loggingLondon devops logging
London devops logging
 
Thinkful - Intro to JavaScript
Thinkful - Intro to JavaScriptThinkful - Intro to JavaScript
Thinkful - Intro to JavaScript
 
Intro to javascript (6:27)
Intro to javascript (6:27)Intro to javascript (6:27)
Intro to javascript (6:27)
 
Future-proof Development for Classic SharePoint
Future-proof Development for Classic SharePointFuture-proof Development for Classic SharePoint
Future-proof Development for Classic SharePoint
 
Solid and Sustainable Development in Scala
Solid and Sustainable Development in ScalaSolid and Sustainable Development in Scala
Solid and Sustainable Development in Scala
 
Intro to JavaScript - Thinkful LA, June 2017
Intro to JavaScript - Thinkful LA, June 2017Intro to JavaScript - Thinkful LA, June 2017
Intro to JavaScript - Thinkful LA, June 2017
 

KĂŒrzlich hochgeladen

KĂŒrzlich hochgeladen (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 

Introduction to CocoaLumberjack