-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathISLogSystem.m
More file actions
executable file
·51 lines (40 loc) · 1.68 KB
/
ISLogSystem.m
File metadata and controls
executable file
·51 lines (40 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// ISLogSystem.m
//
//
// Created by Ivan Sinitsa on 11/13/13.
// Copyright (c) 2013 Home. All rights reserved.
//
#import "ISLogSystem.h"
#import "DDTTYLogger.h"
#import "DDASLLogger.h"
#import "DDFileLogger.h"
//Default file maximum size, initially set to 2MB.
static const int kISDefaultLogFileMaxSize = 2 * 1024 * 1024;
//Default roll frequency, initiallly set to 86400 in seconds (once per day)
static const int kISDefaultLogFileRollFrequency = 24 * 60 * 60;
//Defailt maximum number of log files, initially set to 5
static const int kISDefaultLogFileMaxFileNumber = 5;
@implementation ISLogSystem
//Setup loggers objects
+ (void)setupLogSystem:(int)aLogParamsMask logLevel:(int)aLogLevel
{
if (aLogParamsMask & kLogToConsole) {
//Initialize log output to Terminal or XCode
[DDLog addLogger:[DDTTYLogger sharedInstance] withLogLevel:aLogLevel];
//Initialize log output to Apple System Log
[DDLog addLogger:[DDASLLogger sharedInstance] withLogLevel:aLogLevel];
}
if (aLogParamsMask & kLogToFile) {
//Initialize log output to file
DDFileLogger *fileLogger = [DDFileLogger new]; //Prints log to files
[fileLogger setMaximumFileSize:kISDefaultLogFileMaxSize];
[fileLogger setRollingFrequency:kISDefaultLogFileRollFrequency];
[fileLogger.logFileManager setMaximumNumberOfLogFiles:kISDefaultLogFileMaxFileNumber];
[DDLog addLogger:fileLogger withLogLevel:aLogLevel]; //Always write log to file
}
DLog(@"***************************************************");
DLog(@"**** Started logging session at: %@ ****", [NSDate date]);
DLog(@"***************************************************");
}
@end