global.d.ts

TypeScript ambient declarations for the global logging interface

Purpose

This declaration file extends the global namespace to make the logging functions installed by logging.ts available as typed globals throughout the application, without requiring an explicit import in every file.

Its responsibilities include:

  • Declaring global.logging as an optional LevelType controlling the active log level
  • Declaring global.log as the raw multi-level log emitter
  • Declaring global.makeLogger as the source-scoped logger factory

Invariants

Globals Are Set by logging.ts

The actual runtime values are assigned at the bottom of logging.ts:

global.logging ??= DEFAULT_LOG_LEVEL;
global.log = log;
global.makeLogger = makeLogger;

This file only provides the TypeScript types; importing it does not install the globals.


Must Be Imported Before First Use

logging.ts must be imported before any module calls global.log or global.makeLogger. The convention is to import it at the top of App.tsx before any service or utility imports.


Declared Globals

global.logging

var logging: LevelType | undefined

The active log level filter. When undefined, the default level from logging.ts is applied.


global.log

var log: (
	levels: LevelType[],
	message: string,
	source?: string,
	...details: unknown[]
) => void

Emits a log entry to all configured sinks for each level in levels.


global.makeLogger

var makeLogger: (source: string) => {
	debug: (message: string, ...details: unknown[]) => void;
	error: (message: string, ...details: unknown[]) => void;
	info: (message: string, ...details: unknown[]) => void;
	log: (levels: LevelType[], message: string, ...details: unknown[]) => void;
	warn: (message: string, ...details: unknown[]) => void;
}

Returns a logger object pre-bound to source, so callers don’t need to pass the source string on every call.