Logging
Logging events, errors, and info is a necessary thing to be able to create better functioning and more easily understandable code; that's why create-discord-bot includes options to integrate high-quality loggers into its ecosystem.
Pino
Pino is the recommended option by create-discord-bot and a recommendation of the Discord.JS Guide.
Pino is a very low overhead, lightweight logging utility that outputs JSON and can transport its logs to a separate file or both. It can also be prettified/formatted with pino-pretty, transforming it into a more human-readable format.
Example
Courtesy of pino-prettyDefault
Normal console.log, error, warn, and info that outputs plain text.
Adding Color
There are multiple ways to add colour to your logs, one of which is to use ansi escape codes.
console.log("\x1b[32mI'm GREEN\x1b[0m");
// I'm GREEN (in green)
However, some libraries can help to ease and abstract the process, such as:
- Chalk - Small package with easy-to-use chainable functions
- Pico-colors - Lightweight and fast.
- Kleur - Alternative to Chalk.
- Kolorist - Alternative to Chalk.
Other options
There are also other options that might fit your use case better, such as: