FilePrinter class

文件日志输出器

负责将日志写入文件,并支持日志轮转功能。 继承自 AsyncOutputer,实现异步写入和批处理优化。

Implemented types

Constructors

FilePrinter.new({required String logDirectory, required String baseFileName, RotateStrategy? rotateStrategy, CompressionHandler? compressionHandler, AbstractLogFormatter? formatter, LogRotateConfig? rotateConfig, int maxQueueSize = _defaultMaxQueueSize, Duration flushInterval = _defaultFlushInterval, int maxRetries = _defaultMaxRetries, Duration retryDelay = _defaultRetryDelay})

Properties

baseFileName String
getter/setter pair
config Map<String, dynamic>
获取打印器的配置信息
no setteroverride
flushInterval Duration
getter/setter pairinherited
formatter AbstractLogFormatter
final
hashCode int
The hash code for this object.
no setterinherited
isClosed bool
检查打印器是否已关闭
no setterinherited
logDirectory String
getter/setter pair
maxQueueSize int
getter/setter pairinherited
maxRetries int
getter/setter pairinherited
name String
获取打印器的名称
no setteroverride
retryDelay Duration
getter/setter pairinherited
rotateManager LogRotateManager
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
supportedLevels List<String>
获取打印器支持的日志级别
no setteroverride

Methods

close() Future<void>
关闭打印器
formatError(dynamic error, StackTrace? stackTrace) String
格式化异常信息
override
formatMessage(dynamic message) String
格式化日志消息
override
getLevelBgColor(LogLevel level) String
override
getLevelColor(LogLevel level) String
override
getLevelFgColor(LogLevel level) String
override
getStats() Map<String, dynamic>
获取打印器的统计信息
init() Future<void>
初始化打印器
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
printf(LogRecord record) String
打印日志
inherited
processBatch(List<LogRecord> records) Future<void>
异步批处理多条日志记录 子类可以重写此方法以实现批处理优化
processRecord(LogRecord record) Future<void>
异步处理单条日志记录
resetStats() → void
重置打印器的统计信息
inherited
setColorSupport(bool enabled) → void
设置打印器的颜色支持
override
toString() String
A string representation of this object.
inherited
updateConfig(Map<String, dynamic> newConfig) Future<void>
更新打印器的配置

Operators

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