discord-logger

Log events from nodejs to discord using webhooks

Usage no npm install needed!

<script type="module">
  import discordLogger from 'https://cdn.skypack.dev/discord-logger';
</script>

README

discord logger

Dependency

  • request library for sending requests

Installation

Using npm:

$ npm install discord-logger

How to use

In Node.js:

const DiscordLogger = require('discord-logger');
const options = {
  endpoint: process.env.DISCORD_WEBHOOK,
  botUsername: 'my app logger'
  infoPrefix: ':information_source:' // optional, default value is :information_source:,
  successPrefix: ':white_check_mark:' // optional, default value is :white_check_mark:,
  errorPrefix: ':sos:' // optional, default value is :sos:
}

const logger = new DiscordLogger(options);

// Send message to discord channel associated with provided hook
logger.info('This is regular info message.');
logger.success('Another message, but very successful this time.');
logger.error('Oops! Something is wrong!');

Output:

Author

maleta

Licence

MIT