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

logger-core

v0.5.1

Published

logger core

Readme

logger-core

A lightweight, dependency-free JSON logger for Node.js and TypeScript.

  • 📄 Structured JSON logging
  • 🎯 Configurable log levels
  • ⚙️ Runtime configuration
  • 🏷 Custom log field names
  • 🔖 Constant fields
  • 🚀 Fast and simple
  • 💡 Written in TypeScript

Unlike traditional text loggers, every log entry is emitted as a JSON object, making it ideal for log aggregation systems such as Elasticsearch, Kibana, Splunk, Datadog, Google Cloud Logging, and AWS CloudWatch.


Installation

npm install logger-core

or

yarn add logger-core

Use Cases

  • REST APIs
  • Microservices
  • Serverless Functions
  • Docker Containers
  • Kubernetes
  • Cloud Run
  • AWS Lambda
  • Google Cloud Functions
  • Azure Functions

Examples:

REST API

Import Data

Export Data

Message Queue


Quick Start

import { createLogger } from "logger-core";

const logger = createLogger({});

logger.info("Application started");
logger.warn("Low memory");
logger.error("Database unavailable");

Output

{
    "level":"info",
    "time":"2026-07-02T09:00:00.123Z",
    "msg":"Application started"
}

Configuration

import { createLogger } from "logger-core";

const logger = createLogger({
    level: "INFO"
});

Supported levels

| Level | Description | |--------|-------------| | TRACE | Everything | | DEBUG | Debug information | | INFO | General information | | WARN | Warning messages | | ERROR | Errors | | PANIC | Serious errors | | FATAL | Fatal errors |


Logging

logger.trace("trace");
logger.debug("debug");
logger.info("info");
logger.warn("warn");
logger.error("error");
logger.panic("panic");
logger.fatal("fatal");

Structured Data

Additional properties can be attached to every log.

logger.info("User login", {
    userId: 100,
    username: "john",
    ip: "192.168.1.10"
});

Output

{
    "level":"info",
    "time":"2026-07-02T10:00:00.123Z",
    "msg":"User login",
    "userId":100,
    "username":"john",
    "ip":"192.168.1.10"
}

Constant Fields

Fields that should appear in every log.

const logger = createLogger({
    constants: {
        service: "payment-service",
        version: "1.0.0",
        environment: "production"
    }
});

Output

{
    "service":"payment-service",
    "version":"1.0.0",
    "environment":"production",
    "level":"info",
    "time":"...",
    "msg":"Application started"
}

Custom Field Names

Default fields are

{
    "time":"...",
    "level":"INFO",
    "msg":"..."
}

They can be customized.

const logger = createLogger({
    map: {
        time: "@timestamp",
        level: "severity",
        msg: "message"
    }
});

Output

{
    "@timestamp":"...",
    "severity":"INFO",
    "message":"Application started"
}

Useful for Elasticsearch and Google Cloud Logging.


Custom Log Level Names

The displayed level names can be changed.

import { createLogger } from "logger-core";

const logger = createLogger({
    name: {
        trace: "TRACE",
        debug: "DEBUG",
        info: "INFORMATION",
        warn: "WARNING",
        error: "ERROR",
        panic: "PANIC",
        fatal: "FATAL"
    }
});

Output

{
    "level":"INFORMATION",
    "time":"...",
    "msg":"Application started"
}

Runtime Configuration

The logger configuration can be changed without restarting the application.

import * as http from "http";
import { createLogger, LogController } from "logger-core";

const logger = createLogger({
    level: "INFO"
});

const controller = new LogController(logger);

http.createServer(controller.config)
    .listen(8080);

Update log level

POST /config
Content-Type: application/json

{
    "level":"DEBUG"
}

Update field names

{
    "map":{
        "time":"@timestamp",
        "level":"severity",
        "msg":"message"
    }
}

Update constants

{
    "constants":{
        "service":"user-service",
        "environment":"production"
    }
}

Custom Output

Logs can be redirected anywhere.

const logger = createLogger(
    {},
    undefined,
    undefined,
    console.error,
    message => {

        // write to Kafka

        // write to Elasticsearch

        // write to file

        // send to Cloud Logging

        console.log(message);

    }
);

API

createLogger()

createLogger(config)

Creates a new logger.


Logger

logger.trace()
logger.debug()
logger.info()
logger.warn()
logger.error()
logger.panic()
logger.fatal()

isXXXEnabled()

logger.isTraceEnabled()

logger.isDebugEnabled()

logger.isInfoEnabled()

logger.isWarnEnabled()

logger.isErrorEnabled()

logger.isPanicEnabled()

logger.isFatalEnabled()

Useful for expensive logging.

if (logger.isDebugEnabled()) {

    logger.debug(
        expensiveCalculation()
    );

}

Example Output

{
    "service":"payment-service",
    "version":"1.2.0",
    "environment":"production",
    "level":"INFO",
    "time":"2026-07-02T09:18:10.123Z",
    "msg":"Order created",
    "orderId":100,
    "userId":55
}

Features

  • Lightweight
  • Zero runtime dependencies
  • TypeScript support
  • Structured JSON logs
  • Runtime configuration
  • Custom log levels
  • Custom field names
  • Constant fields
  • Pluggable output
  • Node.js compatible

License

MIT