Configuration topic
Configuration
This module contains classes that control logging behavior.
ConfigLog
Central logging configuration class. It defines which logs should be processed and which should be ignored.
class ConfigLog {
final bool enableLog;
final Set<Type> onlyClasses;
}
Parameters
| Field | Type | Default | Description |
|---|---|---|---|
enableLog |
bool |
false |
Enables/disables log processing globally |
onlyClasses |
Set<Type> |
{DebugLog, WarningLog, InfoLog} |
Set of allowed log types |
Behavior
- When
enableLogisfalse, all logs are ignored exceptErrorLog(alwaysPrint = true). onlyClassesfilters by runtime type.ErrorLogdoes not need to be listed inonlyClassesto be processed.
Usage examples
Default config (logs disabled):
final config = ConfigLog();
// enableLog: false, onlyClasses: {DebugLog, WarningLog, InfoLog}
Enable logs in development:
final config = ConfigLog(enableLog: true);
Only errors and warnings:
final config = ConfigLog(
enableLog: true,
onlyClasses: {ErrorLog, WarningLog},
);
Production-style config (only critical errors always pass):
final config = ConfigLog(enableLog: false);
Integration with printer registration:
void main() {
registerLogPrinterColor(
config: ConfigLog(
enableLog: true,
onlyClasses: {DebugLog, ErrorLog},
),
);
}
Classes
- ConfigLog Configuration
- Configuration object for controlling logging behavior.