swadhinbiswas feat: complete DevPulse production developer operating system for Discord · 9/6/2026
4a8d707
45 lines · 859 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { config } from "@devpulse/config";
import pino from "pino";

const redactPaths = [
  "*.token",
  "*.apiKey",
  "*.secret",
  "*.password",
  "*.authorization",
  "*.githubToken",
  "*.discordToken",
  "*.auth",
  "req.headers.authorization",
  "headers.authorization",
];

export const baseLogger = pino({
  level: config.LOG_LEVEL,
  redact: {
    paths: redactPaths,
    censor: "[REDACTED]",
  },
  timestamp: pino.stdTimeFunctions.isoTime,
  formatters: {
    level(label) {
      return { level: label };
    },
  },
});

export type Logger = pino.Logger;

export function createChildLogger(context: {
  module?: string;
  requestId?: string;
  guildId?: string;
  userId?: string;
  command?: string;
  [key: string]: unknown;
}): Logger {
  return baseLogger.child(context);
}

export const logger = createChildLogger({ module: "devpulse" });