cb-winston-loki-logger
v1.3.9
Published
A logger service that sends server's logs to Grafana Loki
Downloads
20
Maintainers
Readme
Description
This is a simple logger which sends logs using Winston and Morgan to Grafana Loki.
Installation
npm i cb-winston-loki-logger
Usage
Insert the unique label of the logged app and the HTTP address where Loki is hosted. Default address of Loki on localhost is http://localhost:3100.
const lokiAddress = "http://localhost:3100";
const label = "app_test1";
const WinstonLokiLogger = require('cb-winston-loki-logger');
const LoggerClass = new WinstonLokiLogger();
const logger = LoggerClass.createLogger(label, lokiAddress);
Available functions of this logger: info(), warn(), and error(). Additional parameters can be added for function error() and warn() like objects or arrays.
logger.info("Server is running on localhost:8080");
logger.warn("This function is deprecated");
logger.error("Internal server error", args);
Test
npm i
npm test