log function
Outputs the specified message to the IO destination previously
set in showLog().
Returns true if the message is output, false if not.
Accepts source and level arguments that respectively, can be used to
identify which library/package/source this message pertains to, and the logging
Severity level.
source defaults to "Log", and Severity.info is the default log level
// example
log("This is a message");
// example with non-default `source` and `level` set
log("Another message", source: "MyPackage", level = Severity.warning);
Implementation
bool log(String message, {String source = "Log", Severity level = Severity.info}) {
if (_sink != null && Severity.hasLevel(_severity, level)) {
String lvl = level.toString().split('.')[1];
_sink!.writeln('$source ($lvl): ${DateTime.timestamp()} $message');
return true;
}
return false;
}