Skip to content

Logger

Represents a logger utility for logging messages with various log levels.

Constructors

new Logger()

1
new Logger(options: LoggerOptions): Logger

Constructs a new Logger instance with the provided options.

Parameters

ParameterTypeDescription
optionsLoggerOptionsThe options for configuring the logger.

Returns

Logger

Source

twitchfy/packages/eventsub/src/logger/Logger.ts:94

Properties

PropertyModifierTypeDefault valueDescription
optionsreadonlyRequired<LoggerOptions>undefinedThe options for configuring the logger.
DEFAULT_OPTIONSstaticRequired<LoggerOptions>...The default options for the logger.
colorFunctionsstaticMap<LogLevels, (str: string) => string>...A map containing color functions for different log levels.
dirnamestaticstring'eventsub-logs'-
prefixesstaticMap<LogLevels, string>...A map containing prefixes for different log levels.
saveOnFile?staticstring[] | "all"undefined-
streamsstaticPartial<Record<string, WriteStream>>{}-

Accessors

active

1
get active(): boolean

Gets whether the logger is active or not.

1
set active(active: boolean): void

Sets whether the logger is active or not.

Parameters

ParameterType
activeboolean

Returns

boolean

Source

twitchfy/packages/eventsub/src/logger/Logger.ts:130


level

1
get level(): LogLevels

Gets the log level of the logger.

1
set level(level: LogLevels): void

Sets the log level of the logger.

Parameters

ParameterType
levelLogLevels

Returns

LogLevels

Source

twitchfy/packages/eventsub/src/logger/Logger.ts:108


name

1
get name(): string

Gets the name of the logger.

1
set name(name: string): void

Sets the name of the logger.

Parameters

ParameterType
namestring

Returns

string

Source

twitchfy/packages/eventsub/src/logger/Logger.ts:144


saveOnFile

1
get saveOnFile(): boolean
1
set saveOnFile(saveOnFile: boolean): void

Parameters

ParameterType
saveOnFileboolean

Returns

boolean

Source

twitchfy/packages/eventsub/src/logger/Logger.ts:116

Methods

debug()

1
debug(...args: any[]): void

Logs a debug message.

Parameters

ParameterTypeDescription
argsany[]The arguments to log.

Returns

void

Source

twitchfy/packages/eventsub/src/logger/Logger.ts:182


error()

1
error(...args: any[]): void

Logs an error message.

Parameters

ParameterTypeDescription
argsany[]The arguments to log.

Returns

void

Source

twitchfy/packages/eventsub/src/logger/Logger.ts:206


fatal()

1
fatal(...args: any[]): void

Logs a fatal error message.

Parameters

ParameterTypeDescription
argsany[]The arguments to log.

Returns

void

Source

twitchfy/packages/eventsub/src/logger/Logger.ts:214


info()

1
info(...args: any[]): void

Logs an info message.

Parameters

ParameterTypeDescription
argsany[]The arguments to log.

Returns

void

Source

twitchfy/packages/eventsub/src/logger/Logger.ts:190


rawLog()

1
rawLog(level: LogLevels, ...args: unknown[]): void

Logs a message with the specified log level.

Parameters

ParameterTypeDescription
levelLogLevelsThe log level.
argsunknown[]The arguments to log.

Returns

void

The logged message.

Source

twitchfy/packages/eventsub/src/logger/Logger.ts:154


warn()

1
warn(...args: any[]): void

Logs a warning message.

Parameters

ParameterTypeDescription
argsany[]The arguments to log.

Returns

void

Source

twitchfy/packages/eventsub/src/logger/Logger.ts:198


clearLogs()

1
static clearLogs(): Promise<void>

Returns

Promise<void>

Source

twitchfy/packages/eventsub/src/logger/Logger.ts:82


customize()

1
static customize(cb: CustomCallback): void

Allows customization of the logging behavior by providing a custom callback function.

Parameters

ParameterTypeDescription
cbCustomCallbackThe custom callback function for logging.

Returns

void

Example

1
Logger.customize((logger, level, args) => {
2
// Custom logging implementation
3
});

Source

twitchfy/packages/eventsub/src/logger/Logger.ts:78


noColor()

1
static noColor(msg: string): string

A function that returns the input string as is, without any color modification.

Parameters

ParameterTypeDescription
msgstringThe message to log.

Returns

string

The input message as is.

Source

twitchfy/packages/eventsub/src/logger/Logger.ts:248