Skip to main content
Version: Next

Logger

TSCord includes a logger service that lets you efficiently log things towards different "locations" in a formatted way.

Configuration

To configure what should be logged and where, head over to this part of the documentation.

Usage

Log

The log() method of the Logger service is a little abstraction of the per location methods (listed just below) that will act as a shortcut to log to the console, and optionally to a file or a discord channel depending on params.

Params

NameTypeDefaultDescription
messagestringThe message to log
levelstringinfoinfo | warn | error
saveToFilebooleantrueIf the message should be saved in a file
channelIdstring | nullnullDiscord channel to log to (if null, nothing will be logged to Discord)

Usage

import { Logger } from '@services'
const logger = container.resolve(Logger)

logger.log('hello world!')

Per location methods

Log a message in the console using the console() method.

Params

NameTypeDefaultDescription
messagestringThe message to log
levelstringinfoinfo | warn | error
ignoreTemplatebooleanfalseIf it should ignore the default timestamp-based template

Usage

import { Logger } from '@services'
const logger = container.resolve(Logger)

logger.console('hello world!')