logError method
Use logError
, in a similar fashion to logFatal
, should be
used to capture a situation that cannot be fixed and requires a
special level of attention. However, in this case you can use
this method to capture an exception
and a stacktrace
, in
case your irreparable situation represents a crash in your code.
Implementation
@override
void logError(exception, [stacktrace]) {
final data = _baseData;
data['level'] = 'ERROR';
data['message'] = exception?.toString() ?? 'Error';
data['exception'] = <String, dynamic>{
'data': <String, dynamic>{
'stacktrace': (stacktrace as StackTrace).toString(),
},
};
data['event'] = <String, dynamic>{
'created': DateTime.now().toIso8601String(),
'type': 'exception',
};
_sendLog(data);
}