UNPKG

@toreda/log

Version:

Lightweight TypeScript logger with flexible custom transports.

35 lines (34 loc) 1.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.logToConsole = void 0; const levels_1 = require("./levels"); /** * Action intended for development and debugging where console * logs may be needed. * @param msg */ function logToConsole(msg) { const path = msg.path.join('.'); switch (msg.level) { case levels_1.Levels.ERROR: console.error(`[ERROR][${path}]`, ...msg.message); break; case levels_1.Levels.WARN: console.warn(`[WARN][${path}]`, ...msg.message); break; case levels_1.Levels.INFO: console.info(`[INFO][${path}]`, ...msg.message); break; case levels_1.Levels.DEBUG: console.debug(`[DEBUG][${path}]`, ...msg.message); break; case levels_1.Levels.TRACE: console.trace(`[TRACE][${path}]`, ...msg.message); break; default: console.log(`[${path}][${msg.level}]`, ...msg.message); break; } return true; } exports.logToConsole = logToConsole;