forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.ts
More file actions
31 lines (26 loc) · 682 Bytes
/
Copy pathlogger.ts
File metadata and controls
31 lines (26 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import createPinoLogger from "pino";
import pretty from "pino-pretty";
export type LogLevel = "debug" | "info" | "warn" | "error";
export type CopilotRuntimeLogger = ReturnType<typeof createLogger>;
export function createLogger(options?: {
level?: LogLevel;
component?: string;
}) {
const { level, component } = options || {};
const stream = pretty({ colorize: true });
const logger = createPinoLogger(
{
level: process.env.LOG_LEVEL || level || "error",
redact: {
paths: ["pid", "hostname"],
remove: true,
},
},
stream,
);
if (component) {
return logger.child({ component });
} else {
return logger;
}
}