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

@grest-ts/logger-console

v0.0.20

Published

Console logger implementation for @grest-ts/logger

Readme

Part of the grest-ts framework. Documentation | All packages

@grest-ts/logger-console

Colored console logger implementation for @grest-ts/logger. Formats log entries with ANSI colors, timestamps, log levels, and context — designed to be readable when a human needs to read logs from the service console – useful for debugging when developing.

Quick Start

import {GG_LOG} from "@grest-ts/logger"
import {GGLoggerConsole} from "@grest-ts/logger-console"

// In your runtime's compose():
GG_LOG.get().addLogger(
    new GGLoggerConsole({showData: true})
)

Output looks like:

14:32:45 12345 INFO  MyService  Starting up
14:32:45 12345 ERROR MyService  Connection failed [stack trace...]

Options

new GGLoggerConsole({
    minLevel?: LogLevel,              // Filter by minimum level (default: LOG_LEVEL env var, or DEBUG)
    showData?: boolean,               // Include data objects in output (default: true)
    timestampFormat?: 'full' | 'time' // 'time' = HH:MM:SS (default), 'full' = YYYY-MM-DD HH:MM:SS
})

The LOG_LEVEL environment variable is respected automatically (DEBUG, INFO, WARN, ERROR, CRITICAL).

Enriching Logs with addContext()

The most useful feature — addContext() lets you inject extra information into every log line. The callback receives the parts array (the segments that make up each log line) and can push additional values into it. These appear between the source name and the message.

Real-World Example

private getLogger() {
    return new GGLoggerConsole({showData: true})
        .addContext((p) => {
            // Service name
            p.push(GGLocator.getScope().serviceName);

            // Trace ID (short) — for correlating logs across services
            if (GG_TRACE.has()) {
                p.push(GG_TRACE.get().spanId.slice(0, 6));
            }

            // Current HTTP request
            if (GG_HTTP_REQUEST.has()) {
                const req = GG_HTTP_REQUEST.get();
                p.push(req.method + " " + req.path);
            }

            // Authenticated user
            if (UserContext.has()) {
                const user = UserContext.get();
                p.push(user.username + "(" + user.id + ")");
            }

            // Tenant/company (multi-tenant apps)
            if (CompanyContext.has()) {
                p.push("C:" + CompanyContext.get().companyId);
            }
        })
}

This produces log lines like:

14:32:45 12345 INFO  OrderService realestate a3f2b1 POST /api/orders john(42) C:7  Creating order

Every part is context-aware — trace IDs, request info, and user context are only present when available (e.g. outside of an HTTP request, those parts are simply omitted). This makes logs self-describing: you can tell exactly which user, request, and service produced each line.

Log Output Format

Each log line is composed of these segments:

[timestamp] [pid] [level] [contextName] [custom context...] [message] [data] [error]
  • timestamp — gray
  • pid — process ID
  • level — color-coded (green=INFO, yellow=WARN, red=ERROR, gray=DEBUG)
  • contextName — cyan, the this or TAG string passed to GGLog.info(this, ...)
  • custom context — added by addContext() providers
  • message — colored by level
  • data — structured data, auto-sanitized (large buffers, files, deep objects are summarized)
  • error — stack traces, validation errors, and debug context are formatted with indentation