log method
Implementation
@override
void log(TomDiagnosticEvent event) {
if (_failure != null) return;
if (event.level.index > minimumLevel.index) return;
final line = '${jsonEncode(event.toMap(), toEncodable: _encodable)}\n';
try {
final file = File(_path);
// Checked before the append rather than after, so the ceiling is a
// ceiling: rotating afterwards would let one oversized line live in a
// file that is already over budget until the *next* line arrives.
if (file.existsSync() && file.lengthSync() + line.length > maxBytes) {
_rotate();
} else {
file.parent.createSync(recursive: true);
}
File(_path).writeAsStringSync(line, mode: FileMode.append, flush: true);
} on FileSystemException catch (e) {
_failure = e;
}
}