Logger

Logger is a class in the utils folder to help you logging things. It has multiple static methods that you can use.

Example

const {Logger} = require('advanced-command-handler');
Logger.error(`${Logger.setColor('orange')} is not allowed.`, 'PermissionError');

Give the following result in the console (screen made on WebStorm). screen

Every number is yellow by default.

Properties

Colors

Colors are set out in a static public object in the class, so you can change them.

These are the current colors :

Logger.ts
const colors = {
    red: '#b52825',
    orange: '#e76a1f',
    gold: '#deae17',
    yellow: '#eeee23',
    green: '#3ecc2d',
    teal: '#11cc93',
    blue: '#2582ff',
    indigo: '#524cd9',
    violet: '#7d31cc',
    magenta: '#b154cf',
    pink: '#d070a0',
    brown: '#502f1e',
    black: '#000000',
    grey: '#6e6f77',
    white: '#ffffff',
    default: '#cccccc',
};

Levels

Each logs have levels that are primarily used for ignoring logs, see Ignoring logs.

Ignoring logs

There are multiple way to ignore logs.

You can ignore whole multiple levels of logs like this :

You can also ignore logs by titles using ignores property, the title is the second argument you put in every logs methods, it will always be defaulted to the name of the log level.

Finally you can ignore logs by titles and by levels.

Saving logs

You can add files where to save logs using the CreateCommandHandlerOptions#savingFiles property when creating your CommandHandler.

If the files are not found, it will try to create them, else it will append logs to them.

Last updated

Was this helpful?