mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-10 04:22:09 +10:00
* feat: revise library source names & update droplet * feat: add internal name hint to library sources * feat: update library source table with new name + icons * fix: admin invitation localisation issue * feat: #164 * feat: overhaul task UIs, #163 * fix: remove debug task * fix: lint
32 lines
617 B
TypeScript
32 lines
617 B
TypeScript
import type { TaskLog } from "~/server/internal/tasks";
|
|
|
|
const labelNumberMap = {
|
|
100: "silent",
|
|
60: "fatal",
|
|
50: "error",
|
|
40: "warn",
|
|
30: "info",
|
|
20: "debug",
|
|
10: "trace",
|
|
0: "off",
|
|
};
|
|
|
|
export function parseTaskLog(
|
|
logStr?: string | undefined,
|
|
): typeof TaskLog.infer {
|
|
if (!logStr) return { message: "", timestamp: "", level: "" };
|
|
const log = JSON.parse(logStr);
|
|
|
|
if (typeof log.level === "number") {
|
|
log.level = labelNumberMap[
|
|
log.level as keyof typeof labelNumberMap
|
|
] as string;
|
|
}
|
|
|
|
return {
|
|
message: log.msg,
|
|
timestamp: log.time,
|
|
level: log.level,
|
|
};
|
|
}
|