UNPKG

traceability

Version:

Traceability tools - middleware and winston logger

34 lines 1.38 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var express_1 = __importDefault(require("express")); var index_1 = require("../index"); var colors = { info: 'green', warn: 'yellow', error: 'red', }; var colorizer = index_1.format.colorize(); index_1.addColors(colors); var conf = index_1.LoggerTraceability.getLoggerOptions(); var formated = index_1.format.combine(index_1.format.timestamp(), index_1.format.simple(), index_1.format.printf(function (msg) { return colorizer.colorize(msg.level, msg.timestamp + " - " + msg.level + ":") + " " + msg.message; })); conf.format = formated; index_1.LoggerTraceability.configure(conf); var app = express_1.default(); var port = 3000; // ContextAsyncHooks.trackKey = ETrackKey['X-Correlation-ID']; app.use(index_1.ContextAsyncHooks.getExpressMiddlewareTracking()); app.get('/', function (req, res) { res.send('Hello World!'); }); app.listen(port, function () { // Logger.info(`Example app listening at http://localhost:${port}`); index_1.Logger.info('This is the logger info!'); index_1.Logger.error('This is the logger error!'); index_1.Logger.warn('This is the logger warn!'); }); //# sourceMappingURL=express-with-config.js.map