Skip to content

Instantly share code, notes, and snippets.

@forgot
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save forgot/2cb647c55bd0857c167b to your computer and use it in GitHub Desktop.
Save forgot/2cb647c55bd0857c167b to your computer and use it in GitHub Desktop.
CocoaLumberjack Line Number LogFormatter

All credit goes to Stack Overflow user UrK for the answer here: http://stackoverflow.com/a/19311779/862224

@interface LineNumberLogFormatter : NSObject<DDLogFormatter>

- (NSString *)formatLogMessage:(DDLogMessage *)logMessage;

@end

@implementation LineNumberLogFormatter
- (NSString *)formatLogMessage:(DDLogMessage *)logMessage
{
    NSString *path = [NSString stringWithCString:logMessage->file encoding:NSASCIIStringEncoding];
    NSString *fileName = [path lastPathComponent];
    return [NSString stringWithFormat:@"%@:%d %@", fileName, logMessage->lineNumber, logMessage->logMsg];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment