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

@stackra/logger

v2.0.0

Published

Cross-platform logger for the Stackra framework — pluggable reporters, enrichers, and formatters, with React bindings.

Readme

@stackra/logger

Client-side structured logger for the Stackra framework — Laravel-style channels, pluggable reporters, an enrichment pipeline (redaction, interpolation, context, sampling), and React bindings.

Install

pnpm add @stackra/logger @stackra/container @stackra/contracts reflect-metadata

Quick start

import { Module } from "@stackra/container";
import { LoggerModule } from "@stackra/logger";
import { LogLevel } from "@stackra/contracts";

@Module({
  imports: [
    LoggerModule.forRoot({
      default: "app",
      channels: {
        app: {
          driver: "single",
          reporters: ["console"],
          level: LogLevel.DEBUG,
        },
        audit: { driver: "single", reporters: ["json"], level: LogLevel.INFO },
      },
      redact: { paths: ["password", "token", "creditCard.*"] },
    }),
  ],
})
export class AppModule {}

Then anywhere:

import { Injectable } from "@stackra/container";
import { Logger } from "@stackra/logger";

@Injectable()
export class UserService {
  private readonly logger = new Logger(UserService.name);

  create(input: UserInput) {
    this.logger.info("creating user", { email: input.email });
    // …
  }
}

Public API

Logger

Scoped logger created with a class or module name:

const logger = new Logger('MyContext');

logger.debug('...', context?);
logger.info('...', context?);
logger.notice('...', context?);
logger.warn('...', context?);
logger.error('...', context?);
logger.critical('...', context?);
logger.alert('...', context?);
logger.emergency('...', context?);

logger.log(LogLevel.INFO, '...', context?);

// Named channel selection
logger.channel('audit').info('user deleted', { userId });

// Enriched sub-logger
const scoped = logger.withContext({ userId: 5 });
scoped.info('...'); // includes userId automatically

Channels

A channel is a named log destination composed of one or more reporters:

LoggerModule.forRoot({
  default: "app",
  channels: {
    app: { driver: "single", reporters: ["console"] },
    audit: { driver: "single", reporters: ["json"] },
    errors: { driver: "stack", channels: ["console", "audit"] },
  },
});

Drivers: single (one reporter list), stack (fan out to other named channels), daily/rotating (via plugin).

Reporters

Built-in reporters — auto-discovered via @Reporter():

| Name | Purpose | | --------- | ---------------------------------------- | | console | Pretty-printed console output with color | | json | One JSON line per log record | | silent | Discards everything — useful for tests |

Custom reporter:

import { Injectable } from "@stackra/container";
import { Reporter, type IReporter, type ILogRecord } from "@stackra/logger";

@Reporter({ name: "sentry" })
@Injectable()
class SentryReporter implements IReporter {
  report(record: ILogRecord): void {
    if (record.level >= LogLevel.ERROR)
      Sentry.captureMessage(record.message, { extra: record.context });
  }
}

Register it as a provider anywhere in your DI graph — the ReporterLoader scans providers at bootstrap and registers everything with @Reporter metadata.

Enrichment pipeline

Each log record passes through enrichers in order before reaching reporters:

  1. InterpolationEnricher — resolves {placeholder} substitutions.
  2. ContextEnricher — folds ContextRepository state (per-request or per-user) into every record.
  3. RedactionEnricher — deep-scrubs any path listed in config.redact.paths (supports foo.* wildcards).

Extend the pipeline by writing a class that implements IEnricher from @stackra/contracts and declaring it as a DI provider.

Environment overrides

mergeConfig layers env vars on top of user options:

| Variable | Effect | | --------------------- | ----------------------------------------------- | | LOG_LEVEL=debug | Forces every channel to the given minimum level | | APP_DEBUG=true | Same as LOG_LEVEL=debug | | NODE_ENV=production | Silences debug-only channels |

React bindings — @stackra/logger/react

import { useLogger } from "@stackra/logger/react";

function Panel() {
  const logger = useLogger("Panel");
  logger.info("rendered");
  return <div />;
}

Also ships <LogLevelSwitcher />, <LogChannelInspector />, and <LogEventStream /> for in-app debug UI.

Testing helper — @stackra/logger/testing

import {
  createMockLogger,
  createMockLoggerManager,
} from "@stackra/logger/testing";

// Standalone logger — for tests that inject a single ILogger
const logger = createMockLogger();
service.doThing(logger);
logger.$.assertCalled("info").with("did the thing").once();

// Full manager — for tests that resolve LOGGER_MANAGER and call .create()
const manager = createMockLoggerManager();
service.setup(manager);
const scoped = manager.getLogger("UserService");
expect(scoped?.getLogsByLevel("error")).toHaveLength(1);

Both mocks fully implement their contracts (ILogger — all 11 methods, ILoggerManagercreate() and channel()). Logs are appended to .logs in the order they occurred with level, message, and context intact.

Configuration

Copy the template:

mkdir -p src/config
cp node_modules/@stackra/logger/config/logger.config.ts src/config/logger.config.ts

Then in app.module.ts:

import { loggerConfig } from "@/config/logger.config";
LoggerModule.forRoot(loggerConfig);

Subpaths

| Import | Purpose | | ------------------------- | --------------------------------------------------- | | @stackra/logger | Core Logger, LoggerModule, Reporter decorator | | @stackra/logger/react | React hooks + debug components | | @stackra/logger/testing | createMockLogger() |

License

MIT