toJson method
time (ISO 8601), level (its name), message, and the error and
the stack as text where there are.
Implementation
Map<String, Object?> toJson() => {
'time': time.toIso8601String(),
'level': level.name,
'message': message,
if (error != null) 'error': '$error',
if (stack != null) 'stack': '$stack',
};