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

@pubfunc/ngx-common-log

v0.0.1

Published

A flexible logging library for Angular applications with support for multiple transports, log levels, namespaces, and dependency injection.

Readme

@pubfunc/ngx-common-log

A flexible logging library for Angular applications with support for multiple transports, log levels, namespaces, and dependency injection.

Features

  • Transport system: Pluggable transports (Browser Console, Stackdriver, custom)
  • Namespaces: Organize logs with hierarchical namespaces
  • Angular DI support: Use dependency injection or static logging
  • Context support: Attach structured data and error objects to logs

Installation

npm install @pubfunc/ngx-common-log

Usage

Static Logger

Configure the static logger for application-wide use:

import { Log, LogLevel, BrowserConsoleTransport } from '@pubfunc/ngx-common-log';

Log.configure({
  level: LogLevel.DEBUG,
  transport: new BrowserConsoleTransport(),
  namespace: 'MyApp',
});

Use the static logger:

import { Log } from '@pubfunc/ngx-common-log';

Log.trace('Detailed trace information');
Log.debug('Debug information', { context: { userId: 123 } });
Log.info('Application started');
Log.warn('Deprecated API used', { context: { api: 'oldEndpoint' } });
Log.error('An error occurred', {
  error: e,
  context: {
    id: 123,
    action: 'saveUser',
  },
});

Dependency Injection

Provide the logger in your Angular application:

import { provideLogger, LogLevel, BrowserConsoleTransport } from '@pubfunc/ngx-common-log';

bootstrapApplication(AppComponent, {
  providers: [
    provideLogger({
      level: LogLevel.DEBUG,
      transport: new BrowserConsoleTransport(),
      namespace: 'MyApp',
    }),
    // ... other providers
  ],
});

Inject and use the logger in components or services:

import { Component, inject } from '@angular/core';
import { injectLogger } from '@pubfunc/ngx-common-log';

@Component({
  selector: 'app-my-component',
  template: '...',
})
export class MyComponent {
  private log = injectLogger('MyComponent');

  ngOnInit() {
    this.log.info('Component initialized');
  }

  handleError(error: Error) {
    this.log.error('Failed to load data', {
      error,
      context: { component: 'MyComponent' },
    });
  }
}

Log Levels

The library supports five log levels (from most verbose to least):

  • LogLevel.TRACE - Very detailed information for debugging
  • LogLevel.DEBUG - Debug information for development
  • LogLevel.INFO - General informational messages
  • LogLevel.WARN - Warning messages for potentially harmful situations
  • LogLevel.ERROR - Error messages for error events

Logs below the configured level are filtered out.

Transports

Browser Console Transport

Formats logs with styled output for browser console:

import { BrowserConsoleTransport } from '@pubfunc/ngx-common-log';

const transport = new BrowserConsoleTransport();

Stackdriver Transport

Formats logs as JSON for Google Cloud Logging:

import { StackdriverTransport } from '@pubfunc/ngx-common-log';

const transport = new StackdriverTransport();

Custom Transport

Create your own transport by implementing ILogTransport:

import { ILogTransport, ILogObject } from '@pubfunc/ngx-common-log';

class CustomTransport implements ILogTransport {
  push(logObject: ILogObject) {
    // Your custom logging logic
    // e.g., send to external service, write to file, etc.
  }
}

Namespaces

Namespaces help organize logs hierarchically. When using dependency injection, you can create subnamespaces:

export class UserService {
  private log = injectLogger('UserService');

  getUser(id: string) {
    const userLog = this.log.createSubnamespace('getUser');
    userLog.debug('Fetching user', { id });
    // Logs will appear as: MyApp/UserService/getUser
  }
}

Context and Error Objects

Attach structured context data and error objects to any log:

this.log.error('Payment processing failed', {
  error: paymentError,
  context: {
    userId: '123',
    orderId: '456',
    amount: 99.99,
    paymentMethod: 'credit_card',
  },
});