Skip to content

v0.0.1

Latest

Choose a tag to compare

@BebanCode BebanCode released this 14 Jul 16:08
a6fd05b

This is the initial release of commandkit-plugin-custom-logger.

This plugin provides a powerful and highly customizable logging solution for CommandKit bots. It extends CommandKit's capabilities with advanced features like file logging with automatic rotation, Discord webhook integration for critical alerts, and fine-grained control over log output formats. It's designed to give developers a comprehensive view of their application's behavior, from debugging to production monitoring.

Core Features

  • Multi-Channel Logging: Log simultaneously to the console, local files, and a Discord webhook.
  • Automatic Log Rotation: Automatically creates daily log directories and rotates log files when they reach a specific size, preventing them from growing indefinitely.
  • Seamless CommandKit Integration: Optionally replaces the default CommandKit logger to capture and format all framework-level logs consistently.
  • Highly Customizable: Configure log levels, colors, prefixes, timestamps, and more for both console and file outputs.
  • Webhook Alerts: Send critical logs (like 'error' and 'fatal') directly to a Discord channel for immediate notification.
  • Developer-Friendly Debugging: Includes an option to display the caller's file path and line number for easier troubleshooting.

Installation

To install the package, run the following command:

npm install commandkit-plugin-custom-logger

Basic Usage

To use the plugin, import LoggerPlugin and register it in your commandkit.config.ts file:

import { defineConfig } from 'commandkit';
import { LoggerPlugin } from 'commandkit-plugin-custom-logger';

export default defineConfig({
  plugins: [
    LoggerPlugin({
      // The minimum log level to display in the console.
      consoleLogLevel: 'info',
      
      // The minimum log level to write to a file.
      fileLogLevel: 'debug',
      
      // The URL of the Discord webhook to send logs to.
      webhookUrl: 'YOUR_WEBHOOK_URL_HERE',
      
      // An array of log levels that should trigger a webhook message.
      webhookLogLevels: ['error', 'fatal'],
      
      // Whether to replace CommandKit's internal logger.
      replaceCommandKitLogger: true,
    }),
  ],
});

As this is the first version, please report any bugs or issues by opening an issue on the repository.