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

deadslog

v1.2.2

Published

A dead simple logger module for Node.js

Downloads

60

Readme

deadslog

CI & Publish GitHub issues GitHub pull requests codecov npm npm GitHub

A dead simple logger module for Node.js. Provides console and file-based logging with support for log rotation, custom formatting, colored output, and robust error handling.

✨ Features

  • 🖥 Console and file logging
  • 🔄 Log rotation with delete/archive strategies
  • 🧩 Customizable log formatting
  • 🌈 Colored log levels in console
  • 🧱 Handles undefined/non-serializable messages
  • 🧠 TypeScript type definitions included
  • 🔁 ESM + CommonJS support

📦 Installation

npm install deadslog
# or
bun add deadslog

🚀 Usage

🔹 Basic

import deadslog from "deadslog";
const logger = deadslog();
logger.info("Hello, world!");

🎨 With Custom Formatter

const logger = deadslog({
  formatter: (level, message) => {
    const timestamp = new Date().toLocaleString();
    return `---\nTime: ${timestamp}\nLevel: ${level}\nMessage: ${message}\n---`;
  },
});
logger.info("Custom formatted log!");

📁 File Logging & Rotation

const logger = deadslog({
  fileOutput: {
    enabled: true,
    logFilePath: "./logs/app.log",
    rotate: true,
    maxLogSize: 1024 * 1024, // 1MB
    maxLogFiles: 3,
    onMaxLogFilesReached: "archiveOld", // or "deleteOld"
  },
});
logger.info("This will be written to a file!");

📦 CommonJS Usage

const deadslog = require("deadslog");
const logger = deadslog();
logger.info("Hello from CJS!");

📘 API

deadslog(config)

Returns a logger instance.

⚙️ Configuration Options

| Option | Type | Description | | --------------------------------- | ---------- | -------------------------------------------------------------------------------- | | consoleOutput.enabled | boolean | Enable console logging (default: true) | | consoleOutput.coloredCoding | boolean | Enable colored output using chalk (default: true) | | fileOutput.enabled | boolean | Enable file logging (default: false) | | fileOutput.logFilePath | string | File path for log output (required if file logging is enabled) | | fileOutput.rotate | boolean | Enable automatic log file rotation | | fileOutput.maxLogSize | number | Maximum log file size in bytes before rotation | | fileOutput.maxLogFiles | number | Number of rotated files to keep | | fileOutput.onMaxLogFilesReached | string | Rotation strategy: "deleteOld" or "archiveOld" | | formatter | function | Optional custom formatter for log messages | | minLevel | string | Minimum log level: trace, debug, info, success, warn, error, fatal | | filters.include | string | Word filter to include from log | | filters.exclude | string | Word filter to exclude from log |

🧰 Logger Methods

  • trace(msg)
  • debug(msg)
  • info(msg)
  • success(msg)
  • warn(msg)
  • error(msg)
  • fatal(msg)
  • flush()
  • destroy()

🧠 TypeScript

Type definitions are included and will be picked up automatically.

📚 Formatter Examples For Use

🧾 1. Simple Timestamp Formatter

const simpleFormatter = (level, message) => {
  const timestamp = new Date().toISOString();
  return `[${timestamp}] [${level}] ${message}`;
};
[2025-05-03T13:45:21.123Z] [INFO] Application started

📜 2. Multiline Developer-Friendly Formatter

const multilineFormatter = (level, message) => {
  const timestamp = new Date().toLocaleString();
  return `---\nTime: ${timestamp}\nLevel: ${level}\nMessage: ${message}\n---`;
};
---
Time: 5/3/2025, 1:46:11 PM
Level: DEBUG
Message: Connected to database
---

📁 3. File-Friendly CSV Formatter

const csvFormatter = (level, message) => {
  const timestamp = new Date().toISOString();
  const escaped = message.replace(/"/g, '""');
  return `"${timestamp}","${level}","${escaped}"`;
};
"2025-05-03T13:47:02.789Z","ERROR","Failed to load module: ""auth.js"""

🌈 4. Emoji-Coded Formatter

const emojiFormatter = (level, message) => {
  const emojis = {
    trace: '🔍',
    debug: '🐛',
    info: 'ℹ️',
    success: '✅',
    warn: '⚠️',
    error: '❌',
    fatal: '💀'
  };
  const timestamp = new Date().toISOString();
  return `${emojis[level] || ''} [${timestamp}] ${level}: ${message}`;
};
✅ [2025-05-03T13:48:15.456Z] SUCCESS: Task completed

🪵 5. JSONL (JSON Lines) Formatter for Parsing

const jsonlFormatter = (level, message) => {
  return JSON.stringify({
    ts: Date.now(),
    level,
    message
  });
};
{"ts":1714740493123,"level":"INFO","message":"Something happened"}

Changelog

[v1.2.2] - 2025-05-24

Fixed

  • Types file was not included in the package, causing issues for TypeScript users.

See CHANGELOG.md for previous versions and more details.

License

MIT