npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

huloger

v2.4.0

Published

A customizable logging module for Discord bots, supporting console, file, and Discord channel logs with advanced features.

Downloads

62

Readme

Welcome to Huloger! Simplified logging module

Because logging doesn’t have to be boring...

What is Huloger?

Huloger is a customizable, versatile and professional logging module developed for use in Node.js projects. It is designed specifically for Discord bots, but can be used in any Node.js application. It can send the logging process to files, console and Discord Webhooks, and create records in JSON format or user-defined format. Because why not ^^

Features of Huloger

  • Multi-Channel Logging: Console, file and Discord Webhook support.
  • Cyclic File System: A system that rotates log files when the maximum size is reached.
  • Log Levels: Logging at debug, info, warn, error levels.
  • JSON Format Support: Logs can be written in JSON format.
  • Time Format: ISO, UTC or local date formats.
  • Error Trapping: Automatically captures and logs unhandledRejection and uncaughtException errors.
  • Multiple Output Support: Simultaneous logging to multiple files and webhooks.

Setuping

  1. Module Installation
npm install huloger

So much :) (sshh yes that's it. No fancy rituals or sacrifices needed. 🤓)

Usage

  1. Importing the Module Like every good relationship, it starts with an introduction:
const Huloger = require('huloger');
  1. Basic Configuration Huloger is defined as an object. It can be configured with the following options during installation. Huloger makes chopping down trees so easy you'll wonder how you ever survived before.
const logger = new Huloger({
  logFile: 'application.log',                                                      // Log File Name
  webhookUrl: 'https://discord.com/api/webhooks/xxxx/yyyy',                        // Discord Webhook URL
  logLevel: 'info',                                                                // Minimum log level
  enableJson: true,                                                                // Writing logs in JSON format
  timeFormat: 'iso',                                                               // Time format: 'iso', 'utc', 'local'
  outputs: [
    { type: 'file', path: './extra.log' },                                         // Additional file output
    { type: 'discord', webhookUrl: 'https://discord.com/api/webhooks/xxxx/yyyy' }, // Additional Discord Webhook output
  ],
});

Logging Procedures

  1. Basic Logging Huloger can log at certain levels using the following methods:
logger.debug('A debug level message.');
logger.info('An informative message.');
logger.warn('Warning message!');
logger.error('Error message!');
  1. Logging to Multiple Outputs
logger.logToMultiple('info', 'This message was logged in multiple places.');

Error Trapping

Huloger can log unexpected errors with its automatic error trapping feature:

  • Unhandled Rejections: Catches Promise errors.
  • Uncaught Exceptions: Catches unexpected errors that occur while the code is running.

Example:

setTimeout(() => {
  throw new Error('This is a testing error!');
}, 3000);

Configuration Options

| Parameter | Default Value | Description | |----------------|-----------------|--------------------------------------------------------------| | logFile | bot.log | The name of the file where logs will be stored. | | webhookUrl | null | Discord Webhook URL. | | logLevel | info | Minimum log level (debug, info, warn, error). | | enableJson | false | Whether logs will be stored in JSON format. | | timeFormat | iso | Time format (iso, utc, local). | | outputs | [] | Additional log outputs (files or Discord Webhooks). |

Huloger API

  1. Methods log(level, message) Writes logs at the specified level.
  • level: Log level (debug, info, warn, error).
  • message: The message to be logged.
logger.log('info', 'This is a informative message.');

logToMultiple(level, message) Sends logs to multiple outputs.

  • level: Log level.
  • message: The message to be logged.

debug(message) Writes logs at debug level.

info(message) Writes logs at information level.

warn(message) Writes logs at warning level.

error(message) Writes log at error level.

Sample Application

const Huloger = require('huloger');

const logger = new Huloger({
  logFile: 'app.log',
  webhookUrl: process.env.WEBHOOK_URL,
  logLevel: 'debug',
  enableJson: true,
  timeFormat: 'utc',
});

logger.debug('Debug message.');
logger.info('İnfo message.');
logger.warn('Warn message!');
logger.error('Error message!');

Advanced Configuration

Huloger can determine configuration parameters by reading the .env file:

LOG_FILE=bot.log
WEBHOOK_URL=https://discord.com/api/webhooks/xxxx/yyyy
LOG_LEVEL=info
ENABLE_JSON=true
TIME_FORMAT=iso

Debugging

Things not working as expected? If you are having problems with Huloger, follow these steps:

  1. Set your log level to debug.
  2. Check log files (bot.log or another log file).
  3. Make sure you configure the Discord Webhook URL correctly. (don’t make it cry 😢)

License

Huloger is free and open under the Apache-2.0 license. Go ahead, make it yours. (I wasn't serious, no one should take it 🥹)

Finish

AANDD THAT'S ITT! No one wants to miss this amazing moment! Let's install now and start using Hulogerr! Umm... Yes that was it, goodbye. 🙂