eslint, prettier fix

This commit is contained in:
Данил 2024-08-17 16:40:20 +03:00
parent bdc4450b72
commit 2679fa20d5
10 changed files with 284 additions and 208 deletions

View file

@ -11,37 +11,46 @@ function getCallerFile() {
const err = new Error();
let currentFile;
Error.prepareStackTrace = function (err, stack) { return stack; };
Error.prepareStackTrace = function (err, stack) {
return stack;
};
currentFile = err.stack.shift().getFileName();
while (err.stack.length) {
callerFile = err.stack.shift().getFileName();
if (currentFile !== callerFile) break;
}
} catch { return; }
} catch {
return;
}
Error.prepareStackTrace = originalFunc;
return callerFile ? path.basename(callerFile) : 'unknown';
}
const logger = pino({
level: config['server']['log']['level'] ? config['server']['log']['level'] : 'info',
prettifier: pretty,
prettify: true,
messageKey: 'msg',
timestampKey: 'time',
}, pretty({
ignore: 'pid,hostname',
messageFormat: '{msg}',
}));
const logger = pino(
{
level: config['server']['log']['level']
? config['server']['log']['level']
: 'info',
prettifier: pretty,
prettify: true,
messageKey: 'msg',
timestampKey: 'time',
},
pretty({
ignore: 'pid,hostname',
messageFormat: '{msg}',
}),
);
function wrapLogger(logger) {
const levels = ['fatal', 'error', 'warn', 'info', 'debug', 'trace'];
const wrappedLogger = {};
levels.forEach(level => {
levels.forEach((level) => {
wrappedLogger[level] = function (msg, ...args) {
const callerFile = getCallerFile();
const msgWithFilename = `[${callerFile}] ${msg}`;