From d77090d04adf977fac19c1771d4b73df00a87440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20Da=C3=9Fler?= Date: Fri, 29 Aug 2025 15:01:40 +0200 Subject: [PATCH] Add logger dependency and replace console logging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Import LoggerComponent from ior:gitea:gitea.metatrom.net:universal-components/logger@1.0.0 - Replace console.warn and console.info with appropriate logger methods - Use warn level for fallback scenarios when native implementations fail - Use info level for polyfill installation notifications 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- TextEncodingFactory.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/TextEncodingFactory.ts b/TextEncodingFactory.ts index f21aa0b..888b8f9 100644 --- a/TextEncodingFactory.ts +++ b/TextEncodingFactory.ts @@ -6,6 +6,7 @@ * @module text-encoding@1.0.0 */ +import { LoggerComponent } from 'ior:gitea:gitea.metatrom.net:universal-components/logger@1.0.0'; import { TextDecoderPolyfill } from './TextDecoderPolyfill'; import { TextEncoderPolyfill } from './TextEncoderPolyfill'; import type { @@ -17,6 +18,7 @@ import type { export class TextEncodingFactory implements ITextEncodingFactory { private static instance: TextEncodingFactory; + private static logger = new LoggerComponent('TextEncodingFactory'); /** * Get factory singleton instance @@ -40,7 +42,7 @@ export class TextEncodingFactory implements ITextEncodingFactory { return new TextEncoder(); } catch (e) { // Fall back to polyfill if native fails - console.warn('[TextEncodingFactory] Native TextEncoder failed, using polyfill:', e); + TextEncodingFactory.logger.warn('Native TextEncoder failed, using polyfill:', e); } } @@ -59,7 +61,7 @@ export class TextEncodingFactory implements ITextEncodingFactory { return new TextDecoder(label, options); } catch (e) { // Fall back to polyfill if native fails - console.warn('[TextEncodingFactory] Native TextDecoder failed, using polyfill:', e); + TextEncodingFactory.logger.warn('Native TextDecoder failed, using polyfill:', e); } } @@ -113,20 +115,22 @@ export function createTextDecoder(label?: string, options?: TextDecoderOptions): * This makes TextEncoder/TextDecoder available everywhere */ export function installTextEncodingPolyfills(): void { + const logger = new LoggerComponent('TextEncodingPolyfills'); + // @ts-expect-error if (typeof global !== 'undefined') { // @ts-expect-error if (typeof global.TextEncoder === 'undefined') { // @ts-expect-error global.TextEncoder = TextEncoderPolyfill; - console.info('[TextEncodingFactory] Installed TextEncoder polyfill globally'); + logger.info('Installed TextEncoder polyfill globally'); } // @ts-expect-error if (typeof global.TextDecoder === 'undefined') { // @ts-expect-error global.TextDecoder = TextDecoderPolyfill; - console.info('[TextEncodingFactory] Installed TextDecoder polyfill globally'); + logger.info('Installed TextDecoder polyfill globally'); } } } \ No newline at end of file