cover for 🌱 Digital Garden

Better name for Logging Levels

23 March 2021

I find logging levels quite difficult to understand and use. What’s informative? versus what is a warning?

I’ve seen this naming scheme somewhere a while ago, (ref required), I wished this was more common:

export const makeLogger = (name: string) => {
  const prefix = `[${name}]`;

  return {
    inTestEnv: (msg: string, ...args: any[]) =>
      console.debug(`${prefix}: ${msg}`, ...args),
    inProdEnv: (msg: string, ...args: any[]) =>`${prefix}: ${msg}`, ...args),
    toInvestigateTomorrow: (msg: string, ...args: any[]) =>
      console.warn(`${prefix}: ${msg}`, ...args),
    wakeMeUpInTheMiddleOfTheNight: (msg: string, ...args: any[]) =>
      console.error(`${prefix}: ${msg}`, ...args),
    makeLogger: (subName: string) => makeLogger(`${name}.${subName}`),

Laurent Senta

I wrote software for large distributed systems, web applications, and even robots. These days I focus on making developers, creators, and humans more productive through