simplified logging

This commit is contained in:
Jan Prochazka
2023-01-27 15:33:11 +01:00
parent 174d7fde5c
commit 2dd8749bc6

View File

@@ -2,19 +2,10 @@ const byline = require('byline');
const { safeJsonParse, getLogger } = require('dbgate-tools');
const logger = getLogger();
const levelNames = {
10: 'trace',
20: 'debug',
30: 'info',
40: 'warn',
50: 'error',
60: 'fatal',
};
const logDispatcher = method => data => {
const json = safeJsonParse(data.toString());
if (json && json.level && levelNames[json.level]) {
logger[levelNames[json.level]](json || data.toString());
if (json && json.level) {
logger.log(json);
} else {
logger[method](json || data.toString());
}