Replace LOGGER_CATEGORY with <MOD>_MODULE single source of truth

Phase 2B.1 of the convention pass. Establishes one canonical constant
per module — `<MOD>_MODULE = '<alias>'` — as the single source for the
module's identifier across logger category, error message prefixes,
event scopes, and any other place the module's name is needed.

What changed:

1. Renamed all `<MOD>_LOG_CATEGORY` constants to `<MOD>_MODULE` (the
   value semantics didn't change; only the name). Affected modules:
   buss, conn, sess, perm (libs+arts+svrs), timr, lang, auth, http,
   sium, cach, stor, aapp (libs+arts), and the four fmts sub-modules
   (fmts, fmts.curr, fmts.dates, fmts.nums, fmts.unts).

2. Aligned values with the 4-letter alias where they didn't already:
   - STOR_MODULE: 'storage' → 'stor'
   - FMTS_MODULE: 'formats' → 'fmts'
   - FMTS_CURR_MODULE: 'formats.currency' → 'fmts.curr'
   - FMTS_DATES_MODULE: 'formats.dates' → 'fmts.dates'
   - FMTS_NUMS_MODULE: 'formats.numbers' → 'fmts.nums'
   - FMTS_UNTS_MODULE: 'formats.units' → 'fmts.unts'

3. Unified the duplicate `AAPP_MODULE` declaration: arts/aapp/consts.ts
   now re-exports from libs/aapp/consts.ts (canonical source). Both
   files used to declare it independently with different values
   ('app' vs 'aapp').

4. Replaced hardcoded `'[<alias>] ...'` literals in error messages
   with template strings using `<MOD>_MODULE`. Every error-message
   constant now derives the prefix from the module identifier instead
   of hardcoding it. Affected files: libs/aapp/consts.ts, arts/aapp/consts.ts,
   libs/buss/consts.ts, libs/lang/errors.ts, arts/stor/errors.ts,
   arts/sium/errors.ts, arts/fmts/errors.ts, and the ERROR_PREFIX
   constants in arts/conn, arts/sess, arts/http, arts/timr.

5. Updated diagnostic event values to use the new module aliases:
   - STOR_DIAGNOSTIC_EVENTS.ERROR: 'storage.error' → 'stor.error'
   - All FMTS_*_DIAGNOSTIC_EVENTS values to use 'fmts.X.*'

6. Updated tests that asserted against the old values (storage-integration.test
   and fmts/curr/test/barrel.test).

7. Updated docs/conventions.md: replaced the LOG_CATEGORY category
   with the new MODULE category. Added the rule that ERROR_MSG values
   must use the template `[${<MOD>_MODULE}]`, never a hardcoded literal.

Verification: svelte-check 1395 / 0 errors. Server 1230 tests, client
19 tests — all green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
master
dev 5 months ago
parent 14fa92d38c
commit a01ef0f63d

@ -59,7 +59,7 @@ PERM_METHOD_CHECK
TIMR_STATE_PENDING TIMR_STATE_PENDING
CONN_REASON_AUTH_FAILED CONN_REASON_AUTH_FAILED
CACH_LIMIT_DEFAULT_MAX_ENTRIES CACH_LIMIT_DEFAULT_MAX_ENTRIES
STOR_LOG_CATEGORY STOR_MODULE
// bad (will be flagged in audit) // bad (will be flagged in audit)
BUS_DIAGNOSTIC_EVENTS // wrong module prefix (rule 1) BUS_DIAGNOSTIC_EVENTS // wrong module prefix (rule 1)
@ -94,6 +94,7 @@ inside a module.
| Category | Use | | 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 `<MOD>_MODULE = '<alias>'`. |
| `ERR` | Error codes (`ErrCode` values from `$libs/errs`) | | `ERR` | Error codes (`ErrCode` values from `$libs/errs`) |
| `EVENT` | Bus or lifecycle event names (string discriminators) | | `EVENT` | Bus or lifecycle event names (string discriminators) |
| `DIAGNOSTIC_EVENTS` | Event values published through `Logger` (catalog object) | | `DIAGNOSTIC_EVENTS` | Event values published through `Logger` (catalog object) |
@ -107,9 +108,8 @@ inside a module.
| `DEFAULT` | Default values for options | | `DEFAULT` | Default values for options |
| `LIMIT` | Maximum / minimum values | | `LIMIT` | Maximum / minimum values |
| `ID_PREFIX` | Prefix used by ID factories | | `ID_PREFIX` | Prefix used by ID factories |
| `LOG_CATEGORY` | The logger category string |
| `LOG_MSG` | Log message strings | | `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 `<MOD>_MODULE` for the prefix, never a hardcoded literal: `` `[${MOD_MODULE}] ...` ``. |
| `ERROR_NAME` | Legacy `Error.name` strings (being replaced by `ERR` codes) | | `ERROR_NAME` | Legacy `Error.name` strings (being replaced by `ERR` codes) |
| `CONTEXT_KEY` | Svelte context keys | | `CONTEXT_KEY` | Svelte context keys |

@ -43,7 +43,7 @@ import {
APP_ORCHESTRATION_TRANSLATOR_IDENTITY, APP_ORCHESTRATION_TRANSLATOR_IDENTITY,
APP_ORCHESTRATION_TRANSLATOR_PERMISSIONS_REFRESH, APP_ORCHESTRATION_TRANSLATOR_PERMISSIONS_REFRESH,
APP_ORCHESTRATION_TRANSLATOR_TENANT_SWITCHED, APP_ORCHESTRATION_TRANSLATOR_TENANT_SWITCHED,
LOGGER_CATEGORY AAPP_MODULE
} from './consts.ts'; } from './consts.ts';
import { AappAlreadyCreatedError } from './errors.ts'; import { AappAlreadyCreatedError } from './errors.ts';
import type { import type {
@ -254,7 +254,7 @@ export function createActiveApp<S extends LangNode = LangNode>(
if (disposed) return; if (disposed) return;
disposed = true; disposed = true;
if (orchestration.has(APP_ORCHESTRATION_TRANSLATOR_DISPOSE)) { if (orchestration.has(APP_ORCHESTRATION_TRANSLATOR_DISPOSE)) {
publishAppDisposeStarting(Bus, { cause: LOGGER_CATEGORY }); publishAppDisposeStarting(Bus, { cause: AAPP_MODULE });
} }
Auth?.dispose(); Auth?.dispose();
Auth = undefined; Auth = undefined;

@ -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 = export const APP_LOG_MSG_SESSION_CACHE_CLEAR_FAILED =
'session change cache clear failed'; 'session change cache clear failed';
export const APP_CONNECTION_CLOSE_REASON_IDENTITY_CLEARED = 'identity_cleared'; 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_NAME_ALREADY_CREATED = 'AappAlreadyCreatedError';
export const APP_ERROR_ALREADY_CREATED_SESSION = 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 = 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 = 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 = 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.`;

@ -7,7 +7,7 @@ export {
APP_ORCHESTRATION_TRANSLATOR_IDENTITY, APP_ORCHESTRATION_TRANSLATOR_IDENTITY,
APP_ORCHESTRATION_TRANSLATOR_PERMISSIONS_REFRESH, APP_ORCHESTRATION_TRANSLATOR_PERMISSIONS_REFRESH,
APP_ORCHESTRATION_TRANSLATOR_TENANT_SWITCHED, APP_ORCHESTRATION_TRANSLATOR_TENANT_SWITCHED,
LOGGER_CATEGORY AAPP_MODULE
} from './consts'; } from './consts';
export { AappAlreadyCreatedError, isAappAlreadyCreatedError } from './errors'; export { AappAlreadyCreatedError, isAappAlreadyCreatedError } from './errors';
export type { export type {

@ -19,7 +19,7 @@ import {
} from '$sess/consts'; } from '$sess/consts';
import type { SessEventMap, SessLifecyclePayload, SessionEvent } from '$sess/types'; import type { SessEventMap, SessLifecyclePayload, SessionEvent } from '$sess/types';
import type { EngineBus } from '$libs/buss'; import type { EngineBus } from '$libs/buss';
import { LOGGER_CATEGORY } from '../consts.ts'; import { AAPP_MODULE } from '../consts.ts';
type SessionTranslatorBusEvents = AppEventMap & SessEventMap; type SessionTranslatorBusEvents = AppEventMap & SessEventMap;
@ -48,7 +48,7 @@ export function publishAppIdentityFromSessionLifecycleEvent(
cause cause
}, },
{ {
source: LOGGER_CATEGORY source: AAPP_MODULE
} }
); );
} }

@ -61,7 +61,7 @@ describe('App.Storage', () => {
storage: { adapter: broken } storage: { adapter: broken }
}); });
App.Storage.entry('x', 'd').set('v'); 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(); App.dispose();
}); });
}); });

@ -12,7 +12,7 @@ export {
AUTH_STORAGE_KEYS AUTH_STORAGE_KEYS
} from '$libs/auth/consts'; } from '$libs/auth/consts';
export const LOGGER_CATEGORY = 'auth'; export const AUTH_MODULE = 'auth';
export const AUTH_CLIENT_DIAGNOSTIC_EVENTS = { export const AUTH_CLIENT_DIAGNOSTIC_EVENTS = {
OPERATION_FAILED: 'auth.client.operation_failed', OPERATION_FAILED: 'auth.client.operation_failed',

@ -10,7 +10,7 @@ import {
AUTH_CLIENT_DIAGNOSTIC_EVENTS, AUTH_CLIENT_DIAGNOSTIC_EVENTS,
AUTH_CLIENT_LOG_MESSAGE_CACHE_INVALIDATION_FAILED, AUTH_CLIENT_LOG_MESSAGE_CACHE_INVALIDATION_FAILED,
AUTH_CLIENT_LOG_MESSAGE_OPERATION_FAILED, AUTH_CLIENT_LOG_MESSAGE_OPERATION_FAILED,
LOGGER_CATEGORY AUTH_MODULE
} from './consts.ts'; } from './consts.ts';
import type { AuthEventName } from '$libs/auth/types'; import type { AuthEventName } from '$libs/auth/types';
@ -43,7 +43,7 @@ const AUTH_CLIENT_DIAGNOSTIC_LOGS: DiagnosticCatalog<AuthClientDiagnosticEvent>
export function createAuthClientDiagnostics(logger?: Logger): AuthClientDiagnostics { export function createAuthClientDiagnostics(logger?: Logger): AuthClientDiagnostics {
return createCatalogDiagnostics({ return createCatalogDiagnostics({
logger, logger,
defaultCategory: LOGGER_CATEGORY, defaultCategory: AUTH_MODULE,
catalog: AUTH_CLIENT_DIAGNOSTIC_LOGS catalog: AUTH_CLIENT_DIAGNOSTIC_LOGS
}); });
} }
@ -54,7 +54,7 @@ export function emitAuthClientDiagnostic(
meta: AuthClientDiagnosticMeta meta: AuthClientDiagnosticMeta
): void { ): void {
diagnostics.emit({ diagnostics.emit({
artifact: LOGGER_CATEGORY, artifact: AUTH_MODULE,
type, type,
meta meta
}); });

@ -36,7 +36,7 @@ export {
AUTH_SAFE_MESSAGES, AUTH_SAFE_MESSAGES,
AUTH_SESSION_STATUSES, AUTH_SESSION_STATUSES,
AUTH_STORAGE_KEYS, AUTH_STORAGE_KEYS,
LOGGER_CATEGORY AUTH_MODULE
} from './consts.ts'; } from './consts.ts';
export { createAuthClientDiagnostics, emitAuthClientDiagnostic } from './diagnostics.ts'; export { createAuthClientDiagnostics, emitAuthClientDiagnostic } from './diagnostics.ts';
export { export {

@ -1,3 +1,5 @@
import { CACH_MODULE } from '$svrs/cach';
export { export {
CACH_ERROR_MSG_DISPOSED_SUFFIX, CACH_ERROR_MSG_DISPOSED_SUFFIX,
CACH_ERROR_NAME_DISPOSED, CACH_ERROR_NAME_DISPOSED,
@ -26,7 +28,7 @@ export {
CACH_METHOD_QUERY, CACH_METHOD_QUERY,
CACH_METHOD_SET, CACH_METHOD_SET,
CACH_METHOD_STATS, CACH_METHOD_STATS,
LOGGER_CATEGORY CACH_MODULE
} from '$svrs/cach'; } from '$svrs/cach';
export const CACH_ACTIVE_STATUS_IDLE = 'idle'; 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_ACTIVE_LOG_MESSAGE_OPERATION_FAILED = 'active cache operation failed';
export const CACH_ERROR_MSG_ACTIVE_ENTRY_DISPOSED = 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_NONE = 'none';
export const CACH_AUTO_INVALIDATE_STANDARD = 'standard'; export const CACH_AUTO_INVALIDATE_STANDARD = 'standard';

@ -10,7 +10,7 @@ import type { CacheKey } from '$libs/cach';
import { import {
CACH_ACTIVE_DIAGNOSTIC_EVENTS, CACH_ACTIVE_DIAGNOSTIC_EVENTS,
CACH_ACTIVE_LOG_MESSAGE_OPERATION_FAILED, CACH_ACTIVE_LOG_MESSAGE_OPERATION_FAILED,
LOGGER_CATEGORY CACH_MODULE
} from './consts.ts'; } from './consts.ts';
export type ActiveCacheDiagnosticType = export type ActiveCacheDiagnosticType =
@ -38,7 +38,7 @@ const ACTIVE_CACHE_DIAGNOSTIC_LOGS: DiagnosticCatalog<ActiveCacheDiagnosticEvent
export function createActiveCacheDiagnostics(logger?: Logger): ActiveCacheDiagnostics { export function createActiveCacheDiagnostics(logger?: Logger): ActiveCacheDiagnostics {
return createCatalogDiagnostics({ return createCatalogDiagnostics({
logger, logger,
defaultCategory: LOGGER_CATEGORY, defaultCategory: CACH_MODULE,
catalog: ACTIVE_CACHE_DIAGNOSTIC_LOGS catalog: ACTIVE_CACHE_DIAGNOSTIC_LOGS
}); });
} }
@ -49,7 +49,7 @@ export function emitActiveCacheDiagnostic(
meta: ActiveCacheDiagnosticMeta meta: ActiveCacheDiagnosticMeta
): void { ): void {
diagnostics.emit({ diagnostics.emit({
artifact: LOGGER_CATEGORY, artifact: CACH_MODULE,
type, type,
meta meta
}); });

@ -49,7 +49,7 @@ export {
CACH_METHOD_QUERY, CACH_METHOD_QUERY,
CACH_METHOD_SET, CACH_METHOD_SET,
CACH_METHOD_STATS, CACH_METHOD_STATS,
LOGGER_CATEGORY CACH_MODULE
} from './consts.ts'; } from './consts.ts';
export { createActiveCacheDiagnostics, emitActiveCacheDiagnostic } from './diagnostics.ts'; export { createActiveCacheDiagnostics, emitActiveCacheDiagnostic } from './diagnostics.ts';
export { export {

@ -1,4 +1,4 @@
export const LOGGER_CATEGORY = 'conn'; export const CONN_MODULE = 'conn';
export const LOGGER_SCOPE_SEPARATOR = ':'; export const LOGGER_SCOPE_SEPARATOR = ':';
export const CONN_DIAGNOSTIC_EVENTS = { export const CONN_DIAGNOSTIC_EVENTS = {
@ -215,7 +215,7 @@ export const LOG_MSG_SESSION_EXPIRED = 'session expired; disconnecting connectio
export const LOG_MSG_SESSION_REFRESHED = 'session refreshed; reauthenticating connection'; export const LOG_MSG_SESSION_REFRESHED = 'session refreshed; reauthenticating connection';
export const LOG_MSG_BROWSER_RECONNECT = 'browser lifecycle reconnect requested'; export const LOG_MSG_BROWSER_RECONNECT = 'browser lifecycle reconnect requested';
export const ERROR_PREFIX = '[conn] '; export const ERROR_PREFIX = `[${CONN_MODULE}] `;
export const ERROR_NAME_DISPOSED = 'ConnDisposedError'; export const ERROR_NAME_DISPOSED = 'ConnDisposedError';
export const ERROR_NAME_ALREADY_EXISTS = 'ConnConnectionAlreadyExistsError'; export const ERROR_NAME_ALREADY_EXISTS = 'ConnConnectionAlreadyExistsError';
export const ERROR_NAME_NOT_FOUND = 'ConnConnectionNotFoundError'; export const ERROR_NAME_NOT_FOUND = 'ConnConnectionNotFoundError';

@ -8,7 +8,7 @@ import {
import { import {
CONN_DIAGNOSTIC_EVENTS, CONN_DIAGNOSTIC_EVENTS,
CONN_EVENT_MESSAGE, CONN_EVENT_MESSAGE,
LOGGER_CATEGORY, CONN_MODULE,
LOG_MSG_AUTH_FAILED, LOG_MSG_AUTH_FAILED,
LOG_MSG_BROWSER_RECONNECT, LOG_MSG_BROWSER_RECONNECT,
LOG_MSG_CONNECT_FAILED, LOG_MSG_CONNECT_FAILED,
@ -120,7 +120,7 @@ export function emitConnectionDiagnostic(
meta?: unknown meta?: unknown
): void { ): void {
diagnostics.emit({ diagnostics.emit({
artifact: LOGGER_CATEGORY, artifact: CONN_MODULE,
type, type,
meta meta
}); });
@ -133,7 +133,7 @@ export function emitScopedConnectionDiagnostic(
meta?: unknown meta?: unknown
): void { ): void {
diagnostics.emit({ diagnostics.emit({
artifact: LOGGER_CATEGORY, artifact: CONN_MODULE,
scope, scope,
type, type,
meta meta

@ -8,7 +8,7 @@ import {
ERROR_PREFIX, ERROR_PREFIX,
CONN_ID_PREFIX, CONN_ID_PREFIX,
CONN_ID_SEPARATOR, CONN_ID_SEPARATOR,
LOGGER_CATEGORY, CONN_MODULE,
LOGGER_SCOPE_SEPARATOR, LOGGER_SCOPE_SEPARATOR,
LOG_MSG_LISTENER_THREW_PREFIX LOG_MSG_LISTENER_THREW_PREFIX
} from './consts.ts'; } from './consts.ts';
@ -43,14 +43,14 @@ export function listenerThrewMessage(event: string): string {
export function loggerScope(name: string, topic?: string): string { export function loggerScope(name: string, topic?: string): string {
return topic === undefined return topic === undefined
? `${LOGGER_CATEGORY}${LOGGER_SCOPE_SEPARATOR}${name}` ? `${CONN_MODULE}${LOGGER_SCOPE_SEPARATOR}${name}`
: `${LOGGER_CATEGORY}${LOGGER_SCOPE_SEPARATOR}${name}${LOGGER_SCOPE_SEPARATOR}${topic}`; : `${CONN_MODULE}${LOGGER_SCOPE_SEPARATOR}${name}${LOGGER_SCOPE_SEPARATOR}${topic}`;
} }
export function timerKey(connection: string, kind: string, id?: string): string { export function timerKey(connection: string, kind: string, id?: string): string {
return id === undefined return id === undefined
? `${LOGGER_CATEGORY}${LOGGER_SCOPE_SEPARATOR}${connection}${LOGGER_SCOPE_SEPARATOR}${kind}` ? `${CONN_MODULE}${LOGGER_SCOPE_SEPARATOR}${connection}${LOGGER_SCOPE_SEPARATOR}${kind}`
: `${LOGGER_CATEGORY}${LOGGER_SCOPE_SEPARATOR}${connection}${LOGGER_SCOPE_SEPARATOR}${kind}${LOGGER_SCOPE_SEPARATOR}${id}`; : `${CONN_MODULE}${LOGGER_SCOPE_SEPARATOR}${connection}${LOGGER_SCOPE_SEPARATOR}${kind}${LOGGER_SCOPE_SEPARATOR}${id}`;
} }
export function createConnectionIdFactory(connectionName: string): () => string { export function createConnectionIdFactory(connectionName: string): () => string {

@ -1,3 +1,3 @@
export const LOGGER_CATEGORY = 'formats'; export const FMTS_MODULE = 'fmts';
export const DEFAULT_LOCALE = 'en-US'; export const DEFAULT_LOCALE = 'en-US';
export const AUTO_VALUE = 'auto'; export const AUTO_VALUE = 'auto';

@ -1,10 +1,10 @@
export const LOGGER_CATEGORY = 'formats.currency'; export const FMTS_CURR_MODULE = 'fmts.curr';
export const CURRENCY_DIAGNOSTIC_EVENTS = { export const CURRENCY_DIAGNOSTIC_EVENTS = {
RATES_PROVIDER_MISSING: 'formats.currency.rates_provider_missing', RATES_PROVIDER_MISSING: 'fmts.curr.rates_provider_missing',
RATE_NOT_AVAILABLE: 'formats.currency.rate_not_available', RATE_NOT_AVAILABLE: 'fmts.curr.rate_not_available',
INVALID_RATE: 'formats.currency.invalid_rate', INVALID_RATE: 'fmts.curr.invalid_rate',
RATE_FETCH_FAILED: 'formats.currency.rate_fetch_failed' RATE_FETCH_FAILED: 'fmts.curr.rate_fetch_failed'
} as const; } as const;
export const AUTO_CURRENCY = 'auto'; export const AUTO_CURRENCY = 'auto';

@ -6,7 +6,7 @@ import {
type Diagnostics, type Diagnostics,
type Logger type Logger
} from '$libs/logr'; } 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 { CURRENCY_ERRORS } from './errors';
import type { CurrencyCode } from './types'; import type { CurrencyCode } from './types';
@ -52,7 +52,7 @@ const CURRENCY_DIAGNOSTIC_LOGS: DiagnosticCatalog<CurrencyDiagnosticEvent> = {
export function createCurrencyDiagnostics(logger?: Logger): CurrencyDiagnostics { export function createCurrencyDiagnostics(logger?: Logger): CurrencyDiagnostics {
return createCatalogDiagnostics({ return createCatalogDiagnostics({
logger, logger,
defaultCategory: LOGGER_CATEGORY, defaultCategory: FMTS_CURR_MODULE,
catalog: CURRENCY_DIAGNOSTIC_LOGS catalog: CURRENCY_DIAGNOSTIC_LOGS
}); });
} }
@ -63,7 +63,7 @@ export function emitCurrencyDiagnostic(
meta: CurrencyDiagnosticMeta meta: CurrencyDiagnosticMeta
): void { ): void {
diagnostics.emit({ diagnostics.emit({
artifact: LOGGER_CATEGORY, artifact: FMTS_CURR_MODULE,
type, type,
meta meta
}); });

@ -1,15 +1,15 @@
export const CURRENCY_ERRORS = { export const CURRENCY_ERRORS = {
INVALID_CURRENCY: (currency: string): string => 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 => 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 => 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 => 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; } as const;

@ -3,7 +3,7 @@
// or locale currency tables they never reach. // or locale currency tables they never reach.
export { export {
LOGGER_CATEGORY, FMTS_CURR_MODULE,
AUTO_CURRENCY, AUTO_CURRENCY,
CURRENCY_DIAGNOSTIC_EVENTS, CURRENCY_DIAGNOSTIC_EVENTS,
DEFAULT_CURRENCY, DEFAULT_CURRENCY,

@ -3,7 +3,7 @@ import {
AUTO_CURRENCY, AUTO_CURRENCY,
CURRENCY_ERRORS, CURRENCY_ERRORS,
DEFAULT_CURRENCY, DEFAULT_CURRENCY,
LOGGER_CATEGORY, FMTS_CURR_MODULE,
createEngineCurrency, createEngineCurrency,
createRates, createRates,
resolveCurrency resolveCurrency
@ -14,9 +14,9 @@ describe('curr public barrel', () => {
expect(createEngineCurrency).toBeTypeOf('function'); expect(createEngineCurrency).toBeTypeOf('function');
expect(createRates).toBeTypeOf('function'); expect(createRates).toBeTypeOf('function');
expect(resolveCurrency).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(AUTO_CURRENCY).toBe('auto');
expect(DEFAULT_CURRENCY).toBe('USD'); expect(DEFAULT_CURRENCY).toBe('USD');
expect(CURRENCY_ERRORS.RATES_PROVIDER_MISSING).toContain('[formats.currency]'); expect(CURRENCY_ERRORS.RATES_PROVIDER_MISSING).toContain('[fmts.curr]');
}); });
}); });

@ -3,7 +3,7 @@ import { createEngineLogger, LogLevel } from '$logr';
import { import {
AUTO_CURRENCY, AUTO_CURRENCY,
CURRENCY_ERRORS, CURRENCY_ERRORS,
LOGGER_CATEGORY, FMTS_CURR_MODULE,
createEngineCurrency, createEngineCurrency,
createRates, createRates,
type EngineCurrency type EngineCurrency
@ -79,7 +79,7 @@ describe('createEngineCurrency()', () => {
await expect(curr.convert(10, 'USD')).resolves.toBeUndefined(); 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).toHaveLength(1);
expect(logs[0].message).toBe(CURRENCY_ERRORS.RATES_PROVIDER_MISSING); expect(logs[0].message).toBe(CURRENCY_ERRORS.RATES_PROVIDER_MISSING);
}); });

@ -1,6 +1,6 @@
import { describe, expect, it, vi } from 'vitest'; import { describe, expect, it, vi } from 'vitest';
import { createEngineLogger, LogLevel } from '$logr'; import { createEngineLogger, LogLevel } from '$logr';
import { CURRENCY_ERRORS, LOGGER_CATEGORY, createRates } from '..'; import { CURRENCY_ERRORS, FMTS_CURR_MODULE, createRates } from '..';
describe('createRates()', () => { describe('createRates()', () => {
it('caches direct and inverse rates', async () => { 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('EUR', 'USD')).resolves.toBeUndefined();
await expect(rates.getRate('USD', 'EUR')).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) CURRENCY_ERRORS.INVALID_RATE('EUR', 'USD', 0)
); );
}); });

@ -1 +1 @@
export const LOGGER_CATEGORY = 'formats.dates'; export const FMTS_DATES_MODULE = 'fmts.dates';

@ -1,4 +1,4 @@
export { LOGGER_CATEGORY } from './consts'; export { FMTS_DATES_MODULE } from './consts';
export { createActiveDates } from './active-dates.svelte'; export { createActiveDates } from './active-dates.svelte';
export { createEngineDates } from './engine-dates'; export { createEngineDates } from './engine-dates';
export type { export type {

@ -1,3 +1,5 @@
import { FMTS_MODULE } from './consts.ts';
export const FORMATS_ERRORS = { 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; } as const;

@ -4,7 +4,7 @@
// `App.Formats.currency.format(...)` style; with `sideEffects: false` in // `App.Formats.currency.format(...)` style; with `sideEffects: false` in
// package.json the namespace pattern still tree-shakes member access. // 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 { createEngineFormats } from './engine-formats';
export { createActiveFormats } from './active-formats.svelte'; export { createActiveFormats } from './active-formats.svelte';
export { FORMATS_ERRORS } from './errors'; export { FORMATS_ERRORS } from './errors';

@ -1 +1 @@
export const LOGGER_CATEGORY = 'formats.numbers'; export const FMTS_NUMS_MODULE = 'fmts.nums';

@ -1,4 +1,4 @@
export { LOGGER_CATEGORY } from './consts'; export { FMTS_NUMS_MODULE } from './consts';
export { createActiveNumbers } from './active-numbers.svelte'; export { createActiveNumbers } from './active-numbers.svelte';
export { createEngineNumbers } from './engine-numbers'; export { createEngineNumbers } from './engine-numbers';
export type { export type {

@ -1,3 +1,3 @@
export const LOGGER_CATEGORY = 'formats.units'; export const FMTS_UNTS_MODULE = 'fmts.unts';
export const AUTO_UNIT_SYSTEM = 'auto'; export const AUTO_UNIT_SYSTEM = 'auto';

@ -1,11 +1,11 @@
export const UNITS_ERRORS = { 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 => 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 => 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; } as const;
export const UNITS_ERROR_NAMES = { export const UNITS_ERROR_NAMES = {

@ -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 { createActiveUnits } from './active-units.svelte';
export { createEngineUnits } from './engine-units'; export { createEngineUnits } from './engine-units';
export { convert } from './conversions'; export { convert } from './conversions';

@ -15,8 +15,8 @@ import {
} from '$libs/http'; } from '$libs/http';
/** Logger category emitted by the engine. */ /** Logger category emitted by the engine. */
export const LOGGER_CATEGORY = 'http'; export const HTTP_MODULE = 'http';
export const ERROR_PREFIX = '[http] '; export const ERROR_PREFIX = `[${HTTP_MODULE}] `;
/** HTTP statuses with no body — `parseBody` returns `undefined` for these. */ /** HTTP statuses with no body — `parseBody` returns `undefined` for these. */
export const NULL_BODY_STATUSES = HTTP_NULL_BODY_STATUSES; export const NULL_BODY_STATUSES = HTTP_NULL_BODY_STATUSES;

@ -9,7 +9,7 @@ import {
import { import {
HTTP_DIAGNOSTIC_EVENTS, HTTP_DIAGNOSTIC_EVENTS,
HTTP_METHOD_GET, HTTP_METHOD_GET,
LOGGER_CATEGORY, HTTP_MODULE,
bodySchemaRejectedLogMessage, bodySchemaRejectedLogMessage,
httpStatusLogMessage, httpStatusLogMessage,
networkErrorLogMessage, networkErrorLogMessage,
@ -81,13 +81,13 @@ function methodOf(event: HttpDiagnosticEvent): HttpMethod {
} }
function urlOf(event: HttpDiagnosticEvent): string { function urlOf(event: HttpDiagnosticEvent): string {
return event.meta?.url ?? LOGGER_CATEGORY; return event.meta?.url ?? HTTP_MODULE;
} }
export function createHttpDiagnostics(logger?: Logger): HttpDiagnostics { export function createHttpDiagnostics(logger?: Logger): HttpDiagnostics {
return createCatalogDiagnostics({ return createCatalogDiagnostics({
logger, logger,
defaultCategory: LOGGER_CATEGORY, defaultCategory: HTTP_MODULE,
catalog: HTTP_DIAGNOSTIC_LOGS catalog: HTTP_DIAGNOSTIC_LOGS
}); });
} }
@ -98,7 +98,7 @@ export function emitHttpDiagnostic(
meta: HttpDiagnosticMeta meta: HttpDiagnosticMeta
): void { ): void {
diagnostics.emit({ diagnostics.emit({
artifact: LOGGER_CATEGORY, artifact: HTTP_MODULE,
type, type,
meta meta
}); });

@ -6,7 +6,7 @@ export { createEngineHttp } from './engine-http.ts';
export { createHttpDiagnostics, emitHttpDiagnostic } from './diagnostics.ts'; export { createHttpDiagnostics, emitHttpDiagnostic } from './diagnostics.ts';
export { export {
LOGGER_CATEGORY, HTTP_MODULE,
NULL_BODY_STATUSES, NULL_BODY_STATUSES,
DEFAULT_RETRY_METHODS, DEFAULT_RETRY_METHODS,
DEFAULT_RETRY_STATUSES, DEFAULT_RETRY_STATUSES,

@ -27,7 +27,7 @@ export {
LANG_DIAGNOSTIC_EVENTS, LANG_DIAGNOSTIC_EVENTS,
LANG_ERRORS, LANG_ERRORS,
langNodeToJSON, langNodeToJSON,
LOGGER_CATEGORY, LANG_MODULE,
makeLangRecord, makeLangRecord,
MAX_RESOLVE_DEPTH, MAX_RESOLVE_DEPTH,
MONO_LANG_CATEGORY, MONO_LANG_CATEGORY,

@ -7,7 +7,7 @@ export {
PERM_CLIENT_KEY_GLOBAL, PERM_CLIENT_KEY_GLOBAL,
PERM_CLIENT_KEY_NONE, PERM_CLIENT_KEY_NONE,
PERM_CLIENT_KEY_SEPARATOR, PERM_CLIENT_KEY_SEPARATOR,
PERM_LOGGER_CATEGORY as LOGGER_CATEGORY, PERM_MODULE,
PERM_HTTP_CREDENTIALS_INCLUDE, PERM_HTTP_CREDENTIALS_INCLUDE,
PERM_HTTP_STATUS_BAD_REQUEST, PERM_HTTP_STATUS_BAD_REQUEST,
PERM_HTTP_STATUS_FORBIDDEN, PERM_HTTP_STATUS_FORBIDDEN,

@ -6,7 +6,7 @@ import {
type Diagnostics type Diagnostics
} from '$libs/logr'; } from '$libs/logr';
import { import {
LOGGER_CATEGORY, PERM_MODULE,
PERM_CLIENT_DIAGNOSTIC_EVENTS, PERM_CLIENT_DIAGNOSTIC_EVENTS,
PERM_LOG_MSG_REMOTE_BATCH_FAILED, PERM_LOG_MSG_REMOTE_BATCH_FAILED,
PERM_LOG_MSG_REMOTE_CHECK_FAILED, PERM_LOG_MSG_REMOTE_CHECK_FAILED,
@ -65,7 +65,7 @@ export function createPermissionClientDiagnostics(
): PermissionClientDiagnostics { ): PermissionClientDiagnostics {
return createCatalogDiagnostics({ return createCatalogDiagnostics({
logger, logger,
defaultCategory: LOGGER_CATEGORY, defaultCategory: PERM_MODULE,
catalog: PERM_CLIENT_DIAGNOSTIC_LOGS catalog: PERM_CLIENT_DIAGNOSTIC_LOGS
}); });
} }
@ -76,7 +76,7 @@ export function emitPermissionClientDiagnostic(
meta: PermissionClientDiagnosticMeta meta: PermissionClientDiagnosticMeta
): void { ): void {
diagnostics.emit({ diagnostics.emit({
artifact: LOGGER_CATEGORY, artifact: PERM_MODULE,
type, type,
meta meta
}); });

@ -9,7 +9,7 @@ export { disposedPermissionsMessage } from './helpers.ts';
export { permissionDecisionKey, stablePermissionStringify } from '$libs/svrs/perm'; export { permissionDecisionKey, stablePermissionStringify } from '$libs/svrs/perm';
export { export {
LOGGER_CATEGORY, PERM_MODULE,
PERM_AUTO_INVALIDATE_NONE, PERM_AUTO_INVALIDATE_NONE,
PERM_AUTO_INVALIDATE_PERMISSIONS_REFRESH, PERM_AUTO_INVALIDATE_PERMISSIONS_REFRESH,
PERM_AUTO_INVALIDATE_STANDARD, PERM_AUTO_INVALIDATE_STANDARD,

@ -11,7 +11,7 @@ import {
IDENTITY_ANONYMOUS, IDENTITY_ANONYMOUS,
IDENTITY_IDENTIFIED, IDENTITY_IDENTIFIED,
IDENTITY_NONE, IDENTITY_NONE,
LOGGER_CATEGORY SESS_MODULE
} from './consts.ts'; } from './consts.ts';
/** /**
@ -42,7 +42,7 @@ export function createActiveSession<TUser, TCredential = undefined, TData = unde
generation: change.generation, generation: change.generation,
identity: change.identity identity: change.identity
}, },
{ source: LOGGER_CATEGORY } { source: SESS_MODULE }
); );
} }
}); });

@ -11,7 +11,7 @@ import {
EVENT_INITIAL_SESSION, EVENT_INITIAL_SESSION,
EVENT_REFRESHED, EVENT_REFRESHED,
EVENT_REVOKED, EVENT_REVOKED,
LOGGER_CATEGORY, SESS_MODULE,
SESS_EVENT_CHANGED, SESS_EVENT_CHANGED,
SESS_EVENT_EXPIRED, SESS_EVENT_EXPIRED,
SESS_EVENT_IDENTITY_CHANGED, SESS_EVENT_IDENTITY_CHANGED,
@ -29,7 +29,7 @@ export function publishSessLifecycleEvent(
options: BusPublishOptions = {} options: BusPublishOptions = {}
): void { ): void {
if (payload.event === EVENT_INITIAL_SESSION) return; if (payload.event === EVENT_INITIAL_SESSION) return;
const publishOptions = { source: LOGGER_CATEGORY, ...options }; const publishOptions = { source: SESS_MODULE, ...options };
bus.publish(SESS_EVENT_CHANGED, payload, publishOptions); bus.publish(SESS_EVENT_CHANGED, payload, publishOptions);
if (payload.identity.from !== payload.identity.to) { if (payload.identity.from !== payload.identity.to) {

@ -1,5 +1,5 @@
/** Logger category emitted by the engine. */ /** Logger category emitted by the engine. */
export const LOGGER_CATEGORY = 'sess'; export const SESS_MODULE = 'sess';
export const SESS_DIAGNOSTIC_EVENTS = { export const SESS_DIAGNOSTIC_EVENTS = {
ADOPT_SERVER_INVALID: 'sess.adopt_server_invalid', ADOPT_SERVER_INVALID: 'sess.adopt_server_invalid',
@ -223,7 +223,7 @@ export const LOG_MSG_REVOKE_GLOBAL_HANDLER_FAILED =
// Prefixed `[sess]` to match the convention used by `arts/http` // Prefixed `[sess]` to match the convention used by `arts/http`
// (`[http] ...`) so log output and stack traces are searchable. // (`[http] ...`) so log output and stack traces are searchable.
export const ERROR_PREFIX = '[sess] '; export const ERROR_PREFIX = `[${SESS_MODULE}] `;
export const ERROR_NAME_DISPOSED = 'SessDisposedError'; export const ERROR_NAME_DISPOSED = 'SessDisposedError';
export const ERROR_NAME_ALREADY_CREATED = 'SessAlreadyCreatedError'; export const ERROR_NAME_ALREADY_CREATED = 'SessAlreadyCreatedError';
export const ERROR_NAME_INVALID_SESSION = 'SessInvalidSessionError'; export const ERROR_NAME_INVALID_SESSION = 'SessInvalidSessionError';

@ -7,7 +7,7 @@ import {
} from '$libs/logr'; } from '$libs/logr';
import { import {
EVENT_INITIAL_SESSION, EVENT_INITIAL_SESSION,
LOGGER_CATEGORY, SESS_MODULE,
LOG_MSG_REFRESH_ACTOR_SCHEMA_FAILED, LOG_MSG_REFRESH_ACTOR_SCHEMA_FAILED,
LOG_MSG_REFRESH_CREDENTIAL_SCHEMA_FAILED, LOG_MSG_REFRESH_CREDENTIAL_SCHEMA_FAILED,
LOG_MSG_REFRESH_DATA_SCHEMA_FAILED, LOG_MSG_REFRESH_DATA_SCHEMA_FAILED,
@ -105,7 +105,7 @@ const SESS_DIAGNOSTIC_LOGS: DiagnosticCatalog<SessionDiagnosticEvent> = {
function adapterName(meta: SessionDiagnosticMeta | undefined): string { function adapterName(meta: SessionDiagnosticMeta | undefined): string {
if (meta !== undefined && 'adapterName' in meta) return meta.adapterName; if (meta !== undefined && 'adapterName' in meta) return meta.adapterName;
return LOGGER_CATEGORY; return SESS_MODULE;
} }
function invariantName(meta: SessionDiagnosticMeta | undefined): AdoptInvariant { function invariantName(meta: SessionDiagnosticMeta | undefined): AdoptInvariant {
@ -115,7 +115,7 @@ function invariantName(meta: SessionDiagnosticMeta | undefined): AdoptInvariant
function methodName(meta: SessionDiagnosticMeta | undefined): string { function methodName(meta: SessionDiagnosticMeta | undefined): string {
if (meta !== undefined && 'method' in meta) return meta.method; if (meta !== undefined && 'method' in meta) return meta.method;
return LOGGER_CATEGORY; return SESS_MODULE;
} }
function sessionEventName(meta: SessionDiagnosticMeta | undefined): string { function sessionEventName(meta: SessionDiagnosticMeta | undefined): string {
@ -128,7 +128,7 @@ export function createSessionDiagnostics(
): SessionDiagnostics { ): SessionDiagnostics {
return createCatalogDiagnostics({ return createCatalogDiagnostics({
logger, logger,
defaultCategory: LOGGER_CATEGORY, defaultCategory: SESS_MODULE,
catalog: SESS_DIAGNOSTIC_LOGS catalog: SESS_DIAGNOSTIC_LOGS
}); });
} }
@ -139,7 +139,7 @@ export function emitSessionDiagnostic(
meta: SessionDiagnosticMeta meta: SessionDiagnosticMeta
): void { ): void {
diagnostics.emit({ diagnostics.emit({
artifact: LOGGER_CATEGORY, artifact: SESS_MODULE,
type, type,
meta meta
}); });

@ -14,7 +14,7 @@ import {
FIELD_ACTOR, FIELD_ACTOR,
FIELD_CREDENTIAL, FIELD_CREDENTIAL,
FIELD_DATA, FIELD_DATA,
LOGGER_CATEGORY, SESS_MODULE,
REFRESH_STATUS_SKIPPED, REFRESH_STATUS_SKIPPED,
REVOKE_REASON_NO_SESSION, REVOKE_REASON_NO_SESSION,
REVOKE_SCOPE_LOCAL, REVOKE_SCOPE_LOCAL,
@ -99,7 +99,7 @@ export function createEngineSession<TUser, TCredential = undefined, TData = unde
generation: change.generation, generation: change.generation,
identity: change.identity identity: change.identity
}, },
{ source: LOGGER_CATEGORY } { source: SESS_MODULE }
); );
}); });
detachers.push(detachBus); detachers.push(detachBus);

@ -26,7 +26,7 @@ export {
DEFAULT_AUTO_REFRESH_MARGIN_MS, DEFAULT_AUTO_REFRESH_MARGIN_MS,
DEFAULT_AUTO_REFRESH_TICK_MS, DEFAULT_AUTO_REFRESH_TICK_MS,
DEFAULT_BROADCAST_CHANNEL, DEFAULT_BROADCAST_CHANNEL,
LOGGER_CATEGORY, SESS_MODULE,
SESS_EVENT_CHANGED, SESS_EVENT_CHANGED,
SESS_EVENT_EXPIRED, SESS_EVENT_EXPIRED,
SESS_EVENT_IDENTITY_CHANGED, SESS_EVENT_IDENTITY_CHANGED,

@ -1,4 +1,4 @@
export const LOGGER_CATEGORY = 'sium'; export const SIUM_MODULE = 'sium';
export const SIUM_STANDARD_VENDOR = 'sium'; export const SIUM_STANDARD_VENDOR = 'sium';
export const SIUM_DIAGNOSTIC_EVENTS = { export const SIUM_DIAGNOSTIC_EVENTS = {

@ -6,7 +6,7 @@ import {
type Diagnostics, type Diagnostics,
type Logger type Logger
} from '$libs/logr'; } from '$libs/logr';
import { LOGGER_CATEGORY, SIUM_DIAGNOSTIC_EVENTS } from './consts'; import { SIUM_MODULE, SIUM_DIAGNOSTIC_EVENTS } from './consts';
import { SIUM_ERRORS } from './errors'; import { SIUM_ERRORS } from './errors';
import type { Issue } from './core'; import type { Issue } from './core';
@ -54,7 +54,7 @@ export function issueDiagnosticMeta(issues: ReadonlyArray<Issue>): SiumDiagnosti
export function createSiumDiagnostics(logger?: Logger): SiumDiagnostics { export function createSiumDiagnostics(logger?: Logger): SiumDiagnostics {
return createCatalogDiagnostics({ return createCatalogDiagnostics({
logger, logger,
defaultCategory: LOGGER_CATEGORY, defaultCategory: SIUM_MODULE,
catalog: SIUM_DIAGNOSTIC_LOGS catalog: SIUM_DIAGNOSTIC_LOGS
}); });
} }
@ -65,7 +65,7 @@ export function emitSiumDiagnostic(
meta: SiumDiagnosticMeta meta: SiumDiagnosticMeta
): void { ): void {
diagnostics.emit({ diagnostics.emit({
artifact: LOGGER_CATEGORY, artifact: SIUM_MODULE,
type, type,
meta meta
}); });

@ -1,6 +1,8 @@
import { SIUM_MODULE } from './consts.ts';
export const SIUM_ERRORS = { export const SIUM_ERRORS = {
VALIDATION_FAILED: '[sium] Validation failed.', VALIDATION_FAILED: `[${SIUM_MODULE}] Validation failed.`,
RESOLVE_FALLBACK: '[sium] Falling back while resolving Sium message.', RESOLVE_FALLBACK: `[${SIUM_MODULE}] Falling back while resolving Sium message.`,
OBJECT_ENCODE_EXPECTS_PLAIN_OBJECT: 'object().encode expects a plain object value', OBJECT_ENCODE_EXPECTS_PLAIN_OBJECT: 'object().encode expects a plain object value',
ARRAY_ENCODE_EXPECTS_ARRAY: 'array().encode expects an array value', ARRAY_ENCODE_EXPECTS_ARRAY: 'array().encode expects an array value',
LAZY_RESOLVING_ACCESS: LAZY_RESOLVING_ACCESS:

@ -8,7 +8,7 @@ export { createEngineSium } from './engine-sium';
export type { EngineSium, EngineSiumOptions } from './engine-sium'; export type { EngineSium, EngineSiumOptions } from './engine-sium';
export { createSiumDiagnostics, emitSiumDiagnostic, issueDiagnosticMeta } from './diagnostics'; 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'; export { SIUM_ERRORS } from './errors';
// core // core

@ -1,7 +1,7 @@
import { describe, expect, expectTypeOf, it } from 'vitest'; import { describe, expect, expectTypeOf, it } from 'vitest';
import { createEngineLang } from '$lang'; import { createEngineLang } from '$lang';
import { createEngineLogger, LogLevel } from '$logr'; 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 type { Issue, Schema } from '../core';
import { siumLangs } from '../langs'; import { siumLangs } from '../langs';
@ -86,7 +86,7 @@ describe('createEngineSium()', () => {
const result = await sium.validate(schema, 'A'); const result = await sium.validate(schema, 'A');
expect(result.ok).toBe(false); 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).toHaveLength(1);
expect(logs[0].message).toBe(SIUM_ERRORS.VALIDATION_FAILED); expect(logs[0].message).toBe(SIUM_ERRORS.VALIDATION_FAILED);
expect(logs[0].context).toMatchObject({ expect(logs[0].context).toMatchObject({
@ -108,7 +108,7 @@ describe('createEngineSium()', () => {
const result = sium.validateSync(schema, 'A'); const result = sium.validateSync(schema, 'A');
expect(result.ok).toBe(false); 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 () => { 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' }); 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);
}); });
}); });

@ -3,7 +3,7 @@
* Consumers (typically `aapp`) override the handler to route through their * Consumers (typically `aapp`) override the handler to route through their
* own logger and may pick a different category there. * 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_READ = 'read';
export const STOR_OP_WRITE = 'write'; 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 ENVELOPE_ERROR_VERSION_NOT_NUMBER = 'envelope.v not a number';
export const STOR_DIAGNOSTIC_EVENTS = { export const STOR_DIAGNOSTIC_EVENTS = {
ERROR: 'storage.error' ERROR: 'stor.error'
} as const; } as const;
export const defaultStorageErrorMessage = (op: string, fullKey: string): string => export const defaultStorageErrorMessage = (op: string, fullKey: string): string =>
`[${LOGGER_CATEGORY}] ${op} on "${fullKey}":`; `[${STOR_MODULE}] ${op} on "${fullKey}":`;

@ -6,7 +6,7 @@ import {
type Diagnostics, type Diagnostics,
type Logger type Logger
} from '$libs/logr'; } 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'; import type { StorageErrorContext } from './types';
export type StorageDiagnosticType = export type StorageDiagnosticType =
@ -19,7 +19,7 @@ const STOR_DIAGNOSTIC_LOGS: DiagnosticCatalog<StorageDiagnosticEvent> = {
[STOR_DIAGNOSTIC_EVENTS.ERROR]: (event) => ({ [STOR_DIAGNOSTIC_EVENTS.ERROR]: (event) => ({
level: LogLevel.WARN, level: LogLevel.WARN,
message: defaultStorageErrorMessage( message: defaultStorageErrorMessage(
event.meta?.op ?? LOGGER_CATEGORY, event.meta?.op ?? STOR_MODULE,
event.meta?.fullKey ?? '' event.meta?.fullKey ?? ''
) )
}) })
@ -28,7 +28,7 @@ const STOR_DIAGNOSTIC_LOGS: DiagnosticCatalog<StorageDiagnosticEvent> = {
export function createStorageDiagnostics(logger?: Logger): StorageDiagnostics { export function createStorageDiagnostics(logger?: Logger): StorageDiagnostics {
return createCatalogDiagnostics({ return createCatalogDiagnostics({
logger, logger,
defaultCategory: LOGGER_CATEGORY, defaultCategory: STOR_MODULE,
catalog: STOR_DIAGNOSTIC_LOGS catalog: STOR_DIAGNOSTIC_LOGS
}); });
} }
@ -39,7 +39,7 @@ export function emitStorageDiagnostic(
meta: StorageErrorContext meta: StorageErrorContext
): void { ): void {
diagnostics.emit({ diagnostics.emit({
artifact: LOGGER_CATEGORY, artifact: STOR_MODULE,
type, type,
meta meta
}); });

@ -1,31 +1,33 @@
import { STOR_MODULE } from './consts.ts';
export const STOR_ERRORS = { export const STOR_ERRORS = {
UNDEFINED_DEFAULT: 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 => 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: 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 => 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: 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: 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 => 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 => 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 => 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 => 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; } as const;

@ -2,7 +2,7 @@ export { createEngineStorage } from './engine-storage';
export { createActiveStorage } from './active-storage.svelte'; export { createActiveStorage } from './active-storage.svelte';
export { createStorageDiagnostics, emitStorageDiagnostic } from './diagnostics'; export { createStorageDiagnostics, emitStorageDiagnostic } from './diagnostics';
export { export {
LOGGER_CATEGORY, STOR_MODULE,
DEFAULT_VERSION, DEFAULT_VERSION,
NAMESPACE_SEPARATOR, NAMESPACE_SEPARATOR,
ENVELOPE_KEY_VERSION, ENVELOPE_KEY_VERSION,

@ -8,9 +8,11 @@
* message prefixes, log message prefixes) stay in this file. * message prefixes, log message prefixes) stay in this file.
*/ */
import { TIMR_MODULE } from '$libs/timers';
export { export {
DEFAULT_TIMER_SCOPE_SEPARATOR, DEFAULT_TIMER_SCOPE_SEPARATOR,
LOGGER_CATEGORY, TIMR_MODULE,
TIMR_DIAGNOSTIC_EVENTS, TIMR_DIAGNOSTIC_EVENTS,
TIMR_EVENT_CANCELLED, TIMR_EVENT_CANCELLED,
TIMR_EVENT_COMPLETED, 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` / // Prefixed `[timr]` to match the convention used by `arts/sess` /
// `arts/http` so log output and stack traces are searchable. // `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_DISPOSED = 'TimrDisposedError';
export const ERROR_NAME_INVALID_KEY = 'TimrInvalidKeyError'; export const ERROR_NAME_INVALID_KEY = 'TimrInvalidKeyError';
export const ERROR_NAME_DUPLICATE_KEY = 'TimrDuplicateKeyError'; export const ERROR_NAME_DUPLICATE_KEY = 'TimrDuplicateKeyError';

@ -6,7 +6,7 @@ import {
type Diagnostics type Diagnostics
} from '$libs/logr'; } from '$libs/logr';
import { import {
LOGGER_CATEGORY, TIMR_MODULE,
LOG_MSG_SCHEDULE_AT_PAST, LOG_MSG_SCHEDULE_AT_PAST,
TIMR_DIAGNOSTIC_EVENTS, TIMR_DIAGNOSTIC_EVENTS,
TIMR_EVENT_FAILED, TIMR_EVENT_FAILED,
@ -59,13 +59,13 @@ function timerEventName(meta: TimerDiagnosticMeta | undefined): TimerEvent['type
function timerKeyName(meta: TimerDiagnosticMeta | undefined): string { function timerKeyName(meta: TimerDiagnosticMeta | undefined): string {
if (meta !== undefined && 'key' in meta) return meta.key; if (meta !== undefined && 'key' in meta) return meta.key;
return LOGGER_CATEGORY; return TIMR_MODULE;
} }
export function createTimerDiagnostics(logger?: Logger): TimerDiagnostics { export function createTimerDiagnostics(logger?: Logger): TimerDiagnostics {
return createCatalogDiagnostics({ return createCatalogDiagnostics({
logger, logger,
defaultCategory: LOGGER_CATEGORY, defaultCategory: TIMR_MODULE,
catalog: TIMR_DIAGNOSTIC_LOGS catalog: TIMR_DIAGNOSTIC_LOGS
}); });
} }
@ -76,7 +76,7 @@ export function emitTimerDiagnostic(
meta: TimerDiagnosticMeta meta: TimerDiagnosticMeta
): void { ): void {
diagnostics.emit({ diagnostics.emit({
artifact: LOGGER_CATEGORY, artifact: TIMR_MODULE,
type, type,
meta meta
}); });

@ -14,7 +14,7 @@ export {
DEFAULT_BACKOFF_MAX_DELAY_MS, DEFAULT_BACKOFF_MAX_DELAY_MS,
DEFAULT_BACKOFF_MIN_DELAY_MS, DEFAULT_BACKOFF_MIN_DELAY_MS,
DEFAULT_TIMER_SCOPE_SEPARATOR, DEFAULT_TIMER_SCOPE_SEPARATOR,
LOGGER_CATEGORY, TIMR_MODULE,
TIMR_DIAGNOSTIC_EVENTS, TIMR_DIAGNOSTIC_EVENTS,
TIMR_EVENT_CANCELLED, TIMR_EVENT_CANCELLED,
TIMR_EVENT_COMPLETED, TIMR_EVENT_COMPLETED,

@ -4,6 +4,8 @@
* (context keys, error names, runtime gates). * (context keys, error names, runtime gates).
*/ */
export const AAPP_MODULE = 'aapp';
export const AAPP_BUS_CONTEXT_KEY = 'libs.aapp.bus'; export const AAPP_BUS_CONTEXT_KEY = 'libs.aapp.bus';
export const AAPP_BUS_ERROR_NAME_NO_CONTEXT = 'AappBusNoContextError'; 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_EVENT_ERROR_NAME_UNSAFE_PAYLOAD = 'AappUnsafeEventPayloadError';
export const AAPP_BUS_ERROR_MSG_NO_CONTEXT = 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 = 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 = 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 = [ export const AAPP_EVENT_SENSITIVE_KEY_PARTS = [
'authorization', 'authorization',

@ -1,4 +1,4 @@
export const BUSS_LOG_CATEGORY = 'buss'; export const BUSS_MODULE = 'buss';
export const BUSS_DEFAULT_SOURCE = 'buss'; export const BUSS_DEFAULT_SOURCE = 'buss';
export const BUSS_EVENT_ALL = '*'; 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_REENTRANCY_LIMIT = 'BusReentrancyLimitError';
export const BUSS_ERROR_NAME_INVALID_PAYLOAD = 'BusInvalidPayloadError'; 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_DISPOSED = `[${BUSS_MODULE}] operation called on a disposed bus`;
export const BUSS_ERROR_MSG_AGGREGATE_LISTENER = '[buss] one or more listeners failed'; export const BUSS_ERROR_MSG_AGGREGATE_LISTENER = `[${BUSS_MODULE}] one or more listeners failed`;
export const BUSS_ERROR_MSG_REENTRANCY_LIMIT = 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 = 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_FAILED = 'buss.listener.failed';
export const BUSS_LOG_MSG_LISTENER_LEAK_WARNING = 'buss.listener.leak_warning'; export const BUSS_LOG_MSG_LISTENER_LEAK_WARNING = 'buss.listener.leak_warning';

@ -1,6 +1,6 @@
import { import {
BUSS_DIAGNOSTIC_EVENTS, BUSS_DIAGNOSTIC_EVENTS,
BUSS_LOG_CATEGORY, BUSS_MODULE,
BUSS_LOG_MSG_LISTENER_FAILED, BUSS_LOG_MSG_LISTENER_FAILED,
BUSS_LOG_MSG_LISTENER_LEAK_WARNING BUSS_LOG_MSG_LISTENER_LEAK_WARNING
} from './consts.ts'; } from './consts.ts';
@ -48,7 +48,7 @@ const BUSS_DIAGNOSTIC_LOGS: DiagnosticCatalog<BusDiagnosticEvent> = {
export function createBusDiagnostics(logger?: Logger): BusDiagnostics { export function createBusDiagnostics(logger?: Logger): BusDiagnostics {
return createCatalogDiagnostics({ return createCatalogDiagnostics({
logger, logger,
defaultCategory: BUSS_LOG_CATEGORY, defaultCategory: BUSS_MODULE,
catalog: BUSS_DIAGNOSTIC_LOGS catalog: BUSS_DIAGNOSTIC_LOGS
}); });
} }
@ -59,7 +59,7 @@ export function emitBusDiagnostic(
meta: BusDiagnosticMeta meta: BusDiagnosticMeta
): void { ): void {
diagnostics.emit({ diagnostics.emit({
artifact: BUSS_LOG_CATEGORY, artifact: BUSS_MODULE,
type, type,
meta meta
}); });

@ -33,7 +33,7 @@ export {
BUSS_LISTENER_ERROR_MODE_THROW, BUSS_LISTENER_ERROR_MODE_THROW,
BUSS_LISTENER_ERROR_MODES, BUSS_LISTENER_ERROR_MODES,
BUSS_LISTENER_ID_PREFIX, BUSS_LISTENER_ID_PREFIX,
BUSS_LOG_CATEGORY, BUSS_MODULE,
BUSS_LOG_MSG_LISTENER_FAILED, BUSS_LOG_MSG_LISTENER_FAILED,
BUSS_LOG_MSG_LISTENER_LEAK_WARNING BUSS_LOG_MSG_LISTENER_LEAK_WARNING
} from './consts.ts'; } from './consts.ts';

@ -2,7 +2,7 @@
export const ID_PREFIX = '#?'; export const ID_PREFIX = '#?';
export const ID_FALLBACK_SEPARATOR = '|'; export const ID_FALLBACK_SEPARATOR = '|';
export const MAX_RESOLVE_DEPTH = 3; 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 MONO_LANG_CATEGORY = 'lang.mono';
export const LANG_DIAGNOSTIC_EVENTS = { export const LANG_DIAGNOSTIC_EVENTS = {

@ -6,7 +6,7 @@ import {
type Diagnostics, type Diagnostics,
type Logger type Logger
} from '$libs/logr'; } 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 { LANG_ERRORS } from './errors.ts';
import type { SupportedLocale } from './types.ts'; import type { SupportedLocale } from './types.ts';
@ -86,7 +86,7 @@ const LANG_DIAGNOSTIC_LOGS: DiagnosticCatalog<LangDiagnosticEvent> = {
export function createLangDiagnostics(logger?: Logger): LangDiagnostics { export function createLangDiagnostics(logger?: Logger): LangDiagnostics {
return createCatalogDiagnostics({ return createCatalogDiagnostics({
logger, logger,
defaultCategory: LOGGER_CATEGORY, defaultCategory: LANG_MODULE,
catalog: LANG_DIAGNOSTIC_LOGS catalog: LANG_DIAGNOSTIC_LOGS
}); });
} }
@ -98,7 +98,7 @@ export function emitLangDiagnostic(
scope?: string scope?: string
): void { ): void {
diagnostics.emit({ diagnostics.emit({
artifact: LOGGER_CATEGORY, artifact: LANG_MODULE,
type, type,
scope, scope,
meta meta

@ -1,13 +1,15 @@
import { LANG_MODULE } from './consts.ts';
export const LANG_ERRORS = { 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 => 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 => 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: ( AMBIGUOUS_SIBLING_MATCH: (
locale: string, locale: string,
@ -16,21 +18,21 @@ export const LANG_ERRORS = {
path?: string path?: string
): string => ): string =>
path 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_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] 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 => 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 => 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_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 => REFERENCE_FALLBACK_USED: (path: string, fallback: string): string =>
`${LANG_ERRORS.KEY_NOT_FOUND(path)}. Using fallback "${fallback}".`, `${LANG_ERRORS.KEY_NOT_FOUND(path)}. Using fallback "${fallback}".`,

@ -17,7 +17,7 @@ export {
ID_FALLBACK_SEPARATOR, ID_FALLBACK_SEPARATOR,
ID_PREFIX, ID_PREFIX,
LANG_DIAGNOSTIC_EVENTS, LANG_DIAGNOSTIC_EVENTS,
LOGGER_CATEGORY, LANG_MODULE,
MAX_RESOLVE_DEPTH, MAX_RESOLVE_DEPTH,
MONO_LANG_CATEGORY MONO_LANG_CATEGORY
} from './consts.ts'; } from './consts.ts';

@ -1,6 +1,6 @@
import type { ResourceRef } from '$libs/perm'; 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_CHECK = '/check';
export const PERM_CLIENT_PATH_BATCH = '/batch'; export const PERM_CLIENT_PATH_BATCH = '/batch';

@ -9,7 +9,7 @@
*/ */
/** Logger category emitted by the engine. */ /** Logger category emitted by the engine. */
export const LOGGER_CATEGORY = 'timr'; export const TIMR_MODULE = 'timr';
export const TIMR_DIAGNOSTIC_EVENTS = { export const TIMR_DIAGNOSTIC_EVENTS = {
LISTENER_THREW: 'timr.listener_threw', LISTENER_THREW: 'timr.listener_threw',

@ -17,7 +17,7 @@ import {
type CacheEventType type CacheEventType
} from '$libs/cach'; } 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_HIT = 'cache hit';
export const CACH_LOG_MESSAGE_MISS = 'cache miss'; export const CACH_LOG_MESSAGE_MISS = 'cache miss';

@ -13,7 +13,7 @@ import {
type CacheEvent, type CacheEvent,
type CacheEventType type CacheEventType
} from '$libs/cach'; } 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<CacheEventType, CacheEvent>; export type CacheDiagnosticEvent = DiagnosticEvent<CacheEventType, CacheEvent>;
export type CacheDiagnostics = Diagnostics<CacheDiagnosticEvent>; export type CacheDiagnostics = Diagnostics<CacheDiagnosticEvent>;
@ -39,14 +39,14 @@ function cacheLogLevel(event: CacheEvent | undefined) {
export function createCacheDiagnostics(logger?: Logger): CacheDiagnostics { export function createCacheDiagnostics(logger?: Logger): CacheDiagnostics {
return createCatalogDiagnostics({ return createCatalogDiagnostics({
logger, logger,
defaultCategory: LOGGER_CATEGORY, defaultCategory: CACH_MODULE,
catalog: CACH_DIAGNOSTIC_LOGS catalog: CACH_DIAGNOSTIC_LOGS
}); });
} }
export function emitCacheDiagnostic(diagnostics: CacheDiagnostics, event: CacheEvent): void { export function emitCacheDiagnostic(diagnostics: CacheDiagnostics, event: CacheEvent): void {
diagnostics.emit({ diagnostics.emit({
artifact: LOGGER_CATEGORY, artifact: CACH_MODULE,
type: event.type, type: event.type,
meta: event meta: event
}); });

@ -28,7 +28,7 @@ export {
CACH_METHOD_QUERY, CACH_METHOD_QUERY,
CACH_METHOD_SET, CACH_METHOD_SET,
CACH_METHOD_STATS, CACH_METHOD_STATS,
LOGGER_CATEGORY CACH_MODULE
} from './consts.ts'; } from './consts.ts';
export { CachDisposedError, isCachDisposedError } from './errors.ts'; export { CachDisposedError, isCachDisposedError } from './errors.ts';
export { disposedCacheMessage } from './helpers.ts'; export { disposedCacheMessage } from './helpers.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 = { export const PERM_DIAGNOSTIC_EVENTS = {
DECISION: 'perm.server.decision', DECISION: 'perm.server.decision',

@ -7,7 +7,7 @@ import {
} from '$libs/logr'; } from '$libs/logr';
import type { PermissionCheckInput, PermissionDecision } from '$libs/perm'; import type { PermissionCheckInput, PermissionDecision } from '$libs/perm';
import { import {
LOGGER_CATEGORY, PERM_MODULE,
PERM_DIAGNOSTIC_EVENTS, PERM_DIAGNOSTIC_EVENTS,
PERM_LOG_MSG_DECISION, PERM_LOG_MSG_DECISION,
PERM_LOG_MSG_DENIED, PERM_LOG_MSG_DENIED,
@ -50,7 +50,7 @@ export function createPermissionDiagnostics(
): PermissionDiagnostics { ): PermissionDiagnostics {
return createCatalogDiagnostics({ return createCatalogDiagnostics({
logger, logger,
defaultCategory: LOGGER_CATEGORY, defaultCategory: PERM_MODULE,
catalog: PERM_DIAGNOSTIC_LOGS catalog: PERM_DIAGNOSTIC_LOGS
}); });
} }
@ -61,7 +61,7 @@ export function emitPermissionDiagnostic(
meta: PermissionDiagnosticMeta meta: PermissionDiagnosticMeta
): void { ): void {
diagnostics.emit({ diagnostics.emit({
artifact: LOGGER_CATEGORY, artifact: PERM_MODULE,
type, type,
meta meta
}); });

@ -9,7 +9,7 @@ export {
} from './database-repository.ts'; } from './database-repository.ts';
export { export {
LOGGER_CATEGORY, PERM_MODULE,
PERM_CONTEXT_KEYS, PERM_CONTEXT_KEYS,
PERM_DB_DEFAULT_NAMESPACE, PERM_DB_DEFAULT_NAMESPACE,
PERM_DB_POLICY_STATUSES, PERM_DB_POLICY_STATUSES,

Loading…
Cancel
Save

Powered by TurnKey Linux.