Logger
class in meocord/common Since 4.0.0
class LoggerPrints timestamped lines to the console, each named with the app and a context, at a level the config can hide.
Use it in controllers and services instead of console, so the bot's lines share one format and
meocord.config.ts's logLevel, or MEOCORD_LOG_LEVEL for one run, decides which print.
Examples
@Service()
export class ReminderService {
private readonly logger = new Logger(ReminderService.name)
remind(userId: string) {
this.logger.log(`Reminding ${userId}`)
}
}Members
constructor
new Logger(context?: string | undefined)Parameters
| Name | Type | Description |
|---|---|---|
context? | string | undefined | What the lines are about, shown on each, such as a class's name. |
debug
debug(...args: any[]): voidPrints a line at the debug level, shown only when the level is debug.
Parameters
| Name | Type | Description |
|---|---|---|
...args | any[] | What to print, separated by spaces. |
error
error(...args: any[]): voidPrints an error, shown unless the level is silent.
Parameters
| Name | Type | Description |
|---|---|---|
...args | any[] | What to print, separated by spaces. |
info
info(...args: any[]): voidPrints a line tagged [INFO], shown at the log level as log is.
Parameters
| Name | Type | Description |
|---|---|---|
...args | any[] | What to print, separated by spaces. |
log
log(...args: any[]): voidPrints a line at the log level.
Parameters
| Name | Type | Description |
|---|---|---|
...args | any[] | What to print, separated by spaces. |
verbose
verbose(...args: any[]): voidPrints a line tagged [VERBOSE], shown at the log level as log is.
Parameters
| Name | Type | Description |
|---|---|---|
...args | any[] | What to print, separated by spaces. |
warn
warn(...args: any[]): voidPrints a warning, shown unless the level is error or silent.
Parameters
| Name | Type | Description |
|---|---|---|
...args | any[] | What to print, separated by spaces. |
See also
- MeoCordConfig