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 🙏

© 2026 – Pkg Stats / Ryan Hefner

vloggo

v1.0.3

Published

Logging library for Node.js and Bun with file rotation, SMTP notifications, and JSON output support.

Readme

VLoggo

Logging library for Node.js and Bun with file rotation, SMTP notifications, and JSON output support.

Features

  • Multiple log levels: INFO, WARN, DEBUG, ERROR, FATAL
  • Automatic file rotation: Daily rotation with configurable retention
  • SMTP notifications: Email alerts for fatal errors with throttling
  • JSON output: Optional structured logging in JSONL format
  • Caller tracking: Automatic source file and line number tracking
  • TypeScript support: Full type definitions included
  • Zero configuration: Works out of the box with sensible defaults

Installation

npm install vloggo
bun add vloggo

Quick Start

import { VLoggo } from "vloggo";

const logger = new VLoggo({ client: "MyApp" });

logger.info("APP_START", "Application started");
logger.warn("HIGH_MEMORY", "Memory usage above 80%");
logger.error("API_FAIL", "External API request failed");
logger.fatal("DB_DOWN", "Database connection lost");

Configuration

Basic Configuration

const logger = new VLoggo({
  client: "MyApp",    // Application name
  console: true,      // Enable console output
  debug: false,       // Enable debug logs
  json: false,        // Enable JSON output
});

File Configuration

const logger = new VLoggo({
  client: "MyApp",
  directory: {
    txt: "/var/log/myapp",       // Text log directory
    json: "/var/log/myapp/json", // JSON log directory
  },
  filecount: {
    txt: 31,   // Keep 31 days of text logs
    json: 7,   // Keep 7 days of JSON logs
  },
});

SMTP Configuration

const logger = new VLoggo({
  client: "MyApp",
  smtp: {
    host: "smtp.gmail.com",
    port: 465,
    secure: true,
    username: "[email protected]",
    password: "your-password",
    from: "[email protected]",
    to: "[email protected]",        // Can be string or array
  },
  throttle: 300000,  // Min 5 minutes between emails
});

Environment Variables

SMTP can be configured via environment variables:

SMTP_HOST=smtp.gmail.com
SMTP_PORT=465
[email protected]
SMTP_PASSWORD=your-password
[email protected]
[email protected]

API Reference

Constructor

new VLoggo(options?: Partial<VLoggoConfig>)

Options:

  • client: Application name (default: 'VLoggo')
  • console: Enable console output (default: true)
  • debug: Enable debug mode (default: false)
  • json: Enable JSON output (default: false)
  • directory: Log directories (default: ~/[client]/logs for txt, ~/[client]/json for json)
  • filecount: Retention days (default: { txt: 31, json: 31 })
  • smtp: SMTP configuration (optional)
  • notify: Enable notifications (default: false, automatically set to true if smtp is configured)
  • throttle: Email throttle in ms (default: 30000)

Logging Methods

logger.info(code: string, message: string): void
logger.warn(code: string, message: string): void
logger.debug(code: string, message: string): void
logger.error(code: string, message: string): void
logger.fatal(code: string, message: string): void

Parameters:

  • code: Short identifier for the log entry
  • message: Detailed log message

Configuration Access

// Read configuration (readonly)
logger.config.client;      // string
logger.config.debug;       // boolean
logger.config.console;     // boolean
logger.config.json;        // boolean
logger.config.directory;   // VLoggoDirectory
logger.config.filecount;   // VLoggoFilecount
logger.config.notify;      // boolean
logger.config.smtp;        // VLoggoSMTPConfig | undefined
logger.config.throttle;    // number

// Clone configuration
const newLogger = new VLoggo(
  logger.config.clone({ client: "NewApp" })
);

// Update configuration
logger.config.update({ 
  debug: true, 
  throttle: 60000 
});

Log Format

Text Format

[MyApp] [04/11/2025 14:30:45] [INFO] [APP_START] [server.ts:15]: Application started

JSON Format (JSONL)

{
  "client": "MyApp",
  "timestamp": "2025-11-04T14:30:45.123Z",
  "level": "INFO",
  "code": "APP_START",
  "caller": "server.ts:15",
  "message": "Application started"
}

File Rotation

  • Logs rotate daily at midnight
  • Old logs are automatically deleted based on filecount setting
  • Separate rotation for text and JSON logs
  • Rotation happens asynchronously without blocking logging

Email Notifications

  • Only sent for fatal() logs
  • Throttled to prevent spam (configurable via throttle)
  • Includes timestamp, code, caller location, and message
  • HTML formatted emails
  • Requires SMTP configuration via options or environment variables

TypeScript Types

The library exports the following types:

import { 
  VLoggo, 
  VLoggoConfig, 
  VLoggoSMTPConfig,
  VLoggoDirectory,
  VLoggoFilecount,
  LogLevel, 
  LogEntry 
} from "vloggo";

// LogLevel type
type LogLevel = "INFO" | "WARN" | "ERROR" | "FATAL" | "DEBUG";

// LogEntry interface
interface LogEntry {
  level: LogLevel;
  timestamp: string;
  code: string;
  caller: string;
  message: string;
}

Examples

Express.js Integration

import express from "express";
import { VLoggo } from "vloggo";

const app = express();
const logger = new VLoggo({ client: "API" });

app.use((req, res, next) => {
  logger.info("REQUEST", `${req.method} ${req.path}`);
  next();
});

app.use((err, req, res, next) => {
  logger.error("ERROR", err.message);
  res.status(500).json({ error: "Internal Server Error" });
});

Database Connection Monitoring

async function connectDatabase() {
  try {
    await db.connect();
    logger.info("DB_CONNECT", "Database connected successfully");
  } catch (error) {
    logger.fatal("DB_CONNECT_FAIL", error.message);
    process.exit(1);
  }
}

Scheduled Task Logging

import cron from "node-cron";

cron.schedule("0 0 * * *", () => {
  logger.info("CRON_START", "Daily cleanup task started");

  try {
    performCleanup();
    logger.info("CRON_SUCCESS", "Daily cleanup completed");
  } catch (error) {
    logger.error("CRON_FAIL", error.message);
  }
});

Performance Considerations

  • File writes are synchronous for data integrity
  • Rotation is asynchronous to avoid blocking
  • Email sending is asynchronous with error handling
  • Minimal overhead for disabled features

License

MIT

Support

For issues and feature requests, visit: https://github.com/vinialx/vloggo/issues

Author

Email: [email protected]