Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CocoaLumberjack and NSLog in other libraries

I'm using CocoaLumberjack for all the logging in my app. Using this I can log straight to a file by using DDLogVerbose(...) or any of the available variants.

I'm also using fmdb (SQLite wrapper). The problem is that this library uses NSLog() and none if its output ends up on my log file.

Is there a way to capture NSLog's output and redirect it to CocoaLumberjack's? Or if that's not possible, just "rewrite" NSLog() so that it actually executes DDLogVerbose()?

like image 801
Julian Avatar asked Aug 22 '12 17:08

Julian


2 Answers

Try adding

#define NSLog DDLogInfo

to the top of the other libraries. Of course you will need to

#include "Logging.h"

for it to work.

like image 179
Matthew Kelling Avatar answered Nov 26 '22 09:11

Matthew Kelling


This may work, but it could also create an infinite loop since CocoaLumberjack is using NSLog, so a redefinition with DDLogInfo could mess things up. You just need to try and see.

like image 44
Bogdan Avatar answered Nov 26 '22 11:11

Bogdan