New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

acidlog

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

acidlog

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

latest
npmnpm
Version
1.0.0
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

logging

FAQs

Package last updated on 12 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts