From a51d7d23e9f7760c4d68685375cc8010456128fc Mon Sep 17 00:00:00 2001 From: Ali Mihandoost Date: Tue, 24 Oct 2023 01:46:19 +0330 Subject: [PATCH] fix(fetch): compatible with new logger api --- packages/fetch/src/fetch.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/fetch/src/fetch.ts b/packages/fetch/src/fetch.ts index 1edaa30..b333830 100644 --- a/packages/fetch/src/fetch.ts +++ b/packages/fetch/src/fetch.ts @@ -1,4 +1,4 @@ -import {createLogger, globalAlwatr, NODE_MODE} from '@alwatr/logger'; +import {createLogger, definePackage, NODE_MODE} from '@alwatr/logger'; import {getClientId, delay} from '@alwatr/util'; import type {FetchOptions} from './type.js'; @@ -8,10 +8,8 @@ export type * from './type.js'; const logger = createLogger('alwatr/fetch'); -globalAlwatr.registeredList.push({ - name: '@alwatr/fetch', - version: _ALWATR_VERSION_, -}); +definePackage('fetch', '2.x'); + let alwatrCacheStorage: Cache; const cacheSupported = 'caches' in globalThis; @@ -67,11 +65,11 @@ export async function serviceRequest { options.headers ??= {}; if (options.cacheStrategy !== 'network_only' && cacheSupported !== true) { - logger.incident?.('fetch', 'fetch_cache_strategy_ignore', 'Cache storage not support in this browser', { + logger.incident?.('fetch', 'fetch_cache_strategy_unsupported', { cacheSupported, }); options.cacheStrategy = 'network_only'; @@ -196,7 +194,6 @@ async function _handleCacheStrategy(options: Required): Promise): Promise { } // abortController.signal.addEventListener('abort', () => { - // logger.incident('fetch', 'fetch_abort_signal', 'fetch abort signal received', { + // logger.incident('fetch', 'fetch_abort_signal', { // reason: abortController.signal.reason, // }); // });