A lightweight and powerful logging system that sends formatted logs to Discord via webhooks, with zero external dependencies for Discord integration.
- π Multiple predefined log levels (Info, Alert, Error)
- π¨ Customizable log levels with ANSI colors and tags
- π Automatic log buffering and batching for Discord
- πΎ Optional local file logging
- π― Message editing to reduce Discord spam
- π Automatic timestamps on all logs
- π οΈ CLI for easy configuration
- π ANSI color support in Discord and terminal
npm install discord-logify- Go to your Discord server
- Right-click on a channel β Edit Channel
- Go to Integrations β Webhooks
- Click New Webhook or copy an existing one
- Copy the Webhook URL
Edit logger-config.json in your project root:
{
"logFile": true
}Logs will be saved to logify.log in your project root.
import { log } from 'discord-logify';
const logger = new log();// Information log (cyan)
logger.Info('Application started successfully');
// Warning log (yellow)
logger.Alert('Warning: Slow connection detected');
// Error log (red)
logger.Error('Error processing request');Output example:
[06/02/2026 15:30:45] [INFO] Application started successfully
[06/02/2026 15:30:46] [WARN] Warning: Slow connection detected
[06/02/2026 15:30:47] [ERROR] Error processing request
// Add a custom log level
logger.addLogLevel('debug', '35m', '[DEBUG]');
// Use the custom level
logger.Log('Debug message', 'debug');When adding custom log levels, use these color codes (without \x1b[):
31m- Red (Error)33m- Yellow (Warning)36m- Cyan (Info)35m- Magenta32m- Green34m- Blue37m- White
Example:
logger.addLogLevel('success', '32m', '[SUCCESS]'); // Green
logger.addLogLevel('critical', '31m', '[CRITICAL]'); // Redlogify setup <webhook_url>This creates a .env file with your webhook credentials if one doesn't already exist.
logify add-log <prefix> -c <color_code> -t <tag>Example:
logify add-log debug -c "35m" -t "[DEBUG]"
logify add-log success -c "32m" -t "[SUCCESS]"logify configShows all custom log levels in your logger-config.json.
logify logFileToggles the file logging feature on/off.
Custom log levels are stored in logger-config.json:
{
"logFile": true,
"debug": {
"color": "35m",
"prefix": "debug",
"text": "[DEBUG]"
},
"success": {
"color": "32m",
"prefix": "success",
"text": "[SUCCESS]"
}
}- Buffering: Logs are added to an internal buffer
- Batching: After 1 second of inactivity, all buffered logs are sent to Discord
- Message Editing: Subsequent log batches edit the previous Discord message to reduce spam
- ANSI Rendering: Discord renders ANSI color codes using markdown code blocks
- Local Logging: Optionally writes logs to
logify.log(without ANSI codes) - No Dependencies: Uses native Node.js
fetchAPI (Node 18+)
Info(msg: string): Log an info message (cyan)Alert(msg: string): Log a warning message (yellow)Error(msg: string): Log an error message (red)Log(msg: string, prefix: string): Log with a custom leveladdLogLevel(prefix: string, color: string, tag: string): Add a custom log level
WEBHOOK_URL: Full Discord webhook URL (required)
import { log } from 'discord-logify';
const logger = new log();
// Add custom levels
logger.addLogLevel('success', '32m', '[β]');
logger.addLogLevel('debug', '35m', '[DEBUG]');
logger.addLogLevel('critical', '31m', '[ CRITICAL]');
// Use different log levels
logger.Info('Server started on port 3000');
logger.Log('User authenticated successfully', 'success');
logger.Log('Debugging user session', 'debug');
logger.Alert('RAM usage at 80%');
logger.Error('Database connection failed');
logger.Log('CRITICAL: System overload!', 'critical');Discord Output:
[06/02/2026 15:30:45] [INFO] Server started on port 3000
[06/02/2026 15:30:45] [β] User authenticated successfully
[06/02/2026 15:30:45] [DEBUG] Debugging user session
[06/02/2026 15:30:46] [WARN] RAM usage at 80%
[06/02/2026 15:30:47] [ERROR] Database connection failed
[06/02/2026 15:30:47] [ CRITICAL] CRITICAL: System overload!
- π₯οΈ Server Monitoring: Track application health and errors
- π Debugging: Real-time debug logs in Discord
- π Event Tracking: Log important business events
- π¨ Alert System: Get notified of critical issues
- π Analytics: Track user actions and metrics
- π‘οΈ Security: Monitor suspicious activities
- Node.js 18+ (for native
fetchAPI) - Discord webhook URL
dotenvpackage (included as dependency)
- Verify your
WEBHOOK_URLin.env - Check the webhook still exists in Discord
- Ensure your Node.js version is 18+
Discord webhooks have rate limits. The 1-second buffer helps batch logs to avoid hitting limits.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
ISC
txuli
- GitHub: @txuli
- Repository: discord-logify
If you find a bug, please open an issue at: https://github.com/txuli/discord-logify/issues
β If you like this project, give it a star on GitHub!