Created
September 9, 2010 13:36
-
-
Save steipete/571860 to your computer and use it in GitHub Desktop.
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
// | |
// PSDDFormatter.h | |
// Created by Peter Steinberger on 08.09.10. | |
// | |
#import "DDLog.h" | |
@interface PSDDFormatter : NSObject <DDLogFormatter> { | |
NSDateFormatter *dateFormatter; | |
} | |
@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
// | |
// PSDDFormatter.m | |
// Created by Peter Steinberger on 08.09.10. | |
// | |
#import "PSDDFormatter.h" | |
@implementation PSDDFormatter | |
- (id)init { | |
if((self = [super init])) | |
{ | |
dateFormatter = [[NSDateFormatter alloc] init]; | |
[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4]; | |
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss:SSS"]; | |
} | |
return self; | |
} | |
- (NSString *)formatLogMessage:(DDLogMessage *)logMessage { | |
NSString *logLevel; | |
switch (logMessage->logFlag) { | |
case LOG_FLAG_ERROR : logLevel = @"Error: "; break; | |
case LOG_FLAG_WARN : logLevel = @"Warning: "; break; | |
case LOG_FLAG_INFO : logLevel = @""; break; | |
default : logLevel = @"V"; break; | |
} | |
NSString *dateAndTime = [dateFormatter stringFromDate:(logMessage->timestamp)]; | |
NSString *logMsg = logMessage->logMsg; | |
return [NSString stringWithFormat:@"%@%@(%@) [%@ %@/%d] %@", logLevel, dateAndTime, [logMessage threadID], [logMessage fileName], [logMessage methodName], logMessage->lineNumber, logMsg]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment