Skip to content

Custom log types

To create custom log types, pass a custom object of types with the options

Example

const log = new Loger({
    custom: {
    sql: {
        title: 'MySQL',
        foreground: 'bluebright',
        type: 'info'
    },
    redis: {
        title: 'Redis',
        foreground: 'redBright',
        type: 'info'
    },
},
});

If you created a type called sql like this:

custom: {
    sql: {
        title: 'MySQL',
        foreground: 'bluebright',
        type: 'info'
    },
},

You would use it like this:

log.sql('Something about the database');
// -> [00:00:00 | MYSQL] Something about the database

Format

[TIMESTAMP | TITLE] [PREFIX] Text

Options

title

A string that will show with the timestamp (it will be in uppercase)

prefix

Prefix string which goes after timestamp/title and before text (wrapped in [])

foreground

A resolvable foreground colour to colour the text.

background

A resolvable background colour to colour the background.

type

Changes the console function. Defaults to info


Last update: September 1, 2020