UNPKG

@bxshefby/b24jssdk

Version:

Bitrix24 REST API JavaScript SDK

51 lines (48 loc) • 1.59 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 { ConsoleHandler } from './console-handler.mjs'; import { LineFormatter } from '../formatter/line-formatter.mjs'; var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); class ConsoleV2Handler extends ConsoleHandler { static { __name(this, "ConsoleV2Handler"); } constructor(level = LogLevel.DEBUG, options) { super(level, options); this.setFormatter(new LineFormatter("[{channel}]: {message}")); } /** * @inheritDoc */ async handle(record) { const formatter = this.getFormatter(); const message = formatter.format(record); let method = this._getConsoleMethod(record.level); if (record.context["needTrace"] === true) { method = "trace"; } const context = record.context && Object.keys(record.context).length > 0 ? record.context : void 0; const extra = record.extra && Object.keys(record.extra).length > 0 ? record.extra : void 0; const params = []; if (this._useStyles && this._styles.has(record.level)) { const style = this._styles.get(record.level); params.push(style[0], style[1]); } params.push(message); params.push(context); params.push(extra); console[method]( ...params.filter(Boolean) ); return true; } } export { ConsoleV2Handler };