json static method
📜 Logs a JSON-level message (Logs structured JSON data)
Example Usage:
Log.json({"status": "ok", "message": "Request successful"}, fileName: "api_service.dart");
Log.json({"user": "John Doe", "email": "john@example.com"}, fileName: "user_manager.dart");
Log.json({"action": "login_attempt", "result": "failed"}, fileName: "auth_service.dart");
Log.json({"settings": {"theme": "dark", "notifications": true}}, fileName: "settings_manager.dart");
Log.json({"lat": 37.7749, "long": -122.4194}, fileName: "gps_tracker.dart");
Implementation
static void json(dynamic jsonData, {required String fileName}) {
final formattedJson = jsonData
.toString()
.replaceAll(',', ',\n')
.replaceAll('{', '{\n')
.replaceAll('}', '\n}');
log("🍸\n$formattedJson", fileName: fileName, level: LogLevel.json);
}