Better Logging
  • Introduction
  • Setup
    • Install
    • Log Levels
  • Configuration
    • format
    • formatStamp
    • saveToFile
    • logLevels
    • color
    • messageConstructionStrategy
  • extra
    • Decorate Arbitrary Object
    • Custom Instance
    • Express Middleware
    • Typescript Support
  • Upgrade Guides
    • 4.x to 5.x
    • 3.x to 4.x
Powered by GitBook
On this page

Was this helpful?

  1. Configuration

color

It's finally time for the most important option of them all... colors!

const chalk = require('chalk');
require('better-logging')(console, {
    color: {
      base: chalk.greenBright,
      type: {
        debug: chalk.magentaBright,
        info: chalk.magentaBright,
        log: chalk.magentaBright,
        error: chalk.blue,
        warn: chalk.blue,
      }
    },
});
// The type color decides the color of the word inside the "ctx.type" stamp.
// By default the text "info" in this stamp, [info], is white, but now it can be any color you want (or that your terminal supports) :)

There are also some predefined color themes that you can use if you don't want to write your own.

const { Theme } = betterLogging;
betterLogging(console, {
  color: Theme.dark
});

// Theme.dark // default
// Theme.light
// Theme.green
// Theme.noColor // removes all color from messages
PreviouslogLevelsNextmessageConstructionStrategy

Last updated 3 years ago

Was this helpful?