import config from "config"; import { v4 as uuid } from "uuid"; import Log from "./models/Log"; const LOG_LEVEL = config.get('log_level'); const DB_LOG_LEVEL = config.get('db_log_level'); export default class Logger { static silentError(error, ...message) { return this.log('ERROR', message, error, true) || ''; } static error(error, ...message) { return this.log('ERROR', message, error) || ''; } static warn(...message) { this.log('WARN', message); } static info(...message) { this.log('INFO', message); } static debug(...message) { this.log('DEBUG', message); } static dev(...message) { this.log('DEV', message); } static log(level, message, error, silent = false) { const levelIndex = LogLevel[level]; if (levelIndex <= LogLevel[LOG_LEVEL]) { if (error) { if (levelIndex > LogLevel.ERROR) this.warn(`Wrong log level ${level} with attached error.`); } else { if (levelIndex <= LogLevel.ERROR) this.warn(`No error attached with log level ${level}.`); } const computedMsg = message.map(v => { if (typeof v === 'string') { return v; } else { return JSON.stringify(v, (key, value) => { if (value instanceof Object) { if (value.type === 'Buffer') { return `Buffer<${Buffer.from(value.data).toString('hex')}>`; } else if (value !== v) { return `[object Object]`; } } if (typeof value === 'string' && value.length > 96) { return value.substr(0, 96) + '...'; } return value; }, 4); } }).join(' '); const log = new Log({}); log.setLevel(level); log.message = computedMsg; log.setError(error); let logID = Buffer.alloc(16); uuid({}, logID); log.setLogID(logID); let output = `[${level}] `; let pad = output.length; if (levelIndex <= LogLevel[DB_LOG_LEVEL]) output += `${log.getLogID()} - `; output += computedMsg.replace(/\n/g, '\n' + ' '.repeat(pad)); switch (level) { case "ERROR": if (silent || !error) { console.error(output); } else { console.error(output, error); } break; case "WARN": console.warn(output); break; case "INFO": console.info(output); break; case "DEBUG": case "DEV": console.debug(output); break; } if (levelIndex <= LogLevel[DB_LOG_LEVEL]) { log.save().catch(err => { if (!silent && err.message.indexOf('ECONNREFUSED') < 0) { console.error({ save_err: err, error }); } }); } return log.getLogID(); } return null; } constructor() { } } export var LogLevel; (function (LogLevel) { LogLevel[LogLevel["ERROR"] = 0] = "ERROR"; LogLevel[LogLevel["WARN"] = 1] = "WARN"; LogLevel[LogLevel["INFO"] = 2] = "IN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IHNpbGVudDogYm9vbGVhbiA9IGZhbHNlKTogc3RyaW5nIHwgbnVsbCB7XG4gICAgICAgIGNvbnN0IGxldmVsSW5kZXggPSBMb2dMZXZlbFtsZXZlbF07XG4gICAgICAgIGlmIChsZXZlbEluZGV4IDw9IExvZ0xldmVsW0xPR19MRVZFTF0pIHtcbiAgICAgICAgICAgIGlmIChlcnJvcikge1xuICAgICAgICAgICAgICAgIGlmIChsZXZlbEluZGV4ID4gTG9nTGV2ZWwuRVJST1IpIHRoaXMud2FybihgV3JvbmcgbG9nIGxldmVsICR7bGV2ZWx9IHdpdGggYXR0YWNoZWQgZXJyb3IuYCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmIChsZXZlbEluZGV4IDw9IExvZ0xldmVsLkVSUk9SKSB0aGlzLndhcm4oYE5vIGVycm9yIGF0dGFjaGVkIHdpdGggbG9nIGxldmVsICR7bGV2ZWx9LmApO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBjb25zdCBjb21wdXRlZE1zZyA9IG1lc3NhZ2UubWFwKHYgPT4ge1xuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgdiA9PT0gJ3N0cmluZycpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHY7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHYsIChrZXk6IHN0cmluZywgdmFsdWU6IGFueSkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlIGluc3RhbmNlb2YgT2JqZWN0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHZhbHVlLnR5cGUgPT09ICdCdWZmZXInKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBgQnVmZmVyPCR7QnVmZmVyLmZyb20odmFsdWUuZGF0YSkudG9TdHJpbmcoJ2hleCcpfT5gO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAodmFsdWUgIT09IHYpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGBbb2JqZWN0IE9iamVjdF1gO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgPT09ICdzdHJpbmcnICYmIHZhbHVlLmxlbmd0aCA+IDk2KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlLnN1YnN0cigwLCA5NikgKyAnLi4uJztcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB2YWx1ZTtcbiAgICAgICAgICAgICAgICAgICAgfSwgNCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSkuam9pbignICcpO1xuXG4gICAgICAgICAgICBjb25zdCBsb2cgPSBuZXcgTG9nKHt9KTtcbiAgICAgICAgICAgIGxvZy5zZXRMZXZlbChsZXZlbCk7XG4gICAgICAgICAgICBsb2cubWVzc2FnZSA9IGNvbXB1dGVkTXNnO1xuICAgICAgICAgICAgbG9nLnNldEVycm9yKGVycm9yKTtcblxuICAgICAgICAgICAgbGV0IGxvZ0lEID0gQnVmZmVyLmFsbG9jKDE2KTtcbiAgICAgICAgICAgIHV1aWQoe30sIGxvZ0lEKTtcbiAgICAgICAgICAgIGxvZy5zZXRMb2dJRChsb2dJRCk7XG5cblxuICAgICAgICAgICAgbGV0IG91dHB1dCA9IGBbJHtsZXZlbH1dIGA7XG4gICAgICAgICAgICBsZXQgcGFkID0gb3V0cHV0Lmxlbmd0aDtcbiAgICAgICAgICAgIGlmIChsZXZlbEluZGV4IDw9IExvZ0xldmVsW0RCX0xPR19MRVZFTF0pIG91dHB1dCArPSBgJHtsb2cuZ2V0TG9nSUQoKX0gLSBgO1xuICAgICAgICAgICAgb3V0cHV0ICs9IGNvbXB1dGVkTXNnLnJlcGxhY2UoL1xcbi9nLCAnXFxuJyArICcgJy5yZXBlYXQocGFkKSk7XG5cbiAgICAgICAgICAgIHN3aXRjaCAobGV2ZWwpIHtcbiAgICAgICAgICAgICAgICBjYXNlIFwiRVJST1JcIjpcbiAgICAgICAgICAgICAgICAgICAgaWYgKHNpbGVudCB8fCAhZXJyb3IpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3Iob3V0cHV0KTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUuZXJyb3Iob3V0cHV0LCBlcnJvcik7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgY2FzZSBcIldBUk5cIjpcbiAgICAgICAgICAgICAgICAgICAgY29uc29sZS53YXJuKG91dHB1dCk7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIGNhc2UgXCJJTkZPXCI6XG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUuaW5mbyhvdXRwdXQpO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICBjYXNlIFwiREVCVUdcIjpcbiAgICAgICAgICAgICAgICBjYXNlIFwiREVWXCI6XG4gICAgICAgICAgICAgICAgICAgIGNvbnNvbGUuZGVidWcob3V0cHV0KTtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChsZXZlbEluZGV4IDw9IExvZ0xldmVsW0RCX0xPR19MRVZFTF0pIHtcbiAgICAgICAgICAgICAgICBsb2cuc2F2ZSgpLmNhdGNoKGVyciA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGlmICghc2lsZW50ICYmIGVyci5tZXNzYWdlLmluZGV4T2YoJ0VDT05OUkVGVVNFRCcpIDwgMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5lcnJvcih7c2F2ZV9lcnI6IGVyciwgZXJyb3J9KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGxvZy5nZXRMb2dJRCgpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBudWxsO1xuICAgIH1cblxuICAgIHByaXZhdGUgY29uc3RydWN0b3IoKSB7XG4gICAgfVxufVxuXG5leHBvcnQgZW51bSBMb2dMZXZlbCB7XG4gICAgRVJST1IsXG4gICAgV0FSTixcbiAgICBJTkZPLFxuICAgIERFQlVHLFxuICAgIERFVixcbn1cblxuZXhwb3J0IHR5cGUgTG9nTGV2ZWxLZXlzID0ga2V5b2YgdHlwZW9mIExvZ0xldmVsO1xuIl19