Created
March 17, 2012 03:33
-
-
Save juliengrimault/2054724 to your computer and use it in GitHub Desktop.
Cocoa Lumberjack formatter showing file, function and level of the log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// FileFunctionLevelFormatter.h | |
// | |
// Created by Julien Grimault on 23/1/12. | |
// Copyright (c) 2012 Julien Grimault. All rights reserved. | |
// | |
#import "DDLog.h" | |
@interface FileFunctionLevelFormatter : NSObject <DDLogFormatter> | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// FileFunctionLevelFormatter.m | |
// | |
// Created by Julien Grimault on 23/1/12. | |
// Copyright (c) 2012 Julien Grimault. All rights reserved. | |
// | |
#import "FileFunctionLevelFormatter.h" | |
@implementation FileFunctionLevelFormatter | |
- (NSString*)formatLogMessage:(DDLogMessage *)logMessage | |
{ | |
NSString* logLevel = nil; | |
switch (logMessage->logLevel) { | |
case LOG_FLAG_ERROR : logLevel = @"E"; break; | |
case LOG_FLAG_WARN : logLevel = @"W"; break; | |
case LOG_FLAG_INFO : logLevel = @"I"; break; | |
default : logLevel = @"V"; break; | |
} | |
return [NSString stringWithFormat:@"[%@][%@ %@][Line %d] %@", | |
logLevel, | |
logMessage.fileName, | |
logMessage.methodName, | |
logMessage->lineNumber, | |
logMessage->logMsg]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment