json static method
Logs JSON message
to the console.
If the message is not JSON-serializable, logs an error instead.
Only logs in debug mode unless alwaysPrint
is set to true
.
Implementation
static void json(dynamic message, {bool alwaysPrint = false}) {
if (!_canLog(alwaysPrint)) return;
try {
final jsonString = jsonEncode(message);
log(jsonString);
} catch (e) {
error('Failed to log JSON: $e');
}
}