UNPKG

@bxshefby/b24jssdk

Version:

Bitrix24 REST API JavaScript SDK

62 lines (59 loc) • 1.71 kB
/** * @package @bxshefby/b24jssdk * @version 3.3.0 * @copyright (c) 2026 Bitrix24 * @license MIT * @see https://github.com/bx-shef/b24-js-sdk * @see https://b24-js-sdk.bx-shef.by/ */ 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 };