//
//  AliyunLogFileManager.h
//  AliyunStablex
//
//  Created by 顾鹿 on 2026/3/18.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSInteger, LogType) {
    LogTypeCrash,
    LogTypeEvent, // 埋点日志
    LogTypeDebug, // 调试日志
};
typedef void (^AliyunLogFileBlock)(NSArray *filePathArray);

@interface AliyunLogFileManager : NSObject

@property (nonatomic,strong)NSString *crashLogDirectory;
@property (nonatomic,strong)NSString *eventLogDirectory;
@property (nonatomic,strong)NSString *debugLogDirectory;
@property (nonatomic, assign) NSInteger maxFileCountPerType;
@property (nonatomic, assign) NSInteger maxTotalSizePerType;

+ (instancetype)sharedManager;
// 写入日志，传入日志类型
- (void)writeLog:(NSString *)log ofType:(LogType)type completion:(void (^)(void))completion;
// 读取某类型的全部日志（按时间倒序）
- (NSArray<NSString *> *)readAllLogsOfType:(LogType)type;

// 读取某类型的最新日志
- (nullable NSString *)readLatestLogOfType:(LogType)type;

// 删除某类型的全部日志
- (void)deleteAllLogsOfType:(LogType)type;

// 删除某个特定文件（可跨类型使用）
- (void)deleteLogFileAtPath:(NSString *)filePath;

// 标记某个日志为已上传
- (void)markLogFileAsUploadedAtPath:(NSString *)filePath;

// 获取所有未上传的日志路径（可选）
- (NSArray<NSString *> *)getUnuploadedLogFilePathsOfType:(LogType)type;

// 上传未上传的日志
- (void)autoUploadUnuploadedLogsOfType:(LogType)type block:(AliyunLogFileBlock) LogFileBlock;

// 容量控制：清理超出数量/大小限制的旧日志
- (void)enforceStorageLimitsForType:(LogType)type;


@end


NS_ASSUME_NONNULL_END

