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

tango-es6-logger

v1.0.8

Published

Simple ES6 JavaScript Logger

Readme

tango-es6-logger

A lightweight, dependency-free logger for Node.js projects built using ES6 modules.

tango-es6-logger provides a minimal, explicit logging API with configurable log levels and output modes (console or file). It is intentionally simple, predictable, and easy to reason about.


✨ Features

  • Six log levels
    TRACE < DEBUG < INFO < WARN < ERROR < FATAL

  • Process-wide log level control
    Only messages at or above the configured level are generated.

  • Multiple output modes

    • Console
    • File
  • ES6 module support

    • Clean import syntax
    • No CommonJS boilerplate
  • Zero runtime dependencies

  • Colorized console output for improved readability


📦 Installation

npm install tango-es6-logger

🚀 Quick Start

import logLevel from 'tango-es6-logger';
import * as logger from 'tango-es6-logger';

logger.setGlobalLogLevel(logLevel.DEBUG);
logger.setLogMode(logger.logMode.CONSOLE);

logger.logIt(logLevel.INFO, 'Application started');

🧪 Examples

Example 1 — Log to a File

logger.setGlobalLogLevel(logLevel.TRACE);
logger.setLogMode(logger.logMode.FILE, 'myLogFile.txt');

logger.logIt(logLevel.WARN, 'This message will be written to myLogFile.txt');

Example 2 — Log Suppression via Log Level

logger.setGlobalLogLevel(logLevel.ERROR);
logger.setLogMode(logger.logMode.CONSOLE);

logger.logIt(
  logLevel.TRACE,
  'This message will not be generated because TRACE < ERROR'
);

Example 3 — Console Logging

logger.setGlobalLogLevel(logLevel.DEBUG);
logger.setLogMode(logger.logMode.CONSOLE);

logger.logIt(
  logLevel.DEBUG,
  'This message will appear because DEBUG >= DEBUG'
);

🧠 Logging Model

A log message is generated only if:

messageLogLevel >= globalLogLevel

This is not filtering.

Messages below the configured log level are never created, not merely hidden.


📚 Public API

tango-es6-logger exposes:

  • 2 enums
  • 3 functions

Enums

logLevel (default export)

TRACE | DEBUG | INFO | WARN | ERROR | FATAL

Used to:

  • Set the configured log level
  • Specify the level of individual log messages

logMode

CONSOLE | FILE

Used to define where log messages are written.


Functions

setLogMode(logMode[, filePathAndName])

logger.setLogMode(logger.logMode.CONSOLE);
logger.setLogMode(logger.logMode.FILE, 'logs/app.log');
  • Sets where log messages are written
  • When using FILE, a file path must be provided
  • Invalid configurations fail immediately
  • Can be called multiple times — the most recent call wins

setGlobalLogLevel(logLevel)

logger.setGlobalLogLevel(logLevel.WARN);
  • Defines the minimum log level that will be generated
  • Can be changed at runtime
  • Returns the effective log level that was set

logIt(messageLogLevel, message)

logger.logIt(logLevel.INFO, 'Processing request');
  • Requests generation of a log entry
  • The message is generated only if
    messageLogLevel >= globalLogLevel
  • Returns true if the message was generated, otherwise false

📌 Defaults

If not explicitly set:

  • logMode defaults to CONSOLE
  • globalLogLevel defaults to TRACE

📥 Importing Notes

Because logLevel is used frequently, it is exported as the default export:

import logLevel from 'tango-es6-logger';

logLevel.WARN;

All other exports are named:

import * as logger from 'tango-es6-logger';

logger.setGlobalLogLevel(logLevel.TRACE);
logger.setLogMode(logger.logMode.CONSOLE);
logger.logIt(logLevel.DEBUG, 'Debug message');

🕒 Log Output Format

  • Each log entry is prefixed with the current date and time (ISO-8601)
  • Console output includes foreground and background colors for clarity

Standard Output vs Standard Error

When logMode is set to CONSOLE, log messages are routed to either standard output (stdout) or standard error (stderr) based on the log level.

The mapping is intentional and consistent:

| Log Level | Output Stream | |----------|---------------| | TRACE | stdout | | DEBUG | stdout | | INFO | stdout | | WARN | stderr | | ERROR | stderr | | FATAL | stderr |

This behavior aligns with common operational practices in Unix-like environments, containers, CI pipelines, and process supervisors.

It allows informational output to be consumed normally while enabling warnings and errors to be captured, redirected, or filtered independently.

This routing applies only when logMode is set to CONSOLE.


🎯 Design Philosophy

tango-es6-logger is intentionally minimal.

  • Explicit configuration over implicit behavior
  • Log messages are generated, not filtered
  • Predictable, process-wide state
  • No global namespace pollution
  • No unnecessary abstractions