PDLogConfig class

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

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

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

原生文件日志相关:

  • nativeFileLoggingEnabled:是否开启原生文件写入(受平台支持约束);
  • nativeFileLoggingFlushIntervalMs:缓冲刷新间隔(毫秒);
  • nativeFileLoggingMaxBufferEntries:缓冲最大条目数;
  • nativeFileLoggingMaxBufferBytes:缓冲最大字节数;
  • fileLoggingMinLevel:写入文件的最小级别(低于该级别不写入文件)。

Constructors

PDLogConfig.new({bool enabled = true, LogLevel minLevel = LogLevel.debug, String? defaultTag, bool useNative = true, bool useConsole = true, bool showTimestamp = true, 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})
const

Properties

defaultTag String?
final
enabled bool
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
nativeFileLoggingEnabled bool
原生文件日志配置:是否启用与缓冲策略
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
useNative bool
final

Methods

copyWith({bool? enabled, LogLevel? minLevel, String? defaultTag, bool? useNative, bool? useConsole, bool? showTimestamp, bool? showCaller, bool? nativeFileLoggingEnabled, int? nativeFileLoggingFlushIntervalMs, int? nativeFileLoggingMaxBufferEntries, int? nativeFileLoggingMaxBufferBytes, Map<LogLevel, LogStyleConfig>? logStyles, LogLevel? fileLoggingMinLevel, LogRetentionStrategy? logRetentionStrategy, int? logRetentionCount}) 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