Created
April 9, 2013 09:37
-
-
Save maxhuk/5344397 to your computer and use it in GitHub Desktop.
Template initialize for Lumberjack framework.
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
// | |
// LumberjackSettings.h | |
// | |
// Created by Maksym Huk on 2/11/13. | |
// Copyright (c) 2013 Maksym Huk. All rights reserved. | |
// | |
#import "DDLog.h" | |
enum { | |
ddLogLevel = LOG_LEVEL_VERBOSE | |
}; | |
@interface LogFormatter : NSObject <DDLogFormatter> | |
@end | |
void InitLogging(); |
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
// | |
// LumberjackSettings.m | |
// | |
// Created by Maksym Huk on 2/11/13. | |
// Copyright (c) 2013 Maksym Huk. All rights reserved. | |
// | |
#import "LumberjackSettings.h" | |
#import "DDASLLogger.h" | |
#import "DDTTYLogger.h" | |
@implementation LogFormatter | |
- (NSString*)formatLogMessage:(DDLogMessage *)message | |
{ | |
NSString* prefix = nil; | |
switch (message->logFlag) { | |
case LOG_FLAG_ERROR: | |
prefix = @"Error: "; | |
break; | |
case LOG_FLAG_WARN: | |
prefix = @"Warn: "; | |
break; | |
default: | |
prefix = @""; | |
break; | |
} | |
return [NSString stringWithFormat:@"%@[%@:%d %@] %@", | |
prefix, | |
message.fileName, | |
message->lineNumber, | |
message.methodName, | |
message->logMsg]; | |
} | |
void InitLogging() | |
{ | |
[DDLog addLogger:[DDASLLogger sharedInstance]]; | |
[DDASLLogger sharedInstance].logFormatter = [[LogFormatter alloc] init]; | |
[DDLog addLogger:[DDTTYLogger sharedInstance]]; | |
[DDTTYLogger sharedInstance].logFormatter = [[LogFormatter alloc] init]; | |
[[DDTTYLogger sharedInstance] setColorsEnabled:YES]; | |
[[DDTTYLogger sharedInstance] setForegroundColor:[UIColor colorWithHex:@"982513"] backgroundColor:nil forFlag:LOG_FLAG_INFO]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment