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

log-mate

v1.1.0

Published

log-mate makes logging effortless & powerful—log to console, files, databases, or cloud with structured logs, encryption, real-time streaming, and auto-rotation. It’s plug & play, supports multi-transport logging, and boosts performance with async, lazy l

Readme

log-mate

A flexible and powerful logging library for Node.js
log-mate makes logging effortless & powerful—log to console, files, databases, or cloud with structured logs, encryption, real-time streaming, and auto-rotation. It’s plug & play, supports multi-transport logging, and boosts performance with async, lazy logging, and batching. Plus, it keeps your data secure with masking & encryption—perfect for everything from debugging to production!

npm License

📖 Overview

log-mate is a lightweight yet feature-rich logging library for Node.js applications. It provides structured logging, multiple log levels, customizable transports (console, file, database, cloud), log rotation, contextual logging, encryption, and real-time log streaming.

Highly configurable – Customize output formats, storage, and integrations.
Multi-transport support – Log to console, files, databases, cloud, or webhooks.
Structured logging – Supports JSON and other formats.
Contextual logging – Add metadata, user IDs, and request contexts.
Optimized for performance – Lazy evaluation, batching, and async logging.
Secure logging – Mask sensitive data and encrypt logs.


📦 Installation

Install log-mate via npm:

npm install log-mate

or via yarn:

yarn add log-mate

🚀 Usage

Basic Example

const logme = require('log-mate');

logme.trace("This is a trace message");
logme.debug("Debugging details here");
logme.info("Informational message");
logme.warn("This is a warning!");
logme.error("Something went wrong!", { code: 500, details: "Internal Server Error" });
logme.fatal("Critical failure! Shutting down...");
logme.custom("info", "User logged in"); 

Logging to a File

logme.toFile("logs/app.log", { rotation: true });
logme.info("This will be logged to a file.");

Logging to a Database

logme.toDatabase({
    host: "localhost",
    user: "root",
    password: "password",
    database: "logs",
});
logme.info("This message will be stored in the database");

Logging to Cloud (AWS, GCP, Azure)

logme.toCloud("aws", { bucket: "my-log-bucket" });
logme.error("Logging error to the cloud");

Masking Sensitive Data

logme.maskSensitive(["password", "token"]);
logme.info("User logged in with password: 123456 and token: abcdefg");

// OUTPUT: [INFO] User logged in with password: ****** and token: ******

Streaming Logs in Real-Time

logme.enableStreaming(3000); // Streams logs over WebSocket at port 3000
logme.info("Streaming logs in real-time...");

Encrypted Logging

logme.encrypt("my-secret-key");
logme.info("This log is now encrypted!");

Batch Logging

logme.setBatchSize(5);
logme.info("Log message 1");
logme.info("Log message 2");
logme.flush();  // Manually flush logs before batch size is reached

Log Rotation

logme.enableRotation({ maxSize: 1024 * 1024, maxFiles: 3 }); // Rotate at 1MB, keep 3 files
logme.info("This log will be rotated when it reaches max size");

Contextual Logging

logme.setContext({ userId: "1234", sessionId: "abcd" });
logme.info("User performed an action");

// OUTPUT: [INFO] [userId:1234] [sessionId:abcd] User performed an action

Namespace (Scoped) Logging

const authLogger = logme.get("auth");
authLogger("INFO", "User logged in");
// Output: [auth] [INFO] User logged in

Using Plugins

logme.use((message) => console.log(`[PLUGIN] ${message}`));
logme.info("This log passes through a plugin");

CLI Usage

node index.js view logs.txt      # View log file
node index.js clear logs.txt     # Clear log file

📜 API Reference

1️⃣ Core Logging Functions

| Function | Description | |------------------------------|----------------| | logme.trace(message, ...args) | Logs a trace message (detailed debugging). | | logme.debug(message, ...args) | Logs a debug message. | | logme.info(message, ...args) | Logs an informational message. | | logme.notice(message, ...args) | Logs a notice message. | | logme.warn(message, ...args) | Logs a warning message. | | logme.error(message, ...args) | Logs an error message. | | logme.fatal(message, ...args) | Logs a fatal error message. | | logme.custom(level, message, ...args) | Logs with a custom log level. |


2️⃣ Log Output & Transport

| Function | Description | |------------------------------------|----------------| | logme.toConsole(enable = true) | Enables/disables console logging. | | logme.toFile(filepath, options) | Logs messages to a file. | | logme.toDatabase(dbConfig) | Logs messages to a database. | | logme.toCloud(service, options) | Sends logs to AWS, GCP, Azure, etc. | | logme.toWebhook(url, options) | Sends logs to a webhook URL. |


3️⃣ Formatting & Encryption

| Function | Description | |------------------------------------|----------------| | logme.setFormat(type) | Sets log format (json, yaml, text). | | logme.maskSensitive(keys) | Masks sensitive data (e.g., passwords). | | logme.encrypt(key) | Encrypts logs using AES-256. |


4️⃣ Log Rotation & Performance

| Function | Description | |------------------------------------|----------------| | logme.enableRotation(options) | Enables automatic log rotation. | | logme.setBatchSize(size) | Sets batch size for buffered logging. | | logme.flush() | Flushes all batched logs immediately. |


5️⃣ Namespacing & Contextual Logging

| Function | Description | |-----------------------------------|----------------| | logme.get(namespace) | Creates a namespaced logger (log.get("auth")). | | logme.setContext(contextObject) | Adds metadata/context to logs. |


6️⃣ Advanced Features

| Function | Description | |------------------------------------|----------------| | logme.enableStreaming(port) | Streams logs in real-time via WebSocket. | | logme.lazy(() => message) | Lazy logging (evaluates message only if needed). | | logme.retry(attempts, delay) | Retries failed log writes automatically. |


7️⃣ CLI & Plugins

| Function | Description | |-----------------------------------|----------------| | logme.use(plugin) | Loads a plugin (e.g., Slack, Sentry). | | logme.cli() | Provides CLI commands (log-mate view, log-mate clear). |


🛠 Configuration Example

const logme = require("log-mate");

logme.setConfig({
  level: "debug",
  format: "json",
  transports: [
    { type: "console" },
    { type: "file", path: "logs/app.log" }
  ],
  maskSensitive: ["password", "email"],
  encrypt: true
});

console.log(logme.getConfig()); // Check updated config

📌 Features Comparison

| Feature | log-mate | Other Loggers | |------------------------|----------|--------------| | Log Levels | ✅ Yes | ✅ Yes | | File Logging | ✅ Yes | ✅ Yes | | Database Logging | ✅ Yes | ❌ No | | Cloud Integration | ✅ Yes | ❌ No | | Real-time Streaming | ✅ Yes | ❌ No | | Log Encryption | ✅ Yes | ❌ No | | Lazy Logging | ✅ Yes | ❌ No | | Custom Log Levels | ✅ Yes | ✅ Yes |


🤝 Contributing

Contributions are welcome! If you have suggestions or want to add features:

  1. Fork the repo
  2. Create a new branch (feature-name)
  3. Commit your changes
  4. Submit a Pull Request