@@ -54,6 +54,9 @@ @interface QCloudLogger () <QCloudFileLoggerDelegate>
5454@end
5555
5656@implementation QCloudLogger
57+ {
58+ NSMutableArray * _loggerOutputs;
59+ }
5760
5861+ (instancetype )sharedLogger
5962{
@@ -85,8 +88,10 @@ - (instancetype) init
8588 if (!self) {
8689 return self;
8790 }
91+ _loggerOutputs = [NSMutableArray new ];
8892 _currentFileLogger = [[QCloudFileLogger alloc ] initWithPath: [self avilableLogFilePath ] maxSize: QCloudEachLogFileSize];
8993 _currentFileLogger.delegate = self;
94+ [_loggerOutputs addObject: _currentFileLogger];
9095 _maxStoarageSize = 70 *1024 *1024 ;
9196 _keepDays = 3 ;
9297 //
@@ -113,6 +118,9 @@ - (instancetype) init
113118
114119- (void ) fileLoggerDidFull : (QCloudFileLogger *)logger
115120{
121+ if (logger != _currentFileLogger) {
122+ return ;
123+ }
116124 NSString * nextLogPath = [self avilableLogFilePath ];
117125 if (_currentFileLogger.isFull ) {
118126 QCloudFileLogger * fileLogger =[[QCloudFileLogger alloc ] initWithPath: nextLogPath maxSize: QCloudEachLogFileSize];
@@ -207,7 +215,22 @@ - (void)logMessageWithLevel:(QCloudLogLevel)level
207215 QCloudLogModel* model = CreateLog ();
208216 NSLog (@" %@ " ,[model debugDescription ]);
209217 }
210- [self .currentFileLogger appendLog: CreateLog];
218+ for (QCloudLoggerOutput* output in _loggerOutputs) {
219+ [output appendLog: CreateLog];
220+ }
211221 va_end (args);
212222}
223+
224+ - (void ) addLogger : (QCloudLoggerOutput *)output
225+ {
226+ if (!output) {
227+ return ;
228+ }
229+ [_loggerOutputs addObject: output];
230+ }
231+
232+ - (void ) removeLogger : (QCloudLoggerOutput *)output
233+ {
234+ [_loggerOutputs removeObject: output];
235+ }
213236@end
0 commit comments