log method
Logs a message with the specified level and color.
This method handles the core logging logic, determining whether to display the message based on the verbose setting and log level.
Parameters:
message- The message to loglevel- The log level (defaults to info)
Behavior:
- Always writes to
distribution.logfile - Shows in terminal based on verbose setting and log level
Implementation
void log(String message, {LogLevel level = LogLevel.info}) async {
if (isVerbose) {
stdout.writeln('${level.color}$message$_reset');
} else {
if (level != LogLevel.debug && level != LogLevel.errorVerbose) {
stdout.writeln('${level.color}$message$_reset');
}
}
File(
"distribution.log",
).writeAsStringSync("$message\n", mode: FileMode.append);
}