UNPKG

cn-shell

Version:
128 lines (127 loc) 3.77 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? function (o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if ( !desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable) ) { desc = { enumerable: true, get: function () { return m[k]; }, }; } Object.defineProperty(o, k2, desc); } : function (o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; }); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? function (o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); } : function (o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.LoggerConsole = void 0; const logger_js_1 = require("./logger.js"); const util = __importStar(require("node:util")); class LoggerConsole extends logger_js_1.Logger { constructor(name, logTimestamps, timestampFormat) { super(name, logTimestamps, timestampFormat); } fatal(appOrExtName, ...args) { if (this._level > logger_js_1.LogLevel.LOG_COMPLETE_SILENCE) { let msg = util.format( `${this.timestamp()}FATAL: ${this._name}: ${appOrExtName}: ${args[0]}`, ...args.slice(1), ); console.error(msg); } } error(appOrExtName, ...args) { if (this._level > logger_js_1.LogLevel.LOG_COMPLETE_SILENCE) { let msg = util.format( `${this.timestamp()}ERROR: ${this._name}: ${appOrExtName}: ${args[0]}`, ...args.slice(1), ); console.error(msg); } } warn(appOrExtName, ...args) { if (this._level > logger_js_1.LogLevel.LOG_COMPLETE_SILENCE) { let msg = util.format( `${this.timestamp()}WARN: ${this._name}: ${appOrExtName}: ${args[0]}`, ...args.slice(1), ); console.warn(msg); } } info(appOrExtName, ...args) { if (this._level >= logger_js_1.LogLevel.LOG_INFO) { let msg = util.format( `${this.timestamp()}INFO: ${this._name}: ${appOrExtName}: ${args[0]}`, ...args.slice(1), ); console.info(msg); } } startup(appOrExtName, ...args) { if (this._level >= logger_js_1.LogLevel.LOG_START_UP) { let msg = util.format( `${this.timestamp()}STARTUP: ${this._name}: ${appOrExtName}: ${ args[0] }`, ...args.slice(1), ); console.info(msg); } } debug(appOrExtName, ...args) { if (this._level >= logger_js_1.LogLevel.LOG_DEBUG) { let msg = util.format( `${this.timestamp()}DEBUG: ${this._name}: ${appOrExtName}: ${args[0]}`, ...args.slice(1), ); console.info(msg); } } trace(appOrExtName, ...args) { if (this._level >= logger_js_1.LogLevel.LOG_TRACE) { let msg = util.format( `${this.timestamp()}TRACE: ${this._name}: ${appOrExtName}: ${args[0]}`, ...args.slice(1), ); console.info(msg); } } force(appOrExtName, ...args) { let msg = util.format( `${this.timestamp()}FORCED: ${this._name}: ${appOrExtName}: ${args[0]}`, ...args.slice(1), ); console.error(msg); } } exports.LoggerConsole = LoggerConsole;