A multi-target logger tailored for LOKE Group and based around LOKE standards.
Currently supports console output and syslog.
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");
There are a number of options when configuring the logger;
Type: boolean
Default: false
when NODE_ENV=production
, otherwise true
Whether or not debug level logs should be emitted.
Type: boolean
Default: false
This option adds syslog udp messages to the output streams, console messages will still be emitted.
Type: boolean
Default: true
when JOURNAL_STREAM
set, otherwise false
This option prefixes stdout with systemd's severity syntax
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
.