@@ -25,6 +25,8 @@ @interface SLLoggerController ()
25
25
26
26
@implementation SLLoggerController
27
27
28
+ @synthesize defaultFormatBlock = _defaultFormatBlock;
29
+
28
30
#pragma mark - Lifecycle
29
31
30
32
+ (SLLoggerController *)sharedController {
@@ -50,6 +52,7 @@ - (instancetype)init {
50
52
_async = YES ;
51
53
_errorAsync = NO ;
52
54
_globalLogLevel = SLLogLevelDebug;
55
+ _defaultFormatBlock = nil ;
53
56
54
57
return self;
55
58
}
@@ -127,11 +130,21 @@ + (SLLogLevel)logLevelForFile:(NSString *)file {
127
130
#pragma mark - Getters / Setters
128
131
129
132
- (SLLogFormatBlock)defaultFormatBlock {
130
- return ^NSString * (SLLog *log ) {
131
- NSString *callerClass = log .fileName ;
132
- NSString *callerFunction = log .functionName ;
133
- return [NSString stringWithFormat: @" (%@ :%@ )[%@ %@ ] %@ " , log .queueLabel, log .timestamp, callerClass, callerFunction, log .message];
134
- };
133
+ if (_defaultFormatBlock != nil ) {
134
+ return _defaultFormatBlock;
135
+ } else {
136
+ return [^NSString * (SLLog *log ) {
137
+ NSString *callerClass = log .fileName ;
138
+ NSString *callerFunction = log .functionName ;
139
+ return [NSString stringWithFormat: @" (%@ :%@ )[%@ %@ ] %@ " , log .queueLabel, log .timestamp, callerClass, callerFunction, log .message];
140
+ } copy];
141
+ }
142
+ }
143
+
144
+ - (void )setDefaultFormatBlock : (SLLogFormatBlock)defaultFormatBlock {
145
+ dispatch_async ([self .class globalLogQueue ], ^{
146
+ _defaultFormatBlock = defaultFormatBlock;
147
+ });
135
148
}
136
149
137
150
0 commit comments