lib/logger.ts

oh-my-prompt · src/lib/logger.ts · typescript · MIT
infra, tag:knn-classified

Exports a pino logger configured for production or development environments.

// Source: https://github.com/jiunbae/oh-my-prompt | License: MIT | Copyright 2026 Jiun Bae
// Provided via justclaw.it.com; keep this notice with the code.
import pino from "pino";

const isProduction = process.env.NODE_ENV === "production";

export const logger = pino({
  level: process.env.LOG_LEVEL || "info",
  transport: !isProduction
    ? {
        target: "pino-pretty",
        options: {
          colorize: true,
          ignore: "pid,hostname",
          translateTime: "HH:MM:ss Z",
        },
      }
    : undefined,
});

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key