|
| 1 | +const express = require('express'); |
| 2 | +require('dotenv').config(); |
| 3 | + |
| 4 | +const winstonLogger = require('./logger').winstonLogger; |
| 5 | +const log = winstonLogger.info; |
| 6 | + |
| 7 | +const app = express(); |
| 8 | +const port = 8081; |
| 9 | + |
| 10 | +app.get('/', (req, res) => { |
| 11 | + const var1 = 'var1Value'; |
| 12 | + const f = () => { |
| 13 | + console.log('a'); |
| 14 | + }; |
| 15 | + |
| 16 | + const o = { |
| 17 | + prop: 'someValue' |
| 18 | + }; |
| 19 | + |
| 20 | + |
| 21 | + // simple |
| 22 | + log('simple text'); |
| 23 | + log('ERROR', 'this is a log'); |
| 24 | + |
| 25 | + // interpolation |
| 26 | + winstonLogger.info(`Interpolation at ${Date.now()}. The dot should not be present`); |
| 27 | + winstonLogger.info(`Multiple lines ${Date.now()} |
| 28 | + with interpolation`); |
| 29 | + winstonLogger.info(`nested interpolation ${`this is a valid string ${Date.now()}`}`); |
| 30 | + winstonLogger.info(`nested interpolation ${`string${Date.now()} should disappear`} somehow`); |
| 31 | + |
| 32 | + // concatenation |
| 33 | + winstonLogger.info(`hello world` + 1 + 1); |
| 34 | + winstonLogger.info(1 + 1 + `hello world`); |
| 35 | + winstonLogger.info(2 * (3 + 5) + `hello world`); |
| 36 | + |
| 37 | + // comments |
| 38 | + winstonLogger.info(var1 + /* comment */ 'hello world' + ' something else'); |
| 39 | + |
| 40 | + // functions |
| 41 | + winstonLogger.info(f('a', 'b') + ' some text'); |
| 42 | + winstonLogger.info(f('a', 'b') + 'some text'); |
| 43 | + |
| 44 | + // other cases |
| 45 | + winstonLogger.info(o['prop'] + ' no value'); |
| 46 | + winstonLogger.info(o['prop']['nestedProp'] + ' no value'); |
| 47 | + winstonLogger.info(['1', '2', '3'] + ' something particular 2'); |
| 48 | + |
| 49 | + res.send('Hello World!'); |
| 50 | +}); |
| 51 | + |
| 52 | +app.listen(port, () => { |
| 53 | + console.log(`Example app listening on port ${port}`) |
| 54 | +}); |
0 commit comments