/QuillLogger

簡易的console日誌程式

Primary LanguageTypeScriptMIT LicenseMIT

Quill Logger Quill Logger

Welcome to the Quill Logger project!

Description

This project aims to provide a logging solution for Discord bot Project. It allows you to easily log important events and messages for debugging and analysis purposes.

Features

  • Log message events
  • Log error events
  • Customize log format
  • Save logs to file (coming soon)

Installation

To install the logger module, simply run the following command:

npm install https://github.com/YouziDcBot/QuillLogger.git

Usage

To use the logger module in your Discord bot, follow these steps:

// Usage example
const q = new QuillLog({
	format: "[{{prefix.gray}}] {{level}} {{date.gray:HH:mm:ss}}: {{msg}}",
	level: {
        Log: {
            color: "white",
            use: 'log',
            format: "[{{prefix.blue.underline.bold}}] {{date.gray.underline.bold:MM/DD HH:mm:ss}} {{msg.white}}",
            prefix: "LOG-INFO",
        },
        Info: {
            color: "white",
            use: 'info',
            format: "[{{prefix.blue.underline.bold}}] {{date.gray.underline.bold:MM/DD HH:mm:ss}} {{msg.white}}",
            prefix: "INFO",
            files: { // optional
                name: "info {{date:YYYY-MM-DD}}.log",
                logDirectory: "./logs/info"
            }
        },
        Error: {
            color: 'red',
            use: 'error',
            prefix: '[ERROR]',
            format: "{{prefix.bold}} {{date:HH:mm:ss}} {{msg}}"
        },
        Debug: {
            color: 'cyan',
            use: 'debug',
            prefix: '[DEBUG]',
            format: "{{prefix.bold}} {{date:HH:mm:ss}} {{msg}}"
        }
    },
    files: { // optional
        logDirectory: "./logs",
        logName: "{{date:YYYY-MM-DD}}.log",
        bufferSize: 100,
        flushInterval: 1000,
        maxFileSize: 1000,
        retentionDays: 10
    }
});
q.log("Log", "hello world");

// Now only the defined levels can be used
q.log("Log", "This is an informational message.");
q.log("Error", "This is an error message.");
// q.log('Debug', "This will throw an error because 'Debug' is not defined.");

Contributing

Contributions are welcome! If you have any ideas or suggestions for improving this project, please feel free to submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for more details.