diff --git a/docs/conventions.md b/docs/conventions.md index c134fa0..3ee63b0 100644 --- a/docs/conventions.md +++ b/docs/conventions.md @@ -59,7 +59,7 @@ PERM_METHOD_CHECK TIMR_STATE_PENDING CONN_REASON_AUTH_FAILED CACH_LIMIT_DEFAULT_MAX_ENTRIES -STOR_LOG_CATEGORY +STOR_MODULE // bad (will be flagged in audit) BUS_DIAGNOSTIC_EVENTS // wrong module prefix (rule 1) @@ -94,6 +94,7 @@ inside a module. | Category | Use | |---|---| +| `MODULE` | The module's canonical 4-letter alias as a string constant. **Single source of truth** for the module's identity. Used wherever the module's identifier is needed: logger category, error message prefix, event scope, etc. Every module declares exactly one `_MODULE = ''`. | | `ERR` | Error codes (`ErrCode` values from `$libs/errs`) | | `EVENT` | Bus or lifecycle event names (string discriminators) | | `DIAGNOSTIC_EVENTS` | Event values published through `Logger` (catalog object) | @@ -107,9 +108,8 @@ inside a module. | `DEFAULT` | Default values for options | | `LIMIT` | Maximum / minimum values | | `ID_PREFIX` | Prefix used by ID factories | -| `LOG_CATEGORY` | The logger category string | | `LOG_MSG` | Log message strings | -| `ERROR_MSG` | Error message strings (technical, dev-facing) | +| `ERROR_MSG` | Error message strings (technical, dev-facing). Must use a template referencing `_MODULE` for the prefix, never a hardcoded literal: `` `[${MOD_MODULE}] ...` ``. | | `ERROR_NAME` | Legacy `Error.name` strings (being replaced by `ERR` codes) | | `CONTEXT_KEY` | Svelte context keys | diff --git a/src/arts/aapp/active-app.svelte.ts b/src/arts/aapp/active-app.svelte.ts index 2404e85..55fa7f5 100644 --- a/src/arts/aapp/active-app.svelte.ts +++ b/src/arts/aapp/active-app.svelte.ts @@ -43,7 +43,7 @@ import { APP_ORCHESTRATION_TRANSLATOR_IDENTITY, APP_ORCHESTRATION_TRANSLATOR_PERMISSIONS_REFRESH, APP_ORCHESTRATION_TRANSLATOR_TENANT_SWITCHED, - LOGGER_CATEGORY + AAPP_MODULE } from './consts.ts'; import { AappAlreadyCreatedError } from './errors.ts'; import type { @@ -254,7 +254,7 @@ export function createActiveApp( if (disposed) return; disposed = true; if (orchestration.has(APP_ORCHESTRATION_TRANSLATOR_DISPOSE)) { - publishAppDisposeStarting(Bus, { cause: LOGGER_CATEGORY }); + publishAppDisposeStarting(Bus, { cause: AAPP_MODULE }); } Auth?.dispose(); Auth = undefined; diff --git a/src/arts/aapp/consts.ts b/src/arts/aapp/consts.ts index 4560931..423e25c 100644 --- a/src/arts/aapp/consts.ts +++ b/src/arts/aapp/consts.ts @@ -1,4 +1,6 @@ -export const LOGGER_CATEGORY = 'app'; +export { AAPP_MODULE } from '$libs/aapp/consts'; +import { AAPP_MODULE } from '$libs/aapp/consts'; + export const APP_LOG_MSG_SESSION_CACHE_CLEAR_FAILED = 'session change cache clear failed'; export const APP_CONNECTION_CLOSE_REASON_IDENTITY_CLEARED = 'identity_cleared'; @@ -14,13 +16,13 @@ export const APP_ORCHESTRATION_TRANSLATOR_DISPOSE = 'dispose'; export const APP_ERROR_NAME_ALREADY_CREATED = 'AappAlreadyCreatedError'; export const APP_ERROR_ALREADY_CREATED_SESSION = - '[aapp] App.createActiveSession() called twice — only one session per App.'; + `[${AAPP_MODULE}] App.createActiveSession() called twice — only one session per App.`; export const APP_ERROR_ALREADY_CREATED_PERMISSIONS = - '[aapp] App.createActivePermissions() called twice — only one permissions client per App.'; + `[${AAPP_MODULE}] App.createActivePermissions() called twice — only one permissions client per App.`; export const APP_ERROR_ALREADY_CREATED_AUTH = - '[aapp] App.createActiveAuth() called twice — only one active auth client per App.'; + `[${AAPP_MODULE}] App.createActiveAuth() called twice — only one active auth client per App.`; export const APP_ERROR_CREATE_PERMISSIONS_ENDPOINT_REQUIRED = - '[aapp] App.createActivePermissions() requires endpoint via options.permissions or argument.'; + `[${AAPP_MODULE}] App.createActivePermissions() requires endpoint via options.permissions or argument.`; diff --git a/src/arts/aapp/index.ts b/src/arts/aapp/index.ts index 127dc11..1fe1443 100644 --- a/src/arts/aapp/index.ts +++ b/src/arts/aapp/index.ts @@ -7,7 +7,7 @@ export { APP_ORCHESTRATION_TRANSLATOR_IDENTITY, APP_ORCHESTRATION_TRANSLATOR_PERMISSIONS_REFRESH, APP_ORCHESTRATION_TRANSLATOR_TENANT_SWITCHED, - LOGGER_CATEGORY + AAPP_MODULE } from './consts'; export { AappAlreadyCreatedError, isAappAlreadyCreatedError } from './errors'; export type { diff --git a/src/arts/aapp/integrations/session-translator.ts b/src/arts/aapp/integrations/session-translator.ts index 07b4990..9f0f3eb 100644 --- a/src/arts/aapp/integrations/session-translator.ts +++ b/src/arts/aapp/integrations/session-translator.ts @@ -19,7 +19,7 @@ import { } from '$sess/consts'; import type { SessEventMap, SessLifecyclePayload, SessionEvent } from '$sess/types'; import type { EngineBus } from '$libs/buss'; -import { LOGGER_CATEGORY } from '../consts.ts'; +import { AAPP_MODULE } from '../consts.ts'; type SessionTranslatorBusEvents = AppEventMap & SessEventMap; @@ -48,7 +48,7 @@ export function publishAppIdentityFromSessionLifecycleEvent( cause }, { - source: LOGGER_CATEGORY + source: AAPP_MODULE } ); } diff --git a/src/arts/aapp/test/storage-integration.test.ts b/src/arts/aapp/test/storage-integration.test.ts index bd071f3..d6104b4 100644 --- a/src/arts/aapp/test/storage-integration.test.ts +++ b/src/arts/aapp/test/storage-integration.test.ts @@ -61,7 +61,7 @@ describe('App.Storage', () => { storage: { adapter: broken } }); App.Storage.entry('x', 'd').set('v'); - expect(captured.some((e) => e.category === 'storage' && /write/.test(e.message))).toBe(true); + expect(captured.some((e) => e.category === 'stor' && /write/.test(e.message))).toBe(true); App.dispose(); }); }); diff --git a/src/arts/auth/consts.ts b/src/arts/auth/consts.ts index 395f2fd..d54f96a 100644 --- a/src/arts/auth/consts.ts +++ b/src/arts/auth/consts.ts @@ -12,7 +12,7 @@ export { AUTH_STORAGE_KEYS } from '$libs/auth/consts'; -export const LOGGER_CATEGORY = 'auth'; +export const AUTH_MODULE = 'auth'; export const AUTH_CLIENT_DIAGNOSTIC_EVENTS = { OPERATION_FAILED: 'auth.client.operation_failed', diff --git a/src/arts/auth/diagnostics.ts b/src/arts/auth/diagnostics.ts index be083fd..220bc5c 100644 --- a/src/arts/auth/diagnostics.ts +++ b/src/arts/auth/diagnostics.ts @@ -10,7 +10,7 @@ import { AUTH_CLIENT_DIAGNOSTIC_EVENTS, AUTH_CLIENT_LOG_MESSAGE_CACHE_INVALIDATION_FAILED, AUTH_CLIENT_LOG_MESSAGE_OPERATION_FAILED, - LOGGER_CATEGORY + AUTH_MODULE } from './consts.ts'; import type { AuthEventName } from '$libs/auth/types'; @@ -43,7 +43,7 @@ const AUTH_CLIENT_DIAGNOSTIC_LOGS: DiagnosticCatalog export function createAuthClientDiagnostics(logger?: Logger): AuthClientDiagnostics { return createCatalogDiagnostics({ logger, - defaultCategory: LOGGER_CATEGORY, + defaultCategory: AUTH_MODULE, catalog: AUTH_CLIENT_DIAGNOSTIC_LOGS }); } @@ -54,7 +54,7 @@ export function emitAuthClientDiagnostic( meta: AuthClientDiagnosticMeta ): void { diagnostics.emit({ - artifact: LOGGER_CATEGORY, + artifact: AUTH_MODULE, type, meta }); diff --git a/src/arts/auth/index.ts b/src/arts/auth/index.ts index ed84ba5..62e2216 100644 --- a/src/arts/auth/index.ts +++ b/src/arts/auth/index.ts @@ -36,7 +36,7 @@ export { AUTH_SAFE_MESSAGES, AUTH_SESSION_STATUSES, AUTH_STORAGE_KEYS, - LOGGER_CATEGORY + AUTH_MODULE } from './consts.ts'; export { createAuthClientDiagnostics, emitAuthClientDiagnostic } from './diagnostics.ts'; export { diff --git a/src/arts/cach/consts.ts b/src/arts/cach/consts.ts index e2327b9..b1ecb15 100644 --- a/src/arts/cach/consts.ts +++ b/src/arts/cach/consts.ts @@ -1,3 +1,5 @@ +import { CACH_MODULE } from '$svrs/cach'; + export { CACH_ERROR_MSG_DISPOSED_SUFFIX, CACH_ERROR_NAME_DISPOSED, @@ -26,7 +28,7 @@ export { CACH_METHOD_QUERY, CACH_METHOD_SET, CACH_METHOD_STATS, - LOGGER_CATEGORY + CACH_MODULE } from '$svrs/cach'; export const CACH_ACTIVE_STATUS_IDLE = 'idle'; @@ -63,7 +65,7 @@ export const CACH_ACTIVE_DIAGNOSTIC_EVENTS = { export const CACH_ACTIVE_LOG_MESSAGE_OPERATION_FAILED = 'active cache operation failed'; export const CACH_ERROR_MSG_ACTIVE_ENTRY_DISPOSED = - '[cach] ActiveCacheEntry used after dispose().'; + `[${CACH_MODULE}] ActiveCacheEntry used after dispose().`; export const CACH_AUTO_INVALIDATE_NONE = 'none'; export const CACH_AUTO_INVALIDATE_STANDARD = 'standard'; diff --git a/src/arts/cach/diagnostics.ts b/src/arts/cach/diagnostics.ts index 561eaa8..87b5eb7 100644 --- a/src/arts/cach/diagnostics.ts +++ b/src/arts/cach/diagnostics.ts @@ -10,7 +10,7 @@ import type { CacheKey } from '$libs/cach'; import { CACH_ACTIVE_DIAGNOSTIC_EVENTS, CACH_ACTIVE_LOG_MESSAGE_OPERATION_FAILED, - LOGGER_CATEGORY + CACH_MODULE } from './consts.ts'; export type ActiveCacheDiagnosticType = @@ -38,7 +38,7 @@ const ACTIVE_CACHE_DIAGNOSTIC_LOGS: DiagnosticCatalog string { diff --git a/src/arts/fmts/consts.ts b/src/arts/fmts/consts.ts index ea90463..8ed8483 100644 --- a/src/arts/fmts/consts.ts +++ b/src/arts/fmts/consts.ts @@ -1,3 +1,3 @@ -export const LOGGER_CATEGORY = 'formats'; +export const FMTS_MODULE = 'fmts'; export const DEFAULT_LOCALE = 'en-US'; export const AUTO_VALUE = 'auto'; diff --git a/src/arts/fmts/curr/consts.ts b/src/arts/fmts/curr/consts.ts index 1a02216..1341619 100644 --- a/src/arts/fmts/curr/consts.ts +++ b/src/arts/fmts/curr/consts.ts @@ -1,10 +1,10 @@ -export const LOGGER_CATEGORY = 'formats.currency'; +export const FMTS_CURR_MODULE = 'fmts.curr'; export const CURRENCY_DIAGNOSTIC_EVENTS = { - RATES_PROVIDER_MISSING: 'formats.currency.rates_provider_missing', - RATE_NOT_AVAILABLE: 'formats.currency.rate_not_available', - INVALID_RATE: 'formats.currency.invalid_rate', - RATE_FETCH_FAILED: 'formats.currency.rate_fetch_failed' + RATES_PROVIDER_MISSING: 'fmts.curr.rates_provider_missing', + RATE_NOT_AVAILABLE: 'fmts.curr.rate_not_available', + INVALID_RATE: 'fmts.curr.invalid_rate', + RATE_FETCH_FAILED: 'fmts.curr.rate_fetch_failed' } as const; export const AUTO_CURRENCY = 'auto'; diff --git a/src/arts/fmts/curr/diagnostics.ts b/src/arts/fmts/curr/diagnostics.ts index 36fe408..2830a85 100644 --- a/src/arts/fmts/curr/diagnostics.ts +++ b/src/arts/fmts/curr/diagnostics.ts @@ -6,7 +6,7 @@ import { type Diagnostics, type Logger } from '$libs/logr'; -import { CURRENCY_DIAGNOSTIC_EVENTS, LOGGER_CATEGORY } from './consts'; +import { CURRENCY_DIAGNOSTIC_EVENTS, FMTS_CURR_MODULE } from './consts'; import { CURRENCY_ERRORS } from './errors'; import type { CurrencyCode } from './types'; @@ -52,7 +52,7 @@ const CURRENCY_DIAGNOSTIC_LOGS: DiagnosticCatalog = { export function createCurrencyDiagnostics(logger?: Logger): CurrencyDiagnostics { return createCatalogDiagnostics({ logger, - defaultCategory: LOGGER_CATEGORY, + defaultCategory: FMTS_CURR_MODULE, catalog: CURRENCY_DIAGNOSTIC_LOGS }); } @@ -63,7 +63,7 @@ export function emitCurrencyDiagnostic( meta: CurrencyDiagnosticMeta ): void { diagnostics.emit({ - artifact: LOGGER_CATEGORY, + artifact: FMTS_CURR_MODULE, type, meta }); diff --git a/src/arts/fmts/curr/errors.ts b/src/arts/fmts/curr/errors.ts index 6aa52f9..f56338a 100644 --- a/src/arts/fmts/curr/errors.ts +++ b/src/arts/fmts/curr/errors.ts @@ -1,15 +1,15 @@ export const CURRENCY_ERRORS = { INVALID_CURRENCY: (currency: string): string => - `[formats.currency] Invalid currency code: "${currency}".`, + `[fmts.curr] Invalid currency code: "${currency}".`, INVALID_RATE: (from: string, to: string, rate: number): string => - `[formats.currency] Invalid conversion rate from "${from}" to "${to}": ${rate}.`, + `[fmts.curr] Invalid conversion rate from "${from}" to "${to}": ${rate}.`, RATE_FETCH_FAILED: (from: string, to: string): string => - `[formats.currency] Failed to fetch conversion rate from "${from}" to "${to}".`, + `[fmts.curr] Failed to fetch conversion rate from "${from}" to "${to}".`, RATE_NOT_AVAILABLE: (from: string, to: string): string => - `[formats.currency] Conversion rate is not available from "${from}" to "${to}".`, + `[fmts.curr] Conversion rate is not available from "${from}" to "${to}".`, - RATES_PROVIDER_MISSING: '[formats.currency] Conversion requires a rates provider.' + RATES_PROVIDER_MISSING: '[fmts.curr] Conversion requires a rates provider.' } as const; diff --git a/src/arts/fmts/curr/index.ts b/src/arts/fmts/curr/index.ts index 0f4a854..b7d6bc8 100644 --- a/src/arts/fmts/curr/index.ts +++ b/src/arts/fmts/curr/index.ts @@ -3,7 +3,7 @@ // or locale currency tables they never reach. export { - LOGGER_CATEGORY, + FMTS_CURR_MODULE, AUTO_CURRENCY, CURRENCY_DIAGNOSTIC_EVENTS, DEFAULT_CURRENCY, diff --git a/src/arts/fmts/curr/test/barrel.test.ts b/src/arts/fmts/curr/test/barrel.test.ts index 79b26bc..4bcc4ee 100644 --- a/src/arts/fmts/curr/test/barrel.test.ts +++ b/src/arts/fmts/curr/test/barrel.test.ts @@ -3,7 +3,7 @@ import { AUTO_CURRENCY, CURRENCY_ERRORS, DEFAULT_CURRENCY, - LOGGER_CATEGORY, + FMTS_CURR_MODULE, createEngineCurrency, createRates, resolveCurrency @@ -14,9 +14,9 @@ describe('curr public barrel', () => { expect(createEngineCurrency).toBeTypeOf('function'); expect(createRates).toBeTypeOf('function'); expect(resolveCurrency).toBeTypeOf('function'); - expect(LOGGER_CATEGORY).toBe('formats.currency'); + expect(FMTS_CURR_MODULE).toBe('fmts.curr'); expect(AUTO_CURRENCY).toBe('auto'); expect(DEFAULT_CURRENCY).toBe('USD'); - expect(CURRENCY_ERRORS.RATES_PROVIDER_MISSING).toContain('[formats.currency]'); + expect(CURRENCY_ERRORS.RATES_PROVIDER_MISSING).toContain('[fmts.curr]'); }); }); diff --git a/src/arts/fmts/curr/test/engine-currency.test.ts b/src/arts/fmts/curr/test/engine-currency.test.ts index 5875102..da9a773 100644 --- a/src/arts/fmts/curr/test/engine-currency.test.ts +++ b/src/arts/fmts/curr/test/engine-currency.test.ts @@ -3,7 +3,7 @@ import { createEngineLogger, LogLevel } from '$logr'; import { AUTO_CURRENCY, CURRENCY_ERRORS, - LOGGER_CATEGORY, + FMTS_CURR_MODULE, createEngineCurrency, createRates, type EngineCurrency @@ -79,7 +79,7 @@ describe('createEngineCurrency()', () => { await expect(curr.convert(10, 'USD')).resolves.toBeUndefined(); - const logs = logger.getLogs({ category: LOGGER_CATEGORY, level: LogLevel.DEBUG }); + const logs = logger.getLogs({ category: FMTS_CURR_MODULE, level: LogLevel.DEBUG }); expect(logs).toHaveLength(1); expect(logs[0].message).toBe(CURRENCY_ERRORS.RATES_PROVIDER_MISSING); }); diff --git a/src/arts/fmts/curr/test/rates.test.ts b/src/arts/fmts/curr/test/rates.test.ts index 2b3675c..45323d1 100644 --- a/src/arts/fmts/curr/test/rates.test.ts +++ b/src/arts/fmts/curr/test/rates.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it, vi } from 'vitest'; import { createEngineLogger, LogLevel } from '$logr'; -import { CURRENCY_ERRORS, LOGGER_CATEGORY, createRates } from '..'; +import { CURRENCY_ERRORS, FMTS_CURR_MODULE, createRates } from '..'; describe('createRates()', () => { it('caches direct and inverse rates', async () => { @@ -73,7 +73,7 @@ describe('createRates()', () => { await expect(rates.getRate('EUR', 'USD')).resolves.toBeUndefined(); await expect(rates.getRate('USD', 'EUR')).resolves.toBeUndefined(); - expect(logger.getLogs({ category: LOGGER_CATEGORY, level: LogLevel.WARN })[0].message).toBe( + expect(logger.getLogs({ category: FMTS_CURR_MODULE, level: LogLevel.WARN })[0].message).toBe( CURRENCY_ERRORS.INVALID_RATE('EUR', 'USD', 0) ); }); diff --git a/src/arts/fmts/dates/consts.ts b/src/arts/fmts/dates/consts.ts index 7a857ad..a863da0 100644 --- a/src/arts/fmts/dates/consts.ts +++ b/src/arts/fmts/dates/consts.ts @@ -1 +1 @@ -export const LOGGER_CATEGORY = 'formats.dates'; +export const FMTS_DATES_MODULE = 'fmts.dates'; diff --git a/src/arts/fmts/dates/index.ts b/src/arts/fmts/dates/index.ts index c3029d8..afab5f0 100644 --- a/src/arts/fmts/dates/index.ts +++ b/src/arts/fmts/dates/index.ts @@ -1,4 +1,4 @@ -export { LOGGER_CATEGORY } from './consts'; +export { FMTS_DATES_MODULE } from './consts'; export { createActiveDates } from './active-dates.svelte'; export { createEngineDates } from './engine-dates'; export type { diff --git a/src/arts/fmts/errors.ts b/src/arts/fmts/errors.ts index b612410..1e9f8dc 100644 --- a/src/arts/fmts/errors.ts +++ b/src/arts/fmts/errors.ts @@ -1,3 +1,5 @@ +import { FMTS_MODULE } from './consts.ts'; + export const FORMATS_ERRORS = { - INVALID_LOCALE: (locale: string): string => `[formats] Invalid locale: "${locale}".` + INVALID_LOCALE: (locale: string): string => `[${FMTS_MODULE}] Invalid locale: "${locale}".` } as const; diff --git a/src/arts/fmts/index.ts b/src/arts/fmts/index.ts index 9ede551..2a11d0e 100644 --- a/src/arts/fmts/index.ts +++ b/src/arts/fmts/index.ts @@ -4,7 +4,7 @@ // `App.Formats.currency.format(...)` style; with `sideEffects: false` in // package.json the namespace pattern still tree-shakes member access. -export { LOGGER_CATEGORY, DEFAULT_LOCALE, AUTO_VALUE } from './consts'; +export { FMTS_MODULE, DEFAULT_LOCALE, AUTO_VALUE } from './consts'; export { createEngineFormats } from './engine-formats'; export { createActiveFormats } from './active-formats.svelte'; export { FORMATS_ERRORS } from './errors'; diff --git a/src/arts/fmts/nums/consts.ts b/src/arts/fmts/nums/consts.ts index 5e82d74..f96a178 100644 --- a/src/arts/fmts/nums/consts.ts +++ b/src/arts/fmts/nums/consts.ts @@ -1 +1 @@ -export const LOGGER_CATEGORY = 'formats.numbers'; +export const FMTS_NUMS_MODULE = 'fmts.nums'; diff --git a/src/arts/fmts/nums/index.ts b/src/arts/fmts/nums/index.ts index 2db2894..db92735 100644 --- a/src/arts/fmts/nums/index.ts +++ b/src/arts/fmts/nums/index.ts @@ -1,4 +1,4 @@ -export { LOGGER_CATEGORY } from './consts'; +export { FMTS_NUMS_MODULE } from './consts'; export { createActiveNumbers } from './active-numbers.svelte'; export { createEngineNumbers } from './engine-numbers'; export type { diff --git a/src/arts/fmts/unts/consts.ts b/src/arts/fmts/unts/consts.ts index 8490d48..0f5e0da 100644 --- a/src/arts/fmts/unts/consts.ts +++ b/src/arts/fmts/unts/consts.ts @@ -1,3 +1,3 @@ -export const LOGGER_CATEGORY = 'formats.units'; +export const FMTS_UNTS_MODULE = 'fmts.unts'; export const AUTO_UNIT_SYSTEM = 'auto'; diff --git a/src/arts/fmts/unts/errors.ts b/src/arts/fmts/unts/errors.ts index 87efeff..f2c8b07 100644 --- a/src/arts/fmts/unts/errors.ts +++ b/src/arts/fmts/unts/errors.ts @@ -1,11 +1,11 @@ export const UNITS_ERRORS = { - UNKNOWN_UNIT: (unit: string): string => `[formats.units] Unknown unit: "${unit}".`, + UNKNOWN_UNIT: (unit: string): string => `[fmts.unts] Unknown unit: "${unit}".`, INCOMPATIBLE_UNITS: (from: string, fromBase: string, to: string, toBase: string): string => - `[formats.units] Incompatible units: "${from}" (${fromBase}) and "${to}" (${toBase}).`, + `[fmts.unts] Incompatible units: "${from}" (${fromBase}) and "${to}" (${toBase}).`, DEFAULT_UNIT_NOT_FOUND: (system: string, kind: string): string => - `[formats.units] Default unit not found for "${system}:${kind}".` + `[fmts.unts] Default unit not found for "${system}:${kind}".` } as const; export const UNITS_ERROR_NAMES = { diff --git a/src/arts/fmts/unts/index.ts b/src/arts/fmts/unts/index.ts index 984c16e..3a01d78 100644 --- a/src/arts/fmts/unts/index.ts +++ b/src/arts/fmts/unts/index.ts @@ -1,4 +1,4 @@ -export { LOGGER_CATEGORY, AUTO_UNIT_SYSTEM } from './consts'; +export { FMTS_UNTS_MODULE, AUTO_UNIT_SYSTEM } from './consts'; export { createActiveUnits } from './active-units.svelte'; export { createEngineUnits } from './engine-units'; export { convert } from './conversions'; diff --git a/src/arts/http/consts.ts b/src/arts/http/consts.ts index 02d8ddf..3675283 100644 --- a/src/arts/http/consts.ts +++ b/src/arts/http/consts.ts @@ -15,8 +15,8 @@ import { } from '$libs/http'; /** Logger category emitted by the engine. */ -export const LOGGER_CATEGORY = 'http'; -export const ERROR_PREFIX = '[http] '; +export const HTTP_MODULE = 'http'; +export const ERROR_PREFIX = `[${HTTP_MODULE}] `; /** HTTP statuses with no body — `parseBody` returns `undefined` for these. */ export const NULL_BODY_STATUSES = HTTP_NULL_BODY_STATUSES; diff --git a/src/arts/http/diagnostics.ts b/src/arts/http/diagnostics.ts index a2fd82f..c251191 100644 --- a/src/arts/http/diagnostics.ts +++ b/src/arts/http/diagnostics.ts @@ -9,7 +9,7 @@ import { import { HTTP_DIAGNOSTIC_EVENTS, HTTP_METHOD_GET, - LOGGER_CATEGORY, + HTTP_MODULE, bodySchemaRejectedLogMessage, httpStatusLogMessage, networkErrorLogMessage, @@ -81,13 +81,13 @@ function methodOf(event: HttpDiagnosticEvent): HttpMethod { } function urlOf(event: HttpDiagnosticEvent): string { - return event.meta?.url ?? LOGGER_CATEGORY; + return event.meta?.url ?? HTTP_MODULE; } export function createHttpDiagnostics(logger?: Logger): HttpDiagnostics { return createCatalogDiagnostics({ logger, - defaultCategory: LOGGER_CATEGORY, + defaultCategory: HTTP_MODULE, catalog: HTTP_DIAGNOSTIC_LOGS }); } @@ -98,7 +98,7 @@ export function emitHttpDiagnostic( meta: HttpDiagnosticMeta ): void { diagnostics.emit({ - artifact: LOGGER_CATEGORY, + artifact: HTTP_MODULE, type, meta }); diff --git a/src/arts/http/index.ts b/src/arts/http/index.ts index 7e5c43e..555f0b2 100644 --- a/src/arts/http/index.ts +++ b/src/arts/http/index.ts @@ -6,7 +6,7 @@ export { createEngineHttp } from './engine-http.ts'; export { createHttpDiagnostics, emitHttpDiagnostic } from './diagnostics.ts'; export { - LOGGER_CATEGORY, + HTTP_MODULE, NULL_BODY_STATUSES, DEFAULT_RETRY_METHODS, DEFAULT_RETRY_STATUSES, diff --git a/src/arts/lang/index.ts b/src/arts/lang/index.ts index 57fda93..85f764a 100644 --- a/src/arts/lang/index.ts +++ b/src/arts/lang/index.ts @@ -27,7 +27,7 @@ export { LANG_DIAGNOSTIC_EVENTS, LANG_ERRORS, langNodeToJSON, - LOGGER_CATEGORY, + LANG_MODULE, makeLangRecord, MAX_RESOLVE_DEPTH, MONO_LANG_CATEGORY, diff --git a/src/arts/perm/consts.ts b/src/arts/perm/consts.ts index 963c0cb..f45aa3e 100644 --- a/src/arts/perm/consts.ts +++ b/src/arts/perm/consts.ts @@ -7,7 +7,7 @@ export { PERM_CLIENT_KEY_GLOBAL, PERM_CLIENT_KEY_NONE, PERM_CLIENT_KEY_SEPARATOR, - PERM_LOGGER_CATEGORY as LOGGER_CATEGORY, + PERM_MODULE, PERM_HTTP_CREDENTIALS_INCLUDE, PERM_HTTP_STATUS_BAD_REQUEST, PERM_HTTP_STATUS_FORBIDDEN, diff --git a/src/arts/perm/diagnostics.ts b/src/arts/perm/diagnostics.ts index 760eac9..6bd12f7 100644 --- a/src/arts/perm/diagnostics.ts +++ b/src/arts/perm/diagnostics.ts @@ -6,7 +6,7 @@ import { type Diagnostics } from '$libs/logr'; import { - LOGGER_CATEGORY, + PERM_MODULE, PERM_CLIENT_DIAGNOSTIC_EVENTS, PERM_LOG_MSG_REMOTE_BATCH_FAILED, PERM_LOG_MSG_REMOTE_CHECK_FAILED, @@ -65,7 +65,7 @@ export function createPermissionClientDiagnostics( ): PermissionClientDiagnostics { return createCatalogDiagnostics({ logger, - defaultCategory: LOGGER_CATEGORY, + defaultCategory: PERM_MODULE, catalog: PERM_CLIENT_DIAGNOSTIC_LOGS }); } @@ -76,7 +76,7 @@ export function emitPermissionClientDiagnostic( meta: PermissionClientDiagnosticMeta ): void { diagnostics.emit({ - artifact: LOGGER_CATEGORY, + artifact: PERM_MODULE, type, meta }); diff --git a/src/arts/perm/index.ts b/src/arts/perm/index.ts index 6186a41..6c3df37 100644 --- a/src/arts/perm/index.ts +++ b/src/arts/perm/index.ts @@ -9,7 +9,7 @@ export { disposedPermissionsMessage } from './helpers.ts'; export { permissionDecisionKey, stablePermissionStringify } from '$libs/svrs/perm'; export { - LOGGER_CATEGORY, + PERM_MODULE, PERM_AUTO_INVALIDATE_NONE, PERM_AUTO_INVALIDATE_PERMISSIONS_REFRESH, PERM_AUTO_INVALIDATE_STANDARD, diff --git a/src/arts/sess/active-session.svelte.ts b/src/arts/sess/active-session.svelte.ts index ac9d893..2121bed 100644 --- a/src/arts/sess/active-session.svelte.ts +++ b/src/arts/sess/active-session.svelte.ts @@ -11,7 +11,7 @@ import { IDENTITY_ANONYMOUS, IDENTITY_IDENTIFIED, IDENTITY_NONE, - LOGGER_CATEGORY + SESS_MODULE } from './consts.ts'; /** @@ -42,7 +42,7 @@ export function createActiveSession = { function adapterName(meta: SessionDiagnosticMeta | undefined): string { if (meta !== undefined && 'adapterName' in meta) return meta.adapterName; - return LOGGER_CATEGORY; + return SESS_MODULE; } function invariantName(meta: SessionDiagnosticMeta | undefined): AdoptInvariant { @@ -115,7 +115,7 @@ function invariantName(meta: SessionDiagnosticMeta | undefined): AdoptInvariant function methodName(meta: SessionDiagnosticMeta | undefined): string { if (meta !== undefined && 'method' in meta) return meta.method; - return LOGGER_CATEGORY; + return SESS_MODULE; } function sessionEventName(meta: SessionDiagnosticMeta | undefined): string { @@ -128,7 +128,7 @@ export function createSessionDiagnostics( ): SessionDiagnostics { return createCatalogDiagnostics({ logger, - defaultCategory: LOGGER_CATEGORY, + defaultCategory: SESS_MODULE, catalog: SESS_DIAGNOSTIC_LOGS }); } @@ -139,7 +139,7 @@ export function emitSessionDiagnostic( meta: SessionDiagnosticMeta ): void { diagnostics.emit({ - artifact: LOGGER_CATEGORY, + artifact: SESS_MODULE, type, meta }); diff --git a/src/arts/sess/engine-session.ts b/src/arts/sess/engine-session.ts index 70d162a..32d1ea3 100644 --- a/src/arts/sess/engine-session.ts +++ b/src/arts/sess/engine-session.ts @@ -14,7 +14,7 @@ import { FIELD_ACTOR, FIELD_CREDENTIAL, FIELD_DATA, - LOGGER_CATEGORY, + SESS_MODULE, REFRESH_STATUS_SKIPPED, REVOKE_REASON_NO_SESSION, REVOKE_SCOPE_LOCAL, @@ -99,7 +99,7 @@ export function createEngineSession): SiumDiagnosti export function createSiumDiagnostics(logger?: Logger): SiumDiagnostics { return createCatalogDiagnostics({ logger, - defaultCategory: LOGGER_CATEGORY, + defaultCategory: SIUM_MODULE, catalog: SIUM_DIAGNOSTIC_LOGS }); } @@ -65,7 +65,7 @@ export function emitSiumDiagnostic( meta: SiumDiagnosticMeta ): void { diagnostics.emit({ - artifact: LOGGER_CATEGORY, + artifact: SIUM_MODULE, type, meta }); diff --git a/src/arts/sium/errors.ts b/src/arts/sium/errors.ts index 7f79d56..b638bfd 100644 --- a/src/arts/sium/errors.ts +++ b/src/arts/sium/errors.ts @@ -1,6 +1,8 @@ +import { SIUM_MODULE } from './consts.ts'; + export const SIUM_ERRORS = { - VALIDATION_FAILED: '[sium] Validation failed.', - RESOLVE_FALLBACK: '[sium] Falling back while resolving Sium message.', + VALIDATION_FAILED: `[${SIUM_MODULE}] Validation failed.`, + RESOLVE_FALLBACK: `[${SIUM_MODULE}] Falling back while resolving Sium message.`, OBJECT_ENCODE_EXPECTS_PLAIN_OBJECT: 'object().encode expects a plain object value', ARRAY_ENCODE_EXPECTS_ARRAY: 'array().encode expects an array value', LAZY_RESOLVING_ACCESS: diff --git a/src/arts/sium/index.ts b/src/arts/sium/index.ts index 3ddb444..d7972f1 100644 --- a/src/arts/sium/index.ts +++ b/src/arts/sium/index.ts @@ -8,7 +8,7 @@ export { createEngineSium } from './engine-sium'; export type { EngineSium, EngineSiumOptions } from './engine-sium'; export { createSiumDiagnostics, emitSiumDiagnostic, issueDiagnosticMeta } from './diagnostics'; -export { LOGGER_CATEGORY, SIUM_DIAGNOSTIC_EVENTS } from './consts'; +export { SIUM_MODULE, SIUM_DIAGNOSTIC_EVENTS } from './consts'; export { SIUM_ERRORS } from './errors'; // core diff --git a/src/arts/sium/test/engine-sium.test.ts b/src/arts/sium/test/engine-sium.test.ts index c9624ff..9b74118 100644 --- a/src/arts/sium/test/engine-sium.test.ts +++ b/src/arts/sium/test/engine-sium.test.ts @@ -1,7 +1,7 @@ import { describe, expect, expectTypeOf, it } from 'vitest'; import { createEngineLang } from '$lang'; import { createEngineLogger, LogLevel } from '$logr'; -import { LOGGER_CATEGORY, SIUM_ERRORS, createEngineSium, type EngineSium } from '..'; +import { SIUM_MODULE, SIUM_ERRORS, createEngineSium, type EngineSium } from '..'; import type { Issue, Schema } from '../core'; import { siumLangs } from '../langs'; @@ -86,7 +86,7 @@ describe('createEngineSium()', () => { const result = await sium.validate(schema, 'A'); expect(result.ok).toBe(false); - const logs = logger.getLogs({ category: LOGGER_CATEGORY, level: LogLevel.DEBUG }); + const logs = logger.getLogs({ category: SIUM_MODULE, level: LogLevel.DEBUG }); expect(logs).toHaveLength(1); expect(logs[0].message).toBe(SIUM_ERRORS.VALIDATION_FAILED); expect(logs[0].context).toMatchObject({ @@ -108,7 +108,7 @@ describe('createEngineSium()', () => { const result = sium.validateSync(schema, 'A'); expect(result.ok).toBe(false); - expect(logger.getLogs({ category: LOGGER_CATEGORY, level: LogLevel.DEBUG })).toHaveLength(1); + expect(logger.getLogs({ category: SIUM_MODULE, level: LogLevel.DEBUG })).toHaveLength(1); }); it('does not log successful validations', async () => { @@ -118,6 +118,6 @@ describe('createEngineSium()', () => { await expect(sium.validate(schema, 'Ada')).resolves.toEqual({ ok: true, value: 'Ada' }); - expect(logger.getLogs({ category: LOGGER_CATEGORY })).toHaveLength(0); + expect(logger.getLogs({ category: SIUM_MODULE })).toHaveLength(0); }); }); diff --git a/src/arts/stor/consts.ts b/src/arts/stor/consts.ts index 38e4cfd..11ef92f 100644 --- a/src/arts/stor/consts.ts +++ b/src/arts/stor/consts.ts @@ -3,7 +3,7 @@ * Consumers (typically `aapp`) override the handler to route through their * own logger and may pick a different category there. */ -export const LOGGER_CATEGORY = 'storage'; +export const STOR_MODULE = 'stor'; export const STOR_OP_READ = 'read'; export const STOR_OP_WRITE = 'write'; @@ -68,8 +68,8 @@ export const NAMESPACE_SEPARATOR = ':'; export const ENVELOPE_ERROR_VERSION_NOT_NUMBER = 'envelope.v not a number'; export const STOR_DIAGNOSTIC_EVENTS = { - ERROR: 'storage.error' + ERROR: 'stor.error' } as const; export const defaultStorageErrorMessage = (op: string, fullKey: string): string => - `[${LOGGER_CATEGORY}] ${op} on "${fullKey}":`; + `[${STOR_MODULE}] ${op} on "${fullKey}":`; diff --git a/src/arts/stor/diagnostics.ts b/src/arts/stor/diagnostics.ts index eb39d8d..7dbc246 100644 --- a/src/arts/stor/diagnostics.ts +++ b/src/arts/stor/diagnostics.ts @@ -6,7 +6,7 @@ import { type Diagnostics, type Logger } from '$libs/logr'; -import { LOGGER_CATEGORY, STOR_DIAGNOSTIC_EVENTS, defaultStorageErrorMessage } from './consts'; +import { STOR_MODULE, STOR_DIAGNOSTIC_EVENTS, defaultStorageErrorMessage } from './consts'; import type { StorageErrorContext } from './types'; export type StorageDiagnosticType = @@ -19,7 +19,7 @@ const STOR_DIAGNOSTIC_LOGS: DiagnosticCatalog = { [STOR_DIAGNOSTIC_EVENTS.ERROR]: (event) => ({ level: LogLevel.WARN, message: defaultStorageErrorMessage( - event.meta?.op ?? LOGGER_CATEGORY, + event.meta?.op ?? STOR_MODULE, event.meta?.fullKey ?? '' ) }) @@ -28,7 +28,7 @@ const STOR_DIAGNOSTIC_LOGS: DiagnosticCatalog = { export function createStorageDiagnostics(logger?: Logger): StorageDiagnostics { return createCatalogDiagnostics({ logger, - defaultCategory: LOGGER_CATEGORY, + defaultCategory: STOR_MODULE, catalog: STOR_DIAGNOSTIC_LOGS }); } @@ -39,7 +39,7 @@ export function emitStorageDiagnostic( meta: StorageErrorContext ): void { diagnostics.emit({ - artifact: LOGGER_CATEGORY, + artifact: STOR_MODULE, type, meta }); diff --git a/src/arts/stor/errors.ts b/src/arts/stor/errors.ts index e04d088..33a9ac8 100644 --- a/src/arts/stor/errors.ts +++ b/src/arts/stor/errors.ts @@ -1,31 +1,33 @@ +import { STOR_MODULE } from './consts.ts'; + export const STOR_ERRORS = { UNDEFINED_DEFAULT: - '[storage] defaults must not be undefined. Use null when you need an empty value.', + `[${STOR_MODULE}] defaults must not be undefined. Use null when you need an empty value.`, RAW_INCOMPATIBLE: (offending: string): string => - `[storage] raw mode is incompatible with "${offending}". Without an envelope there is nowhere to keep that metadata. Drop "${offending}" or unset raw.`, + `[${STOR_MODULE}] raw mode is incompatible with "${offending}". Without an envelope there is nowhere to keep that metadata. Drop "${offending}" or unset raw.`, ASYNC_VALIDATE_UNSUPPORTED: - '[storage] Async Standard Schema validation is not supported in v1 (SyncStorageAdapter only). Use a sync schema or a sync validate() function.', + `[${STOR_MODULE}] Async Standard Schema validation is not supported in v1 (SyncStorageAdapter only). Use a sync schema or a sync validate() function.`, ENTRY_DEFAULTS_MISMATCH: (key: string): string => - `[storage] entry("${key}", ...) was called more than once with different defaults. The first registration wins; the second default is ignored.`, + `[${STOR_MODULE}] entry("${key}", ...) was called more than once with different defaults. The first registration wins; the second default is ignored.`, NO_PERSIST_ADAPTER: - '[storage] frontend.persist was requested but no persistent storage adapter is configured. Values will reset on reload. Configure createActiveApp({ storage: { adapter: localAdapter } }) or pass an adapter via persist.adapter.', + `[${STOR_MODULE}] frontend.persist was requested but no persistent storage adapter is configured. Values will reset on reload. Configure createActiveApp({ storage: { adapter: localAdapter } }) or pass an adapter via persist.adapter.`, COOKIE_SERVER_REQUIRED: - '[storage] cookieAdapter() runs in the browser only. For SSR use cookieAdapter.fromCookies(event.cookies, options).', + `[${STOR_MODULE}] cookieAdapter() runs in the browser only. For SSR use cookieAdapter.fromCookies(event.cookies, options).`, NUMBER_SERIALIZER_INVALID: (value: string): string => - `[storage] numberSerializer could not parse "${value}" as a number.`, + `[${STOR_MODULE}] numberSerializer could not parse "${value}" as a number.`, BOOLEAN_SERIALIZER_INVALID: (value: string): string => - `[storage] booleanSerializer could not parse "${value}" as a boolean.`, + `[${STOR_MODULE}] booleanSerializer could not parse "${value}" as a boolean.`, DATE_SERIALIZER_INVALID: (value: string): string => - `[storage] dateSerializer could not parse "${value}" as a date.`, + `[${STOR_MODULE}] dateSerializer could not parse "${value}" as a date.`, STANDARD_SCHEMA_VALIDATION_FAILED: (issues: unknown): string => - `[storage] Standard Schema validation failed: ${JSON.stringify(issues)}` + `[${STOR_MODULE}] Standard Schema validation failed: ${JSON.stringify(issues)}` } as const; diff --git a/src/arts/stor/index.ts b/src/arts/stor/index.ts index daf5512..1d5a441 100644 --- a/src/arts/stor/index.ts +++ b/src/arts/stor/index.ts @@ -2,7 +2,7 @@ export { createEngineStorage } from './engine-storage'; export { createActiveStorage } from './active-storage.svelte'; export { createStorageDiagnostics, emitStorageDiagnostic } from './diagnostics'; export { - LOGGER_CATEGORY, + STOR_MODULE, DEFAULT_VERSION, NAMESPACE_SEPARATOR, ENVELOPE_KEY_VERSION, diff --git a/src/arts/timr/consts.ts b/src/arts/timr/consts.ts index e45279b..85f9c23 100644 --- a/src/arts/timr/consts.ts +++ b/src/arts/timr/consts.ts @@ -8,9 +8,11 @@ * message prefixes, log message prefixes) stay in this file. */ +import { TIMR_MODULE } from '$libs/timers'; + export { DEFAULT_TIMER_SCOPE_SEPARATOR, - LOGGER_CATEGORY, + TIMR_MODULE, TIMR_DIAGNOSTIC_EVENTS, TIMR_EVENT_CANCELLED, TIMR_EVENT_COMPLETED, @@ -55,7 +57,7 @@ export const LOG_MSG_LISTENER_THREW_PREFIX = 'Listener threw on event '; // Prefixed `[timr]` to match the convention used by `arts/sess` / // `arts/http` so log output and stack traces are searchable. -export const ERROR_PREFIX = '[timr] '; +export const ERROR_PREFIX = `[${TIMR_MODULE}] `; export const ERROR_NAME_DISPOSED = 'TimrDisposedError'; export const ERROR_NAME_INVALID_KEY = 'TimrInvalidKeyError'; export const ERROR_NAME_DUPLICATE_KEY = 'TimrDuplicateKeyError'; diff --git a/src/arts/timr/diagnostics.ts b/src/arts/timr/diagnostics.ts index 034db8d..af263cf 100644 --- a/src/arts/timr/diagnostics.ts +++ b/src/arts/timr/diagnostics.ts @@ -6,7 +6,7 @@ import { type Diagnostics } from '$libs/logr'; import { - LOGGER_CATEGORY, + TIMR_MODULE, LOG_MSG_SCHEDULE_AT_PAST, TIMR_DIAGNOSTIC_EVENTS, TIMR_EVENT_FAILED, @@ -59,13 +59,13 @@ function timerEventName(meta: TimerDiagnosticMeta | undefined): TimerEvent['type function timerKeyName(meta: TimerDiagnosticMeta | undefined): string { if (meta !== undefined && 'key' in meta) return meta.key; - return LOGGER_CATEGORY; + return TIMR_MODULE; } export function createTimerDiagnostics(logger?: Logger): TimerDiagnostics { return createCatalogDiagnostics({ logger, - defaultCategory: LOGGER_CATEGORY, + defaultCategory: TIMR_MODULE, catalog: TIMR_DIAGNOSTIC_LOGS }); } @@ -76,7 +76,7 @@ export function emitTimerDiagnostic( meta: TimerDiagnosticMeta ): void { diagnostics.emit({ - artifact: LOGGER_CATEGORY, + artifact: TIMR_MODULE, type, meta }); diff --git a/src/arts/timr/index.ts b/src/arts/timr/index.ts index 095b5a0..350e975 100644 --- a/src/arts/timr/index.ts +++ b/src/arts/timr/index.ts @@ -14,7 +14,7 @@ export { DEFAULT_BACKOFF_MAX_DELAY_MS, DEFAULT_BACKOFF_MIN_DELAY_MS, DEFAULT_TIMER_SCOPE_SEPARATOR, - LOGGER_CATEGORY, + TIMR_MODULE, TIMR_DIAGNOSTIC_EVENTS, TIMR_EVENT_CANCELLED, TIMR_EVENT_COMPLETED, diff --git a/src/libs/aapp/consts.ts b/src/libs/aapp/consts.ts index bccdcf2..51398e3 100644 --- a/src/libs/aapp/consts.ts +++ b/src/libs/aapp/consts.ts @@ -4,6 +4,8 @@ * (context keys, error names, runtime gates). */ +export const AAPP_MODULE = 'aapp'; + export const AAPP_BUS_CONTEXT_KEY = 'libs.aapp.bus'; export const AAPP_BUS_ERROR_NAME_NO_CONTEXT = 'AappBusNoContextError'; @@ -11,11 +13,11 @@ export const AAPP_EVENT_ERROR_NAME_INVALID_RUNTIME = 'AappInvalidEventRuntimeErr export const AAPP_EVENT_ERROR_NAME_UNSAFE_PAYLOAD = 'AappUnsafeEventPayloadError'; export const AAPP_BUS_ERROR_MSG_NO_CONTEXT = - '[aapp] no bus in context — call setBus(App.Bus) in a layout before getBus()'; + `[${AAPP_MODULE}] no bus in context — call setBus(App.Bus) in a layout before getBus()`; export const AAPP_EVENT_ERROR_MSG_INVALID_RUNTIME = - '[aapp] event cannot fire in this runtime'; + `[${AAPP_MODULE}] event cannot fire in this runtime`; export const AAPP_EVENT_ERROR_MSG_UNSAFE_PAYLOAD = - '[aapp] app event payload contains a sensitive field'; + `[${AAPP_MODULE}] app event payload contains a sensitive field`; export const AAPP_EVENT_SENSITIVE_KEY_PARTS = [ 'authorization', diff --git a/src/libs/buss/consts.ts b/src/libs/buss/consts.ts index 0f0f2d5..768943e 100644 --- a/src/libs/buss/consts.ts +++ b/src/libs/buss/consts.ts @@ -1,4 +1,4 @@ -export const BUSS_LOG_CATEGORY = 'buss'; +export const BUSS_MODULE = 'buss'; export const BUSS_DEFAULT_SOURCE = 'buss'; export const BUSS_EVENT_ALL = '*'; @@ -32,12 +32,12 @@ export const BUSS_ERROR_NAME_AGGREGATE_LISTENER = 'BusAggregateListenerError'; export const BUSS_ERROR_NAME_REENTRANCY_LIMIT = 'BusReentrancyLimitError'; export const BUSS_ERROR_NAME_INVALID_PAYLOAD = 'BusInvalidPayloadError'; -export const BUSS_ERROR_MSG_DISPOSED = '[buss] operation called on a disposed bus'; -export const BUSS_ERROR_MSG_AGGREGATE_LISTENER = '[buss] one or more listeners failed'; +export const BUSS_ERROR_MSG_DISPOSED = `[${BUSS_MODULE}] operation called on a disposed bus`; +export const BUSS_ERROR_MSG_AGGREGATE_LISTENER = `[${BUSS_MODULE}] one or more listeners failed`; export const BUSS_ERROR_MSG_REENTRANCY_LIMIT = - '[buss] synchronous publish recursion exceeded maxReentrancyDepth'; + `[${BUSS_MODULE}] synchronous publish recursion exceeded maxReentrancyDepth`; export const BUSS_ERROR_MSG_INVALID_PAYLOAD = - '[buss] payload is not cloneable plain data; use $state.snapshot(...) before publishing reactive state and avoid functions, class instances or DOM nodes'; + `[${BUSS_MODULE}] payload is not cloneable plain data; use $state.snapshot(...) before publishing reactive state and avoid functions, class instances or DOM nodes`; export const BUSS_LOG_MSG_LISTENER_FAILED = 'buss.listener.failed'; export const BUSS_LOG_MSG_LISTENER_LEAK_WARNING = 'buss.listener.leak_warning'; diff --git a/src/libs/buss/diagnostics.ts b/src/libs/buss/diagnostics.ts index 3cba350..385123b 100644 --- a/src/libs/buss/diagnostics.ts +++ b/src/libs/buss/diagnostics.ts @@ -1,6 +1,6 @@ import { BUSS_DIAGNOSTIC_EVENTS, - BUSS_LOG_CATEGORY, + BUSS_MODULE, BUSS_LOG_MSG_LISTENER_FAILED, BUSS_LOG_MSG_LISTENER_LEAK_WARNING } from './consts.ts'; @@ -48,7 +48,7 @@ const BUSS_DIAGNOSTIC_LOGS: DiagnosticCatalog = { export function createBusDiagnostics(logger?: Logger): BusDiagnostics { return createCatalogDiagnostics({ logger, - defaultCategory: BUSS_LOG_CATEGORY, + defaultCategory: BUSS_MODULE, catalog: BUSS_DIAGNOSTIC_LOGS }); } @@ -59,7 +59,7 @@ export function emitBusDiagnostic( meta: BusDiagnosticMeta ): void { diagnostics.emit({ - artifact: BUSS_LOG_CATEGORY, + artifact: BUSS_MODULE, type, meta }); diff --git a/src/libs/buss/index.ts b/src/libs/buss/index.ts index a36cfb4..c016bb2 100644 --- a/src/libs/buss/index.ts +++ b/src/libs/buss/index.ts @@ -33,7 +33,7 @@ export { BUSS_LISTENER_ERROR_MODE_THROW, BUSS_LISTENER_ERROR_MODES, BUSS_LISTENER_ID_PREFIX, - BUSS_LOG_CATEGORY, + BUSS_MODULE, BUSS_LOG_MSG_LISTENER_FAILED, BUSS_LOG_MSG_LISTENER_LEAK_WARNING } from './consts.ts'; diff --git a/src/libs/lang/consts.ts b/src/libs/lang/consts.ts index 4cce35d..2e570aa 100644 --- a/src/libs/lang/consts.ts +++ b/src/libs/lang/consts.ts @@ -2,7 +2,7 @@ export const ID_PREFIX = '#?'; export const ID_FALLBACK_SEPARATOR = '|'; export const MAX_RESOLVE_DEPTH = 3; -export const LOGGER_CATEGORY = 'lang'; +export const LANG_MODULE = 'lang'; export const MONO_LANG_CATEGORY = 'lang.mono'; export const LANG_DIAGNOSTIC_EVENTS = { diff --git a/src/libs/lang/diagnostics.ts b/src/libs/lang/diagnostics.ts index 94554e3..8b073f9 100644 --- a/src/libs/lang/diagnostics.ts +++ b/src/libs/lang/diagnostics.ts @@ -6,7 +6,7 @@ import { type Diagnostics, type Logger } from '$libs/logr'; -import { LANG_DIAGNOSTIC_EVENTS, LOGGER_CATEGORY } from './consts.ts'; +import { LANG_DIAGNOSTIC_EVENTS, LANG_MODULE } from './consts.ts'; import { LANG_ERRORS } from './errors.ts'; import type { SupportedLocale } from './types.ts'; @@ -86,7 +86,7 @@ const LANG_DIAGNOSTIC_LOGS: DiagnosticCatalog = { export function createLangDiagnostics(logger?: Logger): LangDiagnostics { return createCatalogDiagnostics({ logger, - defaultCategory: LOGGER_CATEGORY, + defaultCategory: LANG_MODULE, catalog: LANG_DIAGNOSTIC_LOGS }); } @@ -98,7 +98,7 @@ export function emitLangDiagnostic( scope?: string ): void { diagnostics.emit({ - artifact: LOGGER_CATEGORY, + artifact: LANG_MODULE, type, scope, meta diff --git a/src/libs/lang/errors.ts b/src/libs/lang/errors.ts index 6c28e40..960eb9d 100644 --- a/src/libs/lang/errors.ts +++ b/src/libs/lang/errors.ts @@ -1,13 +1,15 @@ +import { LANG_MODULE } from './consts.ts'; + export const LANG_ERRORS = { - KEY_NOT_FOUND: (path: string): string => `[lang] Translation key not found: "${path}"`, + KEY_NOT_FOUND: (path: string): string => `[${LANG_MODULE}] Translation key not found: "${path}"`, - CIRCULAR_REFERENCE: (path: string): string => `[lang] Circular reference in "${path}".`, + CIRCULAR_REFERENCE: (path: string): string => `[${LANG_MODULE}] Circular reference in "${path}".`, MISSING_TRANSLATION: (path: string, locale: string, usedLocale: string): string => - `[lang] Missing translation for "${path}" in "${locale}". Falling back to "${usedLocale}".`, + `[${LANG_MODULE}] Missing translation for "${path}" in "${locale}". Falling back to "${usedLocale}".`, MISSING_TRANSLATION_RECORD: (locale: string, usedLocale: string): string => - `[lang] Missing translation in "${locale}". Falling back to "${usedLocale}".`, + `[${LANG_MODULE}] Missing translation in "${locale}". Falling back to "${usedLocale}".`, AMBIGUOUS_SIBLING_MATCH: ( locale: string, @@ -16,21 +18,21 @@ export const LANG_ERRORS = { path?: string ): string => path - ? `[lang] "${path}" requested base locale "${locale}" but only ${siblingCount} regional variants exist. Picked "${usedLocale}" by insertion order — define a canonical "${locale}" entry to remove the ambiguity.` - : `[lang] Requested base locale "${locale}" but only ${siblingCount} regional variants exist. Picked "${usedLocale}" by insertion order — define a canonical "${locale}" entry to remove the ambiguity.`, + ? `[${LANG_MODULE}] "${path}" requested base locale "${locale}" but only ${siblingCount} regional variants exist. Picked "${usedLocale}" by insertion order — define a canonical "${locale}" entry to remove the ambiguity.` + : `[${LANG_MODULE}] Requested base locale "${locale}" but only ${siblingCount} regional variants exist. Picked "${usedLocale}" by insertion order — define a canonical "${locale}" entry to remove the ambiguity.`, EXTEND_LEAF_OVERWRITE: (path: string): string => - `[lang] extend(): leaf at "${path}" was overwritten silently. Last write wins — register namespaces uniquely or check for collisions before extending.`, + `[${LANG_MODULE}] extend(): leaf at "${path}" was overwritten silently. Last write wins — register namespaces uniquely or check for collisions before extending.`, - LOGGER_ALREADY_SET: '[lang] Logger already set. setLogger() can only be called once.', + LOGGER_ALREADY_SET: `[${LANG_MODULE}] Logger already set. setLogger() can only be called once.`, EXTEND_NAMESPACE_COLLIDES_WITH_LEAF: (path: string): string => - `[lang] Cannot extend namespace "${path}" because it already contains a translation leaf.`, + `[${LANG_MODULE}] Cannot extend namespace "${path}" because it already contains a translation leaf.`, LANG_NODE_TO_JSON_UNSAFE_DYNAMIC_FN: - '[lang] langNodeToJSON: dynamic LangFn cannot be serialized safely. Use p() for plurals or a static template function.', + `[${LANG_MODULE}] langNodeToJSON: dynamic LangFn cannot be serialized safely. Use p() for plurals or a static template function.`, - JSON_TO_LANG_NODE_INVALID_SHAPE: '[lang] JSONToLangNode: invalid JSON shape for LangNode', + JSON_TO_LANG_NODE_INVALID_SHAPE: `[${LANG_MODULE}] JSONToLangNode: invalid JSON shape for LangNode`, REFERENCE_FALLBACK_USED: (path: string, fallback: string): string => `${LANG_ERRORS.KEY_NOT_FOUND(path)}. Using fallback "${fallback}".`, diff --git a/src/libs/lang/index.ts b/src/libs/lang/index.ts index 56b39c1..d0ab49a 100644 --- a/src/libs/lang/index.ts +++ b/src/libs/lang/index.ts @@ -17,7 +17,7 @@ export { ID_FALLBACK_SEPARATOR, ID_PREFIX, LANG_DIAGNOSTIC_EVENTS, - LOGGER_CATEGORY, + LANG_MODULE, MAX_RESOLVE_DEPTH, MONO_LANG_CATEGORY } from './consts.ts'; diff --git a/src/libs/svrs/perm.ts b/src/libs/svrs/perm.ts index 821f67f..97eb848 100644 --- a/src/libs/svrs/perm.ts +++ b/src/libs/svrs/perm.ts @@ -1,6 +1,6 @@ import type { ResourceRef } from '$libs/perm'; -export const PERM_LOGGER_CATEGORY = 'perm'; +export const PERM_MODULE = 'perm'; export const PERM_CLIENT_PATH_CHECK = '/check'; export const PERM_CLIENT_PATH_BATCH = '/batch'; diff --git a/src/libs/timers/consts.ts b/src/libs/timers/consts.ts index 9e74fa1..9952a13 100644 --- a/src/libs/timers/consts.ts +++ b/src/libs/timers/consts.ts @@ -9,7 +9,7 @@ */ /** Logger category emitted by the engine. */ -export const LOGGER_CATEGORY = 'timr'; +export const TIMR_MODULE = 'timr'; export const TIMR_DIAGNOSTIC_EVENTS = { LISTENER_THREW: 'timr.listener_threw', diff --git a/src/svrs/cach/consts.ts b/src/svrs/cach/consts.ts index 911e9d9..01b8f2c 100644 --- a/src/svrs/cach/consts.ts +++ b/src/svrs/cach/consts.ts @@ -17,7 +17,7 @@ import { type CacheEventType } from '$libs/cach'; -export const LOGGER_CATEGORY = 'cach'; +export const CACH_MODULE = 'cach'; export const CACH_LOG_MESSAGE_HIT = 'cache hit'; export const CACH_LOG_MESSAGE_MISS = 'cache miss'; diff --git a/src/svrs/cach/diagnostics.ts b/src/svrs/cach/diagnostics.ts index b0ff14e..9140bec 100644 --- a/src/svrs/cach/diagnostics.ts +++ b/src/svrs/cach/diagnostics.ts @@ -13,7 +13,7 @@ import { type CacheEvent, type CacheEventType } from '$libs/cach'; -import { CACH_LOG_MESSAGE_BY_EVENT, LOGGER_CATEGORY } from './consts.ts'; +import { CACH_LOG_MESSAGE_BY_EVENT, CACH_MODULE } from './consts.ts'; export type CacheDiagnosticEvent = DiagnosticEvent; export type CacheDiagnostics = Diagnostics; @@ -39,14 +39,14 @@ function cacheLogLevel(event: CacheEvent | undefined) { export function createCacheDiagnostics(logger?: Logger): CacheDiagnostics { return createCatalogDiagnostics({ logger, - defaultCategory: LOGGER_CATEGORY, + defaultCategory: CACH_MODULE, catalog: CACH_DIAGNOSTIC_LOGS }); } export function emitCacheDiagnostic(diagnostics: CacheDiagnostics, event: CacheEvent): void { diagnostics.emit({ - artifact: LOGGER_CATEGORY, + artifact: CACH_MODULE, type: event.type, meta: event }); diff --git a/src/svrs/cach/index.ts b/src/svrs/cach/index.ts index a1c692d..a9cb252 100644 --- a/src/svrs/cach/index.ts +++ b/src/svrs/cach/index.ts @@ -28,7 +28,7 @@ export { CACH_METHOD_QUERY, CACH_METHOD_SET, CACH_METHOD_STATS, - LOGGER_CATEGORY + CACH_MODULE } from './consts.ts'; export { CachDisposedError, isCachDisposedError } from './errors.ts'; export { disposedCacheMessage } from './helpers.ts'; diff --git a/src/svrs/perm/consts.ts b/src/svrs/perm/consts.ts index 2f131f7..b7ad3bc 100644 --- a/src/svrs/perm/consts.ts +++ b/src/svrs/perm/consts.ts @@ -1,4 +1,4 @@ -export { PERM_LOGGER_CATEGORY as LOGGER_CATEGORY } from '$libs/svrs/perm'; +export { PERM_MODULE } from '$libs/svrs/perm'; export const PERM_DIAGNOSTIC_EVENTS = { DECISION: 'perm.server.decision', diff --git a/src/svrs/perm/diagnostics.ts b/src/svrs/perm/diagnostics.ts index 9b22213..13da26c 100644 --- a/src/svrs/perm/diagnostics.ts +++ b/src/svrs/perm/diagnostics.ts @@ -7,7 +7,7 @@ import { } from '$libs/logr'; import type { PermissionCheckInput, PermissionDecision } from '$libs/perm'; import { - LOGGER_CATEGORY, + PERM_MODULE, PERM_DIAGNOSTIC_EVENTS, PERM_LOG_MSG_DECISION, PERM_LOG_MSG_DENIED, @@ -50,7 +50,7 @@ export function createPermissionDiagnostics( ): PermissionDiagnostics { return createCatalogDiagnostics({ logger, - defaultCategory: LOGGER_CATEGORY, + defaultCategory: PERM_MODULE, catalog: PERM_DIAGNOSTIC_LOGS }); } @@ -61,7 +61,7 @@ export function emitPermissionDiagnostic( meta: PermissionDiagnosticMeta ): void { diagnostics.emit({ - artifact: LOGGER_CATEGORY, + artifact: PERM_MODULE, type, meta }); diff --git a/src/svrs/perm/index.ts b/src/svrs/perm/index.ts index 9895537..0444337 100644 --- a/src/svrs/perm/index.ts +++ b/src/svrs/perm/index.ts @@ -9,7 +9,7 @@ export { } from './database-repository.ts'; export { - LOGGER_CATEGORY, + PERM_MODULE, PERM_CONTEXT_KEYS, PERM_DB_DEFAULT_NAMESPACE, PERM_DB_POLICY_STATUSES,