UNPKG

@bitrix24/b24jssdk

Version:

Bitrix24 REST API JavaScript SDK

63 lines (60 loc) 1.76 kB
/** * @package @bitrix24/b24jssdk * @version 1.1.0 * @copyright (c) 2026 Bitrix24 * @license MIT * @see https://github.com/bitrix24/b24jssdk * @see https://bitrix24.github.io/b24jssdk/ */ import { LogLevel } from '../../types/logger.mjs'; import { AbstractHandler } from './abstract-handler.mjs'; var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); class ConsolaAdapter extends AbstractHandler { static { __name(this, "ConsolaAdapter"); } consolaInstance; constructor(level = LogLevel.DEBUG, options) { const opts = { bubble: true, ...options }; super(level, opts.bubble); this.consolaInstance = opts.consolaInstance; } setFormatter(_formatter) { } getFormatter() { return null; } async handle(record) { const message = `[${record.channel}] ${record.levelName}: ${record.message}`; const args = { ...record.context, ...record.extra, timestamp: record.timestamp }; switch (record.level) { case LogLevel.DEBUG: this.consolaInstance.log(message, args); break; case LogLevel.INFO: this.consolaInstance.info(message, args); break; case LogLevel.NOTICE: this.consolaInstance.success(message, args); break; case LogLevel.WARNING: this.consolaInstance.warn(message, args); break; case LogLevel.ERROR: case LogLevel.CRITICAL: case LogLevel.ALERT: case LogLevel.EMERGENCY: this.consolaInstance.error(message, args); break; default: this.consolaInstance.log(message, args); } return true; } } export { ConsolaAdapter }; //# sourceMappingURL=consola-adapter.mjs.map