Skip to content

Home > @opengovsg/logging > createLogging

createLogging() function ​

Build a CreateLogger bound to a fixed deployment config. Call once at process boot with values mapped from your app's own environment, and re-export the result so call sites can create request-scoped loggers:

ts
// src/logger.ts — owned by the app
export const createBaseLogger = createLogging({ env, service, version })

The returned factory is immutable: config is fixed at creation and the pino instance is built once. To run with different config, create another factory.

env, service, and version are required — deployment identity must be explicit. level (default info) and pretty (default false) are optional. Never throws.

Signature:

typescript
createLogging: (config: LoggingConfig) => CreateLogger

Parameters ​

ParameterTypeDescription
configLoggingConfig

Returns:

CreateLogger