This commit is contained in:
Evgenii Abramov
2021-05-16 02:36:56 +03:00
parent 925256fdbd
commit 0f79098f44

6
app.js
View File

@@ -4,7 +4,7 @@ const fs = require('fs');
const path = require('path'); const path = require('path');
/* */ /* */
const {createLogger, format, transports} = require('winston'); const {createLogger, format, transports} = require('winston');
const {combine, timestamp, label, printf} = format; const {combine, timestamp, printf} = format;
/* express and https */ /* express and https */
const ejs = require('ejs'); const ejs = require('ejs');
const express = require('express'); const express = require('express');
@@ -29,7 +29,7 @@ global.logger = createLogger({
format: combine( format: combine(
label(), label(),
timestamp(), timestamp(),
printf(({level, message, timestamp, label}) => { printf(({level, message, label, timestamp}) => {
return `${timestamp} [${label}] ${level}: ${message}`; return `${timestamp} [${label}] ${level}: ${message}`;
}) })
), ),
@@ -148,7 +148,7 @@ global.mqttClient = mqtt.connect(`mqtt://${config.mqtt.host}`, {
} }
}, res => { }, res => {
res.on('data', d => { res.on('data', d => {
global.logger.log('info', 'notification', {message: `${d}`}); global.logger.log('info', {message: `${d}`, label: 'notification'});
// process.stdout.write(d); // process.stdout.write(d);
}); });
}); });