A NodeJS logger instrumentation library for Strigo applications.
This is a light abstraction over a common logger. It provides a way to setup the logger for various applications, defaults as to where to direct logs in different cases, and a way to determine context for entries in a generic way.
The logger is built around the winston logger, and express-winston when used as middleware for Express.js.
Make sure to go over the winston
& express-winston
docs to know the API of the logger.
For Express.js specifically, make sure to read this about binding order of the error logging middleware.
Add "@strigo/node-logger": "strigo/strigo-node-logger.git#TAG"
to your package.json
.
import { setupNodeLogger } from '@strigo/node-logger';
const log = setupNodeLogger({ json = true, level = 'info' });
log.info(...);
log.level = 'debug';
log.debug(...);
// And so on...
import { setupExpressLogger } from '@strigo/node-logger';
const { log, loggerMiddleware, errorLoggerMiddleware } = setupExpressLogger({});
app.use(loggerMiddleware);
// read docs about error logger
app.use(errorLoggerMiddleware);
log.info(...);
// And so on...
Check examples for more info.