diff --git a/public/locales/en/diagnostics.json b/public/locales/en/diagnostics.json index 6d1d289d9..1f22aec9a 100644 --- a/public/locales/en/diagnostics.json +++ b/public/locales/en/diagnostics.json @@ -47,7 +47,10 @@ "autocomplete": { "globalLevel": "Global level", "subsystem": "Subsystem", - "level": "Log level" + "level": "Log level", + "invalidSubsystem": "Subsystem \"{subsystem}\" is not valid. Valid subsystems: {subsystems}", + "invalidLevel": "\"{level}\" is not a valid log level. Valid levels: debug, info, warn, error, dpanic, panic, fatal", + "invalidInput": "Input cannot be empty" }, "warnings": { "potentialIssues": "Potential Issues:", diff --git a/src/contexts/logs/api.ts b/src/contexts/logs/api.ts index ebcdec626..55368cb12 100644 --- a/src/contexts/logs/api.ts +++ b/src/contexts/logs/api.ts @@ -24,6 +24,10 @@ interface RawLogEntry { * The message of the log */ msg: string + /** + * Allow any additional structured fields + */ + [key: string]: any } /** @@ -119,11 +123,14 @@ export async function fetchLogSubsystems (ipfs: KuboRPCClient, signal?: AbortSig * Parse raw log entry into structured LogEntry */ export function parseLogEntry (raw: unknown): LogEntry { - const obj = raw as RawLogEntry + const { ts, level, logger, caller, msg, ...attributes } = raw as RawLogEntry + return { - timestamp: obj.ts, - level: obj.level, - subsystem: obj.logger, - message: obj.msg + timestamp: ts, + level, + subsystem: logger, + message: Object.keys(attributes).length > 0 + ? `${msg} ${JSON.stringify(attributes)}` + : msg } }