Skip to content

Configuration ​

Pass an options object to createLogger() to customize behavior.

javascript
const logger = require("logmoji")({
  timestamp: true,
  dateFormat: "iso",
  minLevel: "info",
  disablePrefixText: false,
  logSymbols: { success: "🚀" },
  logColors: { error: "\x1b[91m" },
});

Parameters ​

OptionTypeDefaultDescription
timestampbooleanfalsePrepends a timestamp to every log line.
dateFormat'iso' | 'locale' | 'unix''iso'Timestamp format. Only takes effect when timestamp is true.
disablePrefixTextbooleanfalseOmits the level label (e.g. Info:) from output.
logSymbolsLogSymbolssee belowOverride emoji for any log level.
logColorsLogColorssee belowOverride ANSI color code for any log level.
minLevelLogLevel(none)Suppress all log levels below this one.
levelsLogLevel[](none)Explicit allowlist — only these levels are output. Takes precedence over minLevel.

dateFormat options ​

ValueExample output
'iso'[2024-01-15T10:30:00.000Z]
'locale'[1/15/2024, 10:30:00 AM]
'unix'[1705312200000]

minLevel — log level order ​

Levels ordered from least to most severe:

silly → debug → log → info → success → warn → warning → fail → alert → error → crit

Setting minLevel: "warn" will suppress silly, debug, log, info, and success.

Default symbols ​

javascript
{
  success: "✅", fail: "📛",   warn: "🟠",  error: "ðŸšĻ",
  info:    "📄", log:  "📄",   alert: "ðŸ˜Ą", crit:  "ðŸ˜ą",
  warning: "⚠ïļ", debug: "🛠ïļ", silly: "ðŸĪŠ",
}

Default colors (ANSI codes) ​

javascript
{
  success: "\x1b[32m",  // green
  fail:    "\x1b[31m",  // red
  error:   "\x1b[31m",  // red
  warn:    "\x1b[33m",  // yellow
  warning: "\x1b[33m",  // yellow
  alert:   "\x1b[91m",  // bright red
  crit:    "\x1b[35m",  // magenta
  debug:   "\x1b[90m",  // dark gray
  silly:   "\x1b[2m",   // dim
  info:    "\x1b[0m",   // default
  log:     "\x1b[0m",   // default
}

Custom colors must be valid ANSI escape codes (e.g. "\x1b[34m"). Invalid values silently fall back to the default.

warn vs warning ​

Both warn and warning are kept for convenience. They use the same console method (console.warn) but have different default emojis (🟠 vs ⚠ïļ). In terms of minLevel priority, warning ranks one step above warn.

Disabling logs in production ​

Set the LOGMOJI_DISABLE environment variable to "true":

bash
LOGMOJI_DISABLE=true node app.js

Or in your .env file:

LOGMOJI_DISABLE=true

Released under the MIT License.