krzysztofzablocki / LinkedConsole

Clickable links in your Xcode console, so you never wonder which class logged the message.
http://merowing.info
MIT License
931 stars 63 forks source link

CocoaLumberjack setup #33

Closed taher-mosbah closed 8 years ago

taher-mosbah commented 8 years ago

Hello, I'm trying to setup KZLinkedConsole with CocoaLumberjack 2.2 using your formatter at KZBootstrap/Logging in an Obj-c project.

Here is my code : [DDLog addLogger:[DDTTYLogger sharedInstance] withLevel:globalLogLevel]; [DDLog addLogger:[DDASLLogger sharedInstance] withLevel:globalLogLevel]; [DDTTYLogger sharedInstance].logFormatter = [[KZBootstrapLogFormatter alloc] init]; [[DDTTYLogger sharedInstance] setColorsEnabled:YES];

I had some compilation errors in KZBootstrapLogFormatter.h L87 formatLogMessage:

So I changed

NSString *formattedMsg = [NSString stringWithFormat:@"%04ld-%02ld-%02ld %02ld:%02ld:%02ld:%03d [%s] %s:%d (%s): %@", (long)components.year, (long)components.month, (long)components.day, (long)components.hour, (long)components.minute, (long)components.second, milliseconds, CRLLogFlagToCString(logMessage->logFlag), CRLPointerToLastPathComponent(logMessage->file), logMessage->lineNumber, logMessage->function ?: "", logMessage->logMsg];

to

NSString *formattedMsg = [NSString stringWithFormat:@"%04ld-%02ld-%02ld %02ld:%02ld:%02ld:%03d [%s] %s:%d (%s): %@", (long)components.year, (long)components.month, (long)components.day, (long)components.hour, (long)components.minute, (long)components.second, milliseconds, CRLLogFlagToCString(logMessage->_file), logMessage->_file, logMessage->_line, logMessage->_function ?: @"", logMessage->_message];

but all what I get in console is : 2016-04-13 10:48:48:359 [DBG] »B:376 (»B): my_log_message

any suggestions ?

Thank you !

krzysztofzablocki commented 8 years ago

well you can't mix C strings with NSString *, they are completely different beasts, and you do that for sure given that you use %s while using @"", check your types and match it with formatting expressions and it should be ok