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 🙏

© 2025 – Pkg Stats / Ryan Hefner

acidlog

v1.0.0

Published

A lightweight persistent logger tool using SQLite for storing logs with optional retention and max entries limit.

Readme

acidlog

Canonical URL:
https://alexstevovich.com/a/acidlog-nodejs

Software URL:
https://midnightcitylights.com/software/acidlog-nodejs

Acidlog is a lightweight persistent logger built using SQLite for efficient storage and management of logs. It provides features like automatic log retention, log pruning based on maximum entries, and support for custom loggers.


Installation

npm install acidlog

Example

import AcidLog from 'acidlog';

// Create an instance with a custom retention period and max entries limit
const logger = new AcidLog('./logs/logs.db', {
    retentionDays: 7,
    maxEntries: 5000,
});

// Log entries at different levels
logger.info('System started');
logger.warn('Potential issue detected');
logger.error('Critical error occurred');

// Get the most recent 100 logs
const recentLogs = logger.getRecent(100);
console.log(recentLogs);

// Get logs by level
const errorLogs = logger.getByLevel('error', 50);
console.log(errorLogs);

API

new AcidLog(filePath, options?)

Creates an instance of the AcidLog logger.

Parameters:

  • filePath (string): Path to the SQLite database file where logs will be stored.
  • options (object, optional):
    • retentionDays (number): Number of days to retain logs. Default is 5.
    • maxEntries (number): Maximum number of log entries to store. Default is 10000.
    • logger (object): Custom logger to use internally. Default is console.

log(options)

Records a log entry.

Parameters:

  • level (string): The log level (e.g., "info", "warn", "error").
  • message (string): The log message.
  • system (string, optional): The subsystem or module name.

getRecent(limit = 100)

Returns the most recent limit logs.

Parameters:

  • limit (number): The number of logs to retrieve. Default is 100.

getAll()

Returns all logs, ordered by timestamp (most recent first).


getByLevel(level, limit = 100)

Returns logs filtered by log level (info, warn, error).

Parameters:

  • level (string): The log level to filter by (e.g., info).
  • limit (number): The number of logs to retrieve. Default is 100.

info(message, system = null)

Logs an "info" level message.


warn(message, system = null)

Logs a "warn" level message.


error(message, system = null)

Logs an "error" level message.


createLogger(system = "default")

Creates a logger with a specific system or module name.


Notes

  • Retention: Logs older than the retentionDays value are automatically deleted.
  • Max Entries: If the log entries exceed the maxEntries value, the oldest logs are deleted to keep the database within the set limit.
  • Custom Logger: You can pass a custom logger (like a file logger) if you prefer to log elsewhere, but the default is console.

License

Licensed under the Apache License 2.0.