-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwinston.js
34 lines (29 loc) · 854 Bytes
/
winston.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const winston = require('winston');
const expressWinston = require('express-winston');
const express = require('express');
const app = express();
const port = 3001;
//more options here - https://github.com/bithavoc/express-winston#request-logging
app.use(expressWinston.logger({
transports: [
new winston.transports.Console()
],
format: winston.format.combine(
winston.format.colorize(),
winston.format.json()
),
meta: false,
msg: "HTTP {{req.method}} {{req.url}}",
expressFormat: true,
colorize: false,
ignoreRoute: function (req, res) { return false; }
}));
app.get('/', (req, res) => {
res.send('Hello World! - Winston logged');
});
app.get('/api/test', (req, res) => {
res.json({'message': 'Hello winston!'});
});
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});