CocoaLumberjack是一个功能丰富的第三方日志系统。其生成的log文件,默认是自动命名的,如果需要自定义文件名,重载两个函数即可。

// Log.h
#import
"CocoaLumberjack.h" @interface CustomLogFileManager : DDLogFileManagerDefault - (instancetype)initWithLogsDirectory:(NSString *)logsDirectory fileName:(NSString *)name; @end

 

// Log.m
#import
<Foundation/Foundation.h> #import "Log.h" @interface CustomLogFileManager () @property (nonatomic, copy) NSString *fileName; @end @implementation CustomLogFileManager #pragma mark - Lifecycle method - (instancetype)initWithLogsDirectory:(NSString *)logsDirectory fileName:(NSString *)name { self = [super initWithLogsDirectory:logsDirectory]; if (self) { self.fileName = name; } return self; } #pragma mark - Override methods - (NSString *)newLogFileName { return [NSString stringWithFormat:@"%@", self.fileName]; } - (BOOL)isLogFile:(NSString *)fileName { return [fileName isEqualToString:self.fileName]; } @end

 

相关文章:

  • 2021-12-16
  • 2022-02-21
  • 2021-06-02
  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
  • 2022-02-27
  • 2021-11-27
猜你喜欢
  • 2021-06-22
  • 2021-11-21
  • 2021-11-21
  • 2021-07-07
  • 2022-12-23
  • 2021-11-01
  • 2021-07-14
相关资源
相似解决方案