LogSettings class

日志配置类

用于配置 LogUtils 的全局行为。

示例:

LogUtils.init(settings: LogSettings(
  useHistory: true,
  maxHistoryItems: 200,
  filters: [
    LevelLogFilter(allowedLevels: {LogLevel.error, LogLevel.warning}),
    PrefixLogFilter(prefixes: ['API', 'DB']),
  ],
));

Constructors

LogSettings({List<LogFilter> filters = const [], bool useHistory = true, int maxHistoryItems = 1000, bool useConsoleLogs = true, bool enableColors = false})
创建日志配置
const

Properties

enableColors bool
是否启用控制台日志颜色(解决某些终端如 iOS 控制台出现 ANSI 乱码 \x1B[0m 的问题)
final
filters List<LogFilter>
过滤器列表,日志必须通过所有过滤器才会被记录
final
hashCode int
The hash code for this object.
no setterinherited
maxHistoryItems int
最大保存的日志历史条数
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
useConsoleLogs bool
是否输出到控制台
final
useHistory bool
是否保存日志历史
final

Methods

copyWith({List<LogFilter>? filters, bool? useHistory, int? maxHistoryItems, bool? useConsoleLogs, bool? enableColors}) LogSettings
创建配置的副本,可覆盖部分字段
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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