// Header file#import <TDOS_Diagnose/TDOSLoggerProxy.h>// Initialization method:@interface TDOSLogger : NSObject <TDLoggingIMPProtocol>/// Initializes the log SDK based on the configuration./// @param config configuration- (instancetype)initWithConfig:(TDOSLoggerConfig *)config;@end// TDOSLoggerConfig includes the following optional settings:/// Log directory@property (nonatomic, readonly) NSString *logPath;/// Default log level. Default: RAFTLogLevel_Error@property (nonatomic, readonly) RAFTLogLevel defaultLogLevel;/// Encryption Key@property (nonatomic, readonly) NSString *publicKey;/// Whether to output logs to the console. Default: NO (disabled).@property (nonatomic, assign) BOOL enableConsoleLog;/// Log file name prefix (optional)@property (nonatomic, copy) NSString *logFilePrefix;
RAFTLogLevelVerbose = 0,RAFTLogLevelDebug = 1,RAFTLogLevelInfo = 2,RAFTLogLevelWarn = 3,RAFTLogLevelError = 4,RAFTLogLevelFatal = 5,RAFTLogLevelNone = 6,
#define TDLogDebug(tag, format, ...)#define TDLogInfo(tag, format, ...)#define TDLogWarn(tag, format, ...)#define TDLogError(tag, format, ...)#define TDLogFatal(tag, format, ...)
/// log printing API (without format string)- (void)log:(RAFTLogLevel)leveltag:(NSString *)tagfile:(const char *)filefunc:(const char *)funcline:(int)linemsg:(NSString *)msg;/// log printing API (with format string)- (void)log:(RAFTLogLevel)leveltag:(NSString *)tagfile:(const char *)filefunc:(const char *)funcline:(int)lineformat:(NSString *)format, ... __attribute__((format(__NSString__, 6, 7))) NS_REQUIRES_NIL_TERMINATION;/// Checks if coloring is currently enabled.- (BOOL)isColorState;/// Resets the cloloring level.- (void)resetColorLevel;/// Sets the log level./// @param level Log level- (void)setLogLevel:(RAFTLogLevel)level;/// Sets the special level for printing log and the expiration time for the special level./// @param level Log level/// @param endtime End time- (void)setLogLevel:(RAFTLogLevel)level endTimestamp:(time_t)endtime;/// Forces writes logs to file./// @param isSync Whether to write synchronously- (void)flushLog:(BOOL)isSync;
/// Sets the maximum log retention time./// @param time Unit: seconds. Default: 10 days (10 * 24 * 60 * 60)- (void)setMaxLogAliveTime:(long)time;/// Sets the total log file size. When exceeded, old logs are automatically cleaned up (minimum limit: 50 MB)./// @param maxSize Total file size. Default: 0 (unlimited).- (void)setMaxTotalLogFileSize:(int64_t)maxSize;/// Sets console log output./// @param enabled Whether to enable- (void)setConsoleLogEnabled:(BOOL)enabled;
/// Gets a list of log files (hourly printed)./// @param startTime Start timestamp/// @param endTime End timestamp- (nullable NSArray<NSString *> *)getPeroidLogFilesWithStartTime:(NSTimeInterval)startTimeendTime:(NSTimeInterval)endTime;/// Gets the log list, supporting limiting the maximum log size./// (Discards old files first when the size limit is exceeded).////// @param startTime Start timestamp/// @param endTime End timestamp/// @param sizeLimit Maximum log package- (nullable NSArray<NSString *> *)getPeroidLogFilesWithStartTime:(NSTimeInterval)startTimeendTime:(NSTimeInterval)endTimesizeLimit:(unsigned long long)sizeLimit;/// Gets the log folder path.- (NSString *)getLogFolderPath;/// Gets the log encryption public key.- (nullable NSString *)getLogEncryptPublicKey;
/// Proactively pulls the log retrieval command.////// Call this when a push message is received.- (void)requestLogConfigFromServer;// Calling example:#import <TDOS_Diagnose/TDOS_Diagnose.h>[TDLogSDK.sharedInstance requestLogConfigFromServer];
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback