UNPKG

@bitrix24/b24jssdk

Version:

Bitrix24 REST API JavaScript SDK

77 lines (74 loc) 1.82 kB
/** * @package @bitrix24/b24jssdk * @version 1.0.3 * @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 { AbstractLogger } from './abstract-logger.mjs'; var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); class Logger extends AbstractLogger { static { __name(this, "Logger"); } channel; handlers = []; processors = []; constructor(channel) { super(); this.channel = channel; } // region static methods for creation //// static create(channel) { return new Logger(channel); } // endregion //// // region config //// pushHandler(handler) { this.handlers.push(handler); return this; } popHandler() { return this.handlers.pop() || null; } setHandlers(handlers) { this.handlers = handlers; return this; } pushProcessor(processor) { this.processors.push(processor); return this; } // endregion //// /** * @inheritDoc */ async log(level, message, context) { const record = { channel: this.channel, level, levelName: LogLevel[level], message, context: context ?? {}, extra: {}, timestamp: /* @__PURE__ */ new Date() }; let processedRecord = record; for (const processor of this.processors) { processedRecord = processor(processedRecord); } for (const handler of this.handlers) { if (handler.isHandling(level)) { const handled = await handler.handle(processedRecord); if (handled && !handler.shouldBubble()) { break; } } } } } export { Logger }; //# sourceMappingURL=logger.mjs.map