Skip to content

Source

Package Location

  • Directorymodules
    • Directoryutility
      • Directorytrace
        • index.ts

Source Code

// TODO: Replace this with your condition
const LOGGER_ENABLED = process.env["LOGGER_ENABLED"] === "true"
type Tracer = (
message: string,
args?: {
[key: string]: any
},
) => void
type LogLevel = "debug" | "info" | "warn" | "error"
export type Logger = Record<LogLevel, Tracer>
/**
* A logging abstraction to use instead of `console`. At the moment it will
* always use `console.log`, but in the future you may want to use a more robust
* logging solution. For example; Axiom, Better Stack Logs, etc.
*/
export const trace: Logger = {
debug: LOGGER_ENABLED ? console.debug : console.debug,
info: LOGGER_ENABLED ? console.log : console.log,
warn: LOGGER_ENABLED ? console.warn : console.warn,
error: LOGGER_ENABLED ? console.error : console.error,
}