@egomobile/winston-log
v0.3.0
Published
Extension for winston logger.
Downloads
7
Readme
@egomobile/winston-log
Install
Execute the following command from your project folder, where your package.json
file is stored:
npm install --save @egomobile/winston-log
The following modules are defined in peerDependencies and have to be installed manually:
Usage
import log, { useWinstonLogger, winston } from "@egomobile/winston-log";
const { createLogger, format, transports } = winston;
// create the base logger, based on winston
const myWinstonLogger = createLogger({
level: process.env.NODE_ENV === "development" ? "debug" : "info",
format: format.combine(
format.timestamp({
format: "YYYY-MM-DD HH:mm:ss",
}),
format.errors({ stack: true }),
format.splat(),
format.json()
),
transports: [],
});
// console output
myWinstonLogger.add(
new transports.Console({
format: format.combine(format.colorize(), format.simple()),
})
);
// reset, before we continue
log.reset();
// add middleware
log.use(useWinstonLogger(myWinstonLogger));
log("foo"); // default: debug
log.debug("foo"); // debug
log.error("foo"); // error
log.warn("foo"); // warning
log.info("foo"); // information
log.trace("foo"); // trace
Documentation
The API documentation can be found here.