mirror of
https://github.com/YuzuZensai/Minikura.git
synced 2026-09-13 18:59:25 +00:00
✨ feat: topology, and improves handling
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import pino from "pino";
|
||||
|
||||
export function createLogger(component: string): pino.Logger;
|
||||
export function createLogger(
|
||||
context: Record<string, string | number>,
|
||||
): pino.Logger;
|
||||
export function createLogger(
|
||||
componentOrContext: string | Record<string, string | number>,
|
||||
): pino.Logger {
|
||||
const isString = typeof componentOrContext === "string";
|
||||
const baseContext = isString
|
||||
? { component: componentOrContext }
|
||||
: componentOrContext;
|
||||
|
||||
return pino({
|
||||
level: process.env.LOG_LEVEL || "info",
|
||||
transport:
|
||||
process.env.NODE_ENV !== "production"
|
||||
? {
|
||||
target: "pino-pretty",
|
||||
options: {
|
||||
colorize: true,
|
||||
translateTime: "HH:MM:ss.l",
|
||||
ignore: "pid,hostname",
|
||||
singleLine: false,
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
base: baseContext,
|
||||
});
|
||||
}
|
||||
|
||||
export const logger = createLogger("shared");
|
||||
Reference in New Issue
Block a user