1.2.4 • Published 6 years ago

@kata-codes/yamdbf-log-to-file v1.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

yamdbf-log-to-file

Discord npm dependencies Status devDependencies Status Travis

yamdbf-log-to-file is a plugin for Discord bots that are written with YAMDBF+Discord.js that extends the logging functionality to write all logs issued through the YAMDBF Logger to a log file.

Installation

Install the package via npm:

npm i --save @kata-codes/yamdbf-log-to-file

Note: This plugin depends on YAMDBF >3.0.0, so obviously make sure yamdbf is installed.

Usage

logToFile

Import logToFile from the plugin into your YAMBDF Client:

const { logToFile } = require('@kata-codes/yamdbf-log-to-file');

logsPath

You should add a logsPath entry into your config file specifying where you would like the logs to populate.

After updating your config, add the following to your YAMDBF Client:

const logsPath: string = (config.logsPath) ? config.logsPath : __dirname;

Note: The path must be an absolute path.

plugins array

Pass logToFile(logsPath) into your YAMDBF Client options plugins array field:

const client = new Client({
	...
	plugins: [logToFile(logsPath)]
});

Log Persistence

You can optionally specify a number of days to keep your logs by passing a number as a parameter along with the logsPath:

const client = new Client({
	...
	plugins: [logToFile(logsPath, 7)]
});

Note: If no number is specified, yamdbf-log-to-file will maintain the last three (3) days of logs.