LogStorage class

  • @Author: chuxiong
  • @Created at: 2025/01/XX
  • @Email:
  • @Company: 嘉联支付
  • description 日志存储

内存(Queue,容量上限后队首丢弃)+ 文件(按日 JSON 行文件,超 LogCollectorConfig.maxFileSize 时轮转归档,超 maxFileCount 删最旧)。 文件写入走持久化 IOSink,由定时器周期性 flush 而非每行强制刷盘。

Constructors

LogStorage({required LogCollectorConfig config})

Properties

config → LogCollectorConfig
当前存储配置。
final
hashCode → int
The hash code for this object.
no setterinherited
periodicFlushCount ↔ int
仅供测试观察:periodic flush 回调被触发的次数。
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

cleanupExpiredLogs() → Future<void>
清理过期日志
clear() → Future<void>
清空日志
dispose() → Future<void>
销毁存储
export({DateTime? startTime, DateTime? endTime, LogLevel? level, String? tag}) → Future<File?>
导出日志
flushForTesting() → Future<void>
仅供测试:显式 flush 文件 sink,确保缓冲区内容落盘以便读取验证。
getLogs({DateTime? startTime, DateTime? endTime, LogLevel? level, String? tag}) → Future<List<LogEntry>>
获取日志
initialize() → Future<void>
初始化存储
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
performPeriodicFlush() → void
周期性 flush 文件 sink。
store(LogEntry entry) → Future<void>
存储日志
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited