Class: Logger
A generalized application logger implementation for Node.JS applications
Constructors
Constructor
new Logger(
level:
| LoggerLevel
| "DEBUG"
| "INFO"
| "ERROR"
| "EMERG"
| "ALERT"
| "CRIT"
| "WARNING"
| "NOTICE",
meta: Record<string, any>,
loki?: LokiTransportOptions): Logger;Create a new logger instance.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
level | | LoggerLevel | "DEBUG" | "INFO" | "ERROR" | "EMERG" | "ALERT" | "CRIT" | "WARNING" | "NOTICE" | 'info' | The log level to use. This can be any of the levels defined in LoggerLevel. |
meta | Record<string, any> | {} | Additional metadata to include in the log messages. This can be any object. |
loki? | LokiTransportOptions | undefined | Options for the Loki transport. This can be any object that is compatible with the Loki transport. |
Returns
Logger
Accessors
complete
Get Signature
get complete(): Promise<void>;A promise that resolves when the logger has finished processing all log messages.
Returns
Promise<void>
Methods
alert()
alert(...args: any[]): void;Log a message with the level of alert
Parameters
| Parameter | Type | Description |
|---|---|---|
...args | any[] | The arguments to log |
Returns
void
child()
child(meta: Record<string, any>): Logger;Return a new logger instance with the same level and additional metadata.
Parameters
| Parameter | Type | Description |
|---|---|---|
meta | Record<string, any> | Additional metadata to include in the log messages. This can be any object. |
Returns
Logger
A new logger instance with the same level and additional metadata.
close()
close(): void;Close the logger and flush any remaining log messages.
Returns
void
crit()
crit(...args: any[]): void;Log a message with the level of crit
Parameters
| Parameter | Type | Description |
|---|---|---|
...args | any[] | The arguments to log |
Returns
void
debug()
debug(...args: any[]): void;Log a message with the level of debug
Parameters
| Parameter | Type | Description |
|---|---|---|
...args | any[] | The arguments to log |
Returns
void
emerg()
emerg(...args: any[]): void;Log a message with the level of emerg
Parameters
| Parameter | Type | Description |
|---|---|---|
...args | any[] | The arguments to log |
Returns
void
error()
error(...args: any[]): void;Log a message with the level of error
Parameters
| Parameter | Type | Description |
|---|---|---|
...args | any[] | The arguments to log |
Returns
void
info()
info(...args: any[]): void;Log a message with the level of info
Parameters
| Parameter | Type | Description |
|---|---|---|
...args | any[] | The arguments to log |
Returns
void
inspect()
inspect(arg: unknown, level:
| LoggerLevel
| "DEBUG"
| "INFO"
| "ERROR"
| "EMERG"
| "ALERT"
| "CRIT"
| "WARNING"
| "NOTICE"): void;Log an inspected value using the Node.js util.inspect function.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
arg | unknown | undefined | The value to inspect. |
level | | LoggerLevel | "DEBUG" | "INFO" | "ERROR" | "EMERG" | "ALERT" | "CRIT" | "WARNING" | "NOTICE" | 'info' | The log level to use. This can be any of the levels defined in LoggerLevel. |
Returns
void
notice()
notice(...args: any[]): void;Log a message with the level of notice
Parameters
| Parameter | Type | Description |
|---|---|---|
...args | any[] | The arguments to log |
Returns
void
shutdown()
shutdown(): Promise<void>;Shuts down the logger and flushes any remaining log messages.
Returns
Promise<void>
warning()
warning(...args: any[]): void;Log a message with the level of warning
Parameters
| Parameter | Type | Description |
|---|---|---|
...args | any[] | The arguments to log |
Returns
void