Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion public/locales/en/diagnostics.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:",
Expand Down
17 changes: 12 additions & 5 deletions src/contexts/logs/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ interface RawLogEntry {
* The message of the log
*/
msg: string
/**
* Allow any additional structured fields
*/
[key: string]: any
}

/**
Expand Down Expand Up @@ -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
}
}