mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 13:13:58 +00:00
simplified logging
This commit is contained in:
@@ -2,19 +2,10 @@ const byline = require('byline');
|
|||||||
const { safeJsonParse, getLogger } = require('dbgate-tools');
|
const { safeJsonParse, getLogger } = require('dbgate-tools');
|
||||||
const logger = getLogger();
|
const logger = getLogger();
|
||||||
|
|
||||||
const levelNames = {
|
|
||||||
10: 'trace',
|
|
||||||
20: 'debug',
|
|
||||||
30: 'info',
|
|
||||||
40: 'warn',
|
|
||||||
50: 'error',
|
|
||||||
60: 'fatal',
|
|
||||||
};
|
|
||||||
|
|
||||||
const logDispatcher = method => data => {
|
const logDispatcher = method => data => {
|
||||||
const json = safeJsonParse(data.toString());
|
const json = safeJsonParse(data.toString());
|
||||||
if (json && json.level && levelNames[json.level]) {
|
if (json && json.level) {
|
||||||
logger[levelNames[json.level]](json || data.toString());
|
logger.log(json);
|
||||||
} else {
|
} else {
|
||||||
logger[method](json || data.toString());
|
logger[method](json || data.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user