@mategyf/express-logger
v1.1.0
Published
Logger for ExpressJS using winston
Downloads
1
Readme
@mategyf/express-logger
Simple wrapper for winston and morgan for use in Express webapps.
Installation
If you use npm
:
npm install @mategyf/express-logger
Or if you use yarn
:
yarn add @mategyf/express-logger
Usage
This package supports two levels of logging: logger.info()
and logger.error()
. Both are called with a message string.
For logging http calls, use logger.middleware()
as an Express middleware.
import express from 'express';
import logger from '@mategyf/express-logger';
const app = express();
app.use(logger.middleware());
const PORT = 4000;
app.get('/', (req, res) => {
res.send('Hello world!');
});
app.listen(PORT, () => {
logger.info(`App is listening on ${PORT}.`);
});
import logger from '@mategyf/express-logger';
export default function doSomething() {
logger.error('Something was done!');
}