Module

Logging

Comprehensive logging toolkit for browser and Node environments.

View Source index.ts, line 13

Interfaces

Impersonatable

Declares a for method that returns another instance of THIS using the provided arguments, enabling chained logger customization.

Logger

Declares severity-specific log methods, configuration overrides, and factory helpers used throughout the logging toolkit.

LoggingFilter

Allows custom pre-processing of log entries before they are formatted or emitted.

Theme

Specifies styling for each console log element and supports overrides based on LogLevel values.

ThemeOption

Configures foreground and background colors as well as additional style directives for styled console output.

Members

string

# static constant BrowserEnvKey

Enables the logging environment helpers to locate serialized environment configuration on globalThis.

Global key used to store environment variables in browser contexts.

View Source constants.ts, line 2

Array.<string>

# static constant DefaultPlaceholderWrappers

Provides wrapper strings applied when interpolating messages with patchPlaceholders.

Default prefix and suffix used for template placeholders.

View Source constants.ts, line 18

Theme

# static constant DefaultTheme

Defines the default color and style settings for various components of log messages.

Default theme for styling log output.

Properties:
Name Type Description
class Object

Styling for class names.

fg number

Foreground color code for class names (34).

id Object

Styling for identifiers.

fg number

Foreground color code for identifiers (36).

stack Object

Styling for stack traces (empty object).

timestamp Object

Styling for timestamps (empty object).

message Object

Styling for different types of messages.

error Object

Styling for error messages.

error.fg number

Foreground color code for error messages (31).

method Object

Styling for method names (empty object).

logLevel Object

Styling for different log levels.

error Object

Styling for error level logs.

error.fg number

Foreground color code for error level logs (31).

error.style Array.<string>

Style attributes for error level logs (["bold"]).

info Object

Styling for info level logs (empty object).

verbose Object

Styling for verbose level logs (empty object).

debug Object

Styling for debug level logs.

debug.fg number

Foreground color code for debug level logs (33).

View Source constants.ts, line 94

string

# static constant ENV_PATH_DELIMITER

Joins parent and child keys when mapping object paths to ENV strings.

Delimiter used for composing nested environment variable names.

View Source constants.ts, line 10

# static constant LoggedEnvironment

Combines DefaultLoggingConfig with runtime environment variables to provide consistent logging defaults across platforms.

Singleton environment instance seeded with default logging configuration.

View Source environment.ts, line 394

NumericLogLevelsShape

# static constant NumericLogLevels

Provides a numeric representation of log levels for comparison and filtering.

Numeric values associated with log levels.

View Source constants.ts, line 64

string

# static constant PACKAGE_NAME

Stores the package version for diagnostics and compatibility checks.

Current package version string.

View Source index.ts, line 26

string

# static constant VERSION

Stores the package version for diagnostics and compatibility checks.

Current package version string.

View Source index.ts, line 18

LoggerFactory

# static constant WinstonFactory

A LoggerFactory implementation that creates WinstonLogger instances

Factory function for creating Winston loggers

View Source winston/winston.ts, line 74

string

# static readonly exports.LogLevel

Defines different levels of logging for the application.

Enum for log levels.

View Source constants.ts, line 33

string

# static exports.LoggingMode

Defines different output formats for log messages.

Enum for logging output modes.

View Source constants.ts, line 87

Methods

# static escapeRegExp(string) → {string}

Adds backslashes before characters that have special meaning in regular expressions, allowing the string to be used as a literal match in a RegExp.

Escapes special characters in a string for use in a regular expression.

Parameters:
Name Type Description
string string

The string to escape for regular expression use.

View Source text.ts, line 161

The escaped string safe for use in regular expressions.

string

# static formatMs(ms) → {string}

Breaks the duration into hours, minutes, seconds, and milliseconds, returning a zero-padded string.

Formats milliseconds into hh:mm:ss.mmm.

sequenceDiagram participant Caller participant Formatter as formatMs Caller->>Formatter: formatMs(ms) Formatter->>Formatter: derive hours/minutes/seconds Formatter->>Formatter: pad segments Formatter-->>Caller: hh:mm:ss.mmm
Parameters:
Name Type Description
ms number

Milliseconds to format.

View Source time.ts, line 187

Formatted duration string.

string

# static isBrowser() → {boolean}

Checks if the code is running in a browser environment.

Determines if the current environment is a browser by checking the prototype chain of the global object.

View Source web.ts, line 2

True if the environment is a browser, false otherwise.

boolean

# static padEnd(str, length, charopt) → {string}

Extends the input string to a specified length by adding a padding character to the end. If the input string is already longer than the specified length, it is returned unchanged.

Pads the end of a string with a specified character.

Parameters:
Name Type Attributes Default Description
str string

The input string to be padded.

length number

The desired total length of the resulting string.

char string <optional>
" "

The character to use for padding. Defaults to a space.

View Source text.ts, line 3

If the padding character is not exactly one character long.

Error

The padded string.

string

# static patchPlaceholders(input, values, prefix, suffix, flags) → {string}

Interpolates a string by replacing placeholders of the form ${variableName} with corresponding values from the provided object. If a placeholder doesn't have a corresponding value, it is left unchanged in the string.

Replaces placeholders in a string with provided values.

sequenceDiagram participant Caller participant patchString participant String.replace Caller->>patchString: Call with input and values patchString->>String.replace: Call with regex and replacement function String.replace->>patchString: Return replaced string patchString-->>Caller: Return patched string
Parameters:
Name Type Description
input string

The input string containing placeholders to be replaced.

values Record.<string, (number|string)>

An object containing key-value pairs for replacement.

prefix
suffix
flags

View Source text.ts, line 23

The interpolated string with placeholders replaced by their corresponding values.

string

# static patchString(input, values, flagsopt) → {string}

Iterates through a set of key-value pairs and replaces all occurrences of each key in the input string with its corresponding value. Supports regular expression flags for customized replacement.

Replaces occurrences of keys with their corresponding values in a string.

Parameters:
Name Type Attributes Default Description
input string

The input string in which replacements will be made.

values Record.<string, (number|string)>

An object containing key-value pairs for replacement.

flags string <optional>
"g"

Regular expression flags to control the replacement behavior.

View Source text.ts, line 57

The string with all specified replacements applied.

string

# static sf(string, argsopt) → {string}

Util function to provide string format functionality similar to C#'s string.format

Parameters:
Name Type Attributes Description
string string
args Array.<(string|number)> | Record.<string, any> <optional>

replacements made by order of appearance (replacement0 wil replace {0} and so on)

View Source text.ts, line 176

formatted string

string

# static stringFormat()

Util function to provide string format functionality similar to C#'s string.format

Deprecated:
  • Yes
See:
  • sf

View Source text.ts, line 205

# static toCamelCase(text) → {string}

Transforms the input string into camelCase format, where words are joined without spaces and each word after the first starts with a capital letter.

Converts a string to camelCase.

Parameters:
Name Type Description
text string

The input string to be converted.

View Source text.ts, line 78

The input string converted to camelCase.

string

# static toENVFormat(text) → {string}

Transforms the input string into uppercase with words separated by underscores, typically used for environment variable names.

Converts a string to ENVIRONMENT_VARIABLE format.

Parameters:
Name Type Description
text string

The input string to be converted.

View Source text.ts, line 95

The input string converted to ENVIRONMENT_VARIABLE format.

string

# static toKebabCase(text) → {string}

Transforms the input string into lowercase with words separated by hyphens.

Converts a string to kebab-case.

Parameters:
Name Type Description
text string

The input string to be converted.

View Source text.ts, line 127

The input string converted to kebab-case.

string

# static toPascalCase(text) → {string}

Transforms the input string into PascalCase format, where words are joined without spaces and each word starts with a capital letter.

Converts a string to PascalCase.

Parameters:
Name Type Description
text string

The input string to be converted.

View Source text.ts, line 144

The input string converted to PascalCase.

string

# static toSnakeCase(text) → {string}

Transforms the input string into lowercase with words separated by underscores.

Converts a string to snake_case.

Parameters:
Name Type Description
text string

The input string to be converted.

View Source text.ts, line 110

The input string converted to snake_case.

string

Type Definitions

# AnyFunction(args)

Covers variadic functions whose arguments and return types are not constrained, enabling the logging layer to accept any callable.

Generic function signature for loosely typed callbacks.

Parameters:
Name Type Description
args Array

View Source types.ts, line 14

any

# Class

Describes a constructor that produces instances of type T, allowing APIs to accept class references for context-aware logging.

Constructable class type.

Properties:
Name Type Description
...args: T

any[]

View Source types.ts, line 22

LoggingConfig

# DefaultLoggingConfig

Defines the default settings for the logging system, including verbosity, log level, styling, and timestamp format.

Default configuration for logging.

Properties:
Name Type Description
verbose number

Verbosity level (0).

level LogLevel

Default log level (LogLevel.info).

logLevel boolean

Whether to display log level in output (true).

mode LoggingMode

Output format mode (LoggingMode.RAW).

style boolean

Whether to apply styling to log output (false).

separator string

Separator between log components (" - ").

timestamp boolean

Whether to include timestamps in log messages (true).

timestampFormat string

Format for timestamps ("HH:mm:ss.SSS").

context boolean

Whether to include context information in log messages (true).

theme Theme

The theme to use for styling log messages (DefaultTheme).

View Source constants.ts, line 167

# EnvironmentFactory(args)

Describes factories that construct Environment derivatives with custom initialization.

Factory type for creating Environment instances.

Parameters:
Name Type Description
args Array

View Source environment.ts, line 410

Object

# Lap

Captures the lap index, optional label, elapsed milliseconds for the lap, and cumulative elapsed time since the stopwatch started.

Snapshot of a recorded lap interval.

Properties:
Name Type Attributes Description
index number

Zero-based lap order.

label string <optional>

Optional label describing the lap.

ms number

Duration of the lap in milliseconds.

totalMs number

Total elapsed time when the lap was recorded.

index number
label string <optional>
ms number

Duration of this lap in milliseconds

totalMs number

Cumulative time up to this lap in milliseconds

View Source time.ts, line 214

# LoggerFactory(object, configopt, args)

Allows consumers to override logger construction with custom implementations.

Factory signature for creating logger instances.

Parameters:
Name Type Attributes Description
object string
config Partial.<LoggingConfig> <optional>
args Array

View Source types.ts, line 200

Object

# LoggingConfig

Defines the log level and verbosity for logging.

Configuration for logging.

Properties:
Name Type Attributes Description
level LogLevel

The logging level.

logLevel boolean <optional>

Whether to display log level in output.

verbose number

The verbosity level.

mode LoggingMode <optional>

Output format mode.

contextSeparator string

Separator between context entries.

separator string

Separator between log components.

style boolean <optional>

Whether to apply styling to log output.

timestamp boolean <optional>

Whether to include timestamps in log messages.

timestampFormat string <optional>

Format for timestamps.

context boolean <optional>

Whether to include context information in log messages.

theme Theme <optional>

The theme to use for styling log messages.

correlationId string | number <optional>

Correlation ID for tracking related log messages.

app string <optional>
env "development" | "production" | "test" | "staging" | string
level LogLevel
logLevel boolean <optional>
verbose number
contextSeparator string
separator string
style boolean <optional>
timestamp boolean <optional>
timestampFormat string <optional>
context boolean <optional>
theme Theme <optional>
format LoggingMode
pattern string
correlationId string | number <optional>
filters Array | Array <optional>

View Source types.ts, line 165

# LoggingContext()

Allows the logging system to resolve context names from strings, constructors, or functions.

Context descriptor accepted when requesting a logger instance.

View Source types.ts, line 31

Object

# NumericLogLevelsShape

Provides a numeric representation of log levels for comparison and filtering.

Numeric values associated with log levels.

Properties:
Name Type Description
benchmark number

Numeric value for benchmark level (0).

error number

Numeric value for error level (2).

info number

Numeric value for info level (4).

verbose number

Numeric value for verbose level (6).

debug number

Numeric value for debug level (7).

silly number

Numeric value for silly level (9).

View Source constants.ts, line 52

# ReplacementFunction(substring, args)

Receives the matched substring and additional capture arguments, returning the replacement text that will be injected into the log message.

Replacement callback used to transform RegExp matches.

Parameters:
Name Type Description
substring string
args Array

View Source filters/PatternFilter.ts, line 85

string | Object

# StringLike

Represents either a literal string or an object exposing a toString() method, allowing lazy stringification of complex payloads.

String-compatible value accepted by the logging APIs.

Properties:
Name Type Description
toString function

View Source types.ts, line 6