Discord webhook logger for Node.js. Supports log levels, embeds, timestamps, and error stack traces for real-time monitoring.
npm install discord-logging-handlerbash
npm install discord-logging-handler
`
Usage
Initialise the logger with:
$3
`javascript
import DiscordLog from 'discord-logging-handler';
const logger = new DiscordLog('WEBHOOKURL', { level: 'LEVEL' })
`
Legacy style (Javascript)
`javascript
import DiscordLog from 'discord-logging-handler';
const logger = new DiscordLog('WEBHOOKURL', 'LEVEL')
`
- WEBHOOKURL: Your webhook from Discord Integrations. Use DEV to enable development mode (logs are suppressed during builds/tests).
- LEVEL (optional): The minimum level that should trigger logs to be sent to Discord. Defaults to 'ERROR'.
Send logs with:
`javascript
logInstance.log('Message', 'LEVEL', error)
`
- LEVEL (optional): Log severity- 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'. Defaults to 'INFO'.
- error (optional): An Error object or exception to include in the log. Defaults to null.
$3
`javascript
import DiscordLog from 'discord-logging-handler'
const logger = new DiscordLog('YOUR_WEBHOOK_URL', 'DEBUG')
logger.log('This is an INFO log', 'INFO')
try {
throw new Error('Sample error')
} catch (err) {
logger.log('An error occurred', 'ERROR', err)
}
``