UNPKG

jsout

Version:

A Syslog-compatible, small, and simple logger for Typescript/Javascript projects. Sponsored by https://aeroview.io

28 lines 1.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.formatCli = formatCli; const colorizeLevel_1 = require("../colorizeLevel"); const formatSerializedError_1 = require("./formatSerializedError"); const portableInspect_1 = require("../lib/portableInspect"); const colors_1 = require("../lib/colors"); function formatCli(log) { const { bold, white } = (0, colors_1.getColorFunctions)(); const insp = (obj) => (0, portableInspect_1.portableInspect)(obj, { colors: true, depth: null }); const level = `${bold(white('Level'))}: ${(0, colorizeLevel_1.colorizeLevel)(log.level)}\n`; const message = `${bold(white(`Message: ${log.message}`))}\n`; const error = cliFormatError(log.error); const data = log.data ? `${insp(log.data)}\n` : ''; return `\n${level}${message}${error}${data}`; } function cliFormatError(error) { const { bold } = (0, colors_1.getColorFunctions)(); if (!error) return ''; if ((0, formatSerializedError_1.isSerializedError)(error)) { return `${(0, formatSerializedError_1.formatSerializedError)(error)}\n`; } else { return `${bold('Error')}: ${(0, portableInspect_1.portableInspect)(error, { colors: true, depth: null })}\n`; } } //# sourceMappingURL=cli.js.map