addSimpleLog method
- SimpleOverlayLog log
Writes a SimpleOverlayLog to the persistent log file.
The log is written to a file named simple_logs.jsonl within the
application support directory. The log is written in JSON Lines format.
The log is written asynchronously in a separate isolate to avoid blocking the main isolate.
The log is written as a single JSON object, with the following keys:
timestamp: The timestamp of the log event, in ISO 8601 format.tag: The tag of the log event, a short string identifying the source of the log.level: The log level of the log event, one of "debug", "info", "warn", or "error".message: The log message itself, a string.
Implementation
Future<void> addSimpleLog(SimpleOverlayLog log) async {
_printStyled(log.level.name, log.tag, log.message);
final dir = await getApplicationSupportDirectory();
final path = dir.path;
final payload = {
'path': path,
'type': 'simple',
...log.toJson(),
};
await Isolate.run(() => SimpleOverlayIsolateLogWriter.writeLog(payload));
}