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

logmux

v2.0.1

Published

A logger multiplexer

Readme

LogMux

A flexible and customizable logging utility for Node.js applications, supporting both ESM and CommonJS modules, with TypeScript support. LogMux provides a simple way to log messages with customizable colors, timestamps, labels, and file logging capabilities.

Features

  • Customizable Logging: Configure log colors, timestamps, and labels.
  • Multiple Log Types: Supports standard logs (Log), error logs (ErrorLog), and warning logs (WarnLog).
  • Timestamp Formats: Choose between Unix timestamp or ISO format.
  • File Logging: Optionally save logs to a file.
  • Color Support: ANSI color codes for console output.
  • TypeScript Support: Fully typed with TypeScript definitions.
  • Dual Module Support: Compatible with both ESM and CommonJS.
  • Configurable Labels: Include or exclude labels, with optional uppercase formatting.

Installation

Install LogMux via npm:

npm install logmux

Usage

Importing LogMux

ESM

import LogMux from 'logmux';

CommonJS

const LogMux = require('logmux');

Basic Example

const logger = new LogMux({
  textColour: 'blue',
  errorColour: 'red',
  warnColour: 'yellow',
  includeLabel: true,
  includeTimeStamp: true,
  timeStampFormat: 'iso',
  recordFile: true,
  uppercaseLabel: true,
});

// Standard log
await logger.Log('This is an info message');

// Error log
await logger.ErrorLog('This is an error message');

// Warning log
await logger.WarnLog('This is a warning message');

Configuration Options

When creating a LogMux instance, you can pass a configuration object with the following properties:

| Option | Type | Default | Description | |---------------------|-----------|---------------|-----------------------------------------------------------------------------| | textColour | string | 'white' | ANSI color for standard logs (e.g., 'blue', 'green'). | | errorColour | string | 'red' | ANSI color for error logs. | | warnColour | string | 'yellow' | ANSI color for warning logs. | | includeLabel | boolean | true | Include a label (e.g., [INFO], [ERROR]) in the log. | | includeTimeStamp | boolean | true | Include a timestamp in the log. | | timeStampFormat | string | 'unix' | Timestamp format: 'unix' (milliseconds) or 'iso' (ISO 8601). | | recordFile | boolean | false | Save logs to a file (logs.txt by default). | | uppercaseLabel | boolean | false | Convert labels to uppercase (e.g., [INFO] instead of [info]). |

Example with Custom Configuration

const logger = new LogMux({
  textColour: 'cyan',
  timeStampFormat: 'unix',
  recordFile: true,
  uppercaseLabel: true,
});

await logger.Log('Custom log message', 'CUSTOM');
// Output: 1746654321000 [CUSTOM] - Custom log message (in cyan)
await logger.ErrorLog('Something went wrong');
// Output: 1746654321000 [ERROR] - Something went wrong (in red)

TypeScript Usage

LogMux is fully typed and works seamlessly with TypeScript. Here's an example:

import LogMux from 'logmux';

const logger = new LogMux({
  textColour: 'green',
  timeStampFormat: 'iso',
  recordFile: true,
});

async function main() {
  await logger.Log('Hello, TypeScript!', 'INFO');
  await logger.WarnLog({ warning: 'Low battery' }, 'BATTERY');
  await logger.ErrorLog(new Error('Critical failure'), 'CRITICAL');
}

main();

File Logging

When recordFile is set to true, logs are saved to logs.txt in the project directory. You can customize the file path by modifying the logToFile function in src/utils.ts if needed.

API

LogMux Class

Constructor

const logger = new LogMux(config);

Methods

  • Log(message: any, label?: string): Promise<void> Logs a standard message with optional custom label.
  • ErrorLog(message: any, label?: string): Promise<void> Logs an error message with optional custom label.
  • WarnLog(message: any, label?: string): Promise<void> Logs a warning message with optional custom label.

Supported Colors

LogMux supports the following ANSI colors for console output:

  • black, red, green, yellow, blue, magenta, cyan, white
  • brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite

Development

To contribute to LogMux or build it locally:

  1. Clone the repository:

    git clone https://github.com/HarshDev1809/logmux.git
  2. Install dependencies:

    npm install
  3. Build the project:

    npm run build
  4. Run tests (if available):

    npm test

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please submit a pull request or open an issue on the GitHub repository for bug reports, feature requests, or suggestions.

Contact

For questions or support, please open an issue on the GitHub repository or contact the maintainers.