PDLogConfig class

日志配置项,用于全局控制日志行为。

使用 PDLog.configure 设置全局配置。常用选项:

  • enabled:是否启用日志;
  • minLevel:最小输出级别(低于该级别的日志会被忽略);
  • defaultTag:默认标签;
  • useConsole:是否在 Dart 控制台打印;
  • showTimestamp:是否在输出中加入时间戳。

本地文件写入(Dart 管理)相关:

  • nativeFileLoggingEnabled:是否开启本地文件写入(由 Dart 写入器处理);
  • nativeFileLoggingFlushIntervalMs:缓冲刷新间隔(毫秒);
  • nativeFileLoggingMaxBufferEntries:缓冲最大条目数;
  • nativeFileLoggingMaxBufferBytes:缓冲最大字节数;
  • fileLoggingMinLevel:写入文件的最小级别(低于该级别不写入文件)。

Constructors

PDLogConfig({bool enabled = true, LogLevel minLevel = LogLevel.verbose, String? defaultTag, bool useConsole = true, bool showTimestamp = false, bool ansiEnabled = false, bool showCaller = false, bool nativeFileLoggingEnabled = false, int nativeFileLoggingFlushIntervalMs = 2000, int nativeFileLoggingMaxBufferEntries = 100, int nativeFileLoggingMaxBufferBytes = 64 * 1024, Map<LogLevel, LogStyleConfig> logStyles = kDefaultLogStyles, LogLevel fileLoggingMinLevel = LogLevel.info, LogRetentionStrategy logRetentionStrategy = LogRetentionStrategy.none, int logRetentionCount = 0, int fileEventDedupeWindowMs = 500, int mobileWatchPollingIntervalMs = 2000})
const

Properties

ansiEnabled bool
是否启用 ANSI 颜色包裹(控制台/平台输出)。
final
defaultTag String?
final
enabled bool
final
fileEventDedupeWindowMs int
文件事件去重窗口(毫秒)。
final
fileLoggingMinLevel LogLevel
写入文件的最小级别阈值。
final
hashCode int
The hash code for this object.
no setterinherited
logRetentionCount int
滚动保留的数量,按 策略 的单位解释:
final
logRetentionStrategy LogRetentionStrategy
日志滚动策略(保留最近 N 天 / 月 / 年)。
final
logStyles Map<LogLevel, LogStyleConfig>
日志颜色样式配置(按级别设置前景色/背景色/样式)。
final
minLevel LogLevel
final
mobileWatchPollingIntervalMs int
移动端文件轮询间隔(毫秒)。
final
nativeFileLoggingEnabled bool
本地文件写入配置(Dart 管理):是否启用与缓冲策略
final
nativeFileLoggingFlushIntervalMs int
final
nativeFileLoggingMaxBufferBytes int
final
nativeFileLoggingMaxBufferEntries int
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showCaller bool
是否在日志中显示调用者函数信息(通过解析调用栈获取)。
final
showTimestamp bool
final
useConsole bool
final

Methods

copyWith({bool? enabled, LogLevel? minLevel, String? defaultTag, bool? useConsole, bool? showTimestamp, bool? ansiEnabled, bool? showCaller, bool? nativeFileLoggingEnabled, int? nativeFileLoggingFlushIntervalMs, int? nativeFileLoggingMaxBufferEntries, int? nativeFileLoggingMaxBufferBytes, Map<LogLevel, LogStyleConfig>? logStyles, LogLevel? fileLoggingMinLevel, LogRetentionStrategy? logRetentionStrategy, int? logRetentionCount, int? fileEventDedupeWindowMs, int? mobileWatchPollingIntervalMs}) PDLogConfig
复制当前配置并覆盖部分字段。
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