4.1.2 • Published 2 years ago

kailogs v4.1.2

Weekly downloads
2
License
ISC
Repository
github
Last release
2 years ago

KaiLogs

Local logging library for Discord.js bots. Designed for KaiBot and Quentin Discord Applications.

Turn this:

Hey this needs to be logged!

Into this:

[11:44:55PM] [<location>/INFO]: Hey this needs to be logged!

JavaScript Usage for KaiLogs@4.x.x+

Create logger

We need to create a new logger with a directory to put the logs.

const KaiLogs = require('kailogs');
const logger = new KaiLogs.logger('./logs');

Error handling

KaiLogs can now log uncaught exceptions and rejections.

const exception = new KaiLogs.exceptions(logger);
const rejection = new KaiLogs.rejections(logger);

After this we need to tell KaiLogs to start handling error events.

exception.handle();
rejection.handle();

These can be turned off at anytime using the unhandle() method.

Logging levels

KaiLogs has 6 logging levels. Each type of level has its own method. | Name | Example | Usage | ---------| ----------------| ----------- | debug | logger.debug(message) | 'message' : string of the message to be logged. | error | logger.error(message) | 'message' : string of the message to be logged. | info | logger.info(message) | 'message' : string of the message to be logged. | log | logger.log(type, message) | 'type' : custom level type string, 'message' : string of the message to be logged. | warn | logger.warn(message) | 'message' : string of the message to be logged.

The logger.message() method is intended to log Discord messages for moderation purposes. Requires a channel.name, user.username, and message.content class.

Events

As of KaiLogs@4.1.x, events will emit for each logging level.

logger.on('error', (err) => {
    // Emits every time 'logger.error()' is called.
})

JavaScript Usage for KaiLogs@3.x.x

const logger = require('kailogs');

// Loads the latest log and continues the logging
logger.loadLog('../logs');

// Writes to log file and prints to console
logger.debug('debug');
logger.error('this is a error');
logger.log('this is a log');
logger.warn('this is a warning');

// Saves file as current date
logger.save();

// Creates a new log file
logger.createLog('../logs');

// Writes only to the console
logger.write('this is not logged', 'function');
5.0.0-Beta.0

2 years ago

4.1.0

2 years ago

4.0.1

2 years ago

4.1.2

2 years ago

4.1.1

2 years ago

4.0.0

2 years ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.0

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.0.2

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.1.2

3 years ago

0.1.3

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago