@loke/logger
TypeScript icon, indicating that this package has built-in type declarations

3.3.0 • Public • Published

LOKE Logger

NPM Version Build Status

A multi-target logger tailored for LOKE Group and based around LOKE standards.

Currently supports console output and syslog.

Overview

In version 3.x the api is a subset of console

it includes .debug(), .log(), .info(), .warn() and .error().

in addition is a withPrefix method that creates a logger child logger with a prefix;

const logger = require("@loke/logger").create();

logger.error("Lorem ipsum");
logger.warn("dolor sit amet consectetur");

const httpLogger = logger.withPrefix("HTTP");

httpLogger.info("eiusmod tempor incididunt ut");
httpLogger.debug("labore et dolore magna aliqua");

create() Options

There are a number of options when configuring the logger;

showDebug

Type: boolean
Default: false when NODE_ENV=production, otherwise true

Whether or not debug level logs should be emitted.

syslog

Type: boolean
Default: false

This option adds syslog udp messages to the output streams, console messages will still be emitted.

systemdPrefix

Type: boolean
Default: true when JOURNAL_STREAM set, otherwise false

This option prefixes stdout with systemd's severity syntax

metricsRegistry

Type: Object

A prom-client register to add metrics to.

const { register } = require("prom-client");
const logger = require("@loke/logger").create({
  metricsRegistry: register,
});

logger.error("Lorem ipsum");

This adds the metric log_messages_total with the labels prefix and severity.

Dependencies (2)

Dev Dependencies (12)

Package Sidebar

Install

npm i @loke/logger

Weekly Downloads

405

Version

3.3.0

License

MIT

Unpacked Size

47.9 kB

Total Files

42

Last publish

Collaborators

  • loke