toJson method

Map<String, dynamic> toJson()

Serializes the entry to JSON-compatible map.

Includes all fields. Context is shallow-copied.

Implementation

Map<String, dynamic> toJson() {
  return {
    "level": level.name,
    "code": level.code,
    "timestamp": timestamp.toIso8601String(),
    "message": message,
    "context": {...context},
    if (metadata != null) "metadata": metadata,
  };
}