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 🙏

© 2024 – Pkg Stats / Ryan Hefner

ngx-logger

v5.0.12

Published

[![npm version](https://badge.fury.io/js/ngx-logger.svg)](https://www.npmjs.com/package/ngx-logger)

Downloads

291,554

Readme

npm version

NGX Logger

NGX Logger is a simple logging module for angular (currently supports angular 6+. Warning : you might need older version of the lib to use older versions of angular). It allows "pretty print" to the console, as well as allowing log messages to be POSTed to a URL for server-side logging.

Join the NGX Logger discord server!

Join our discord server! Get updated on the latest changes and newest feature! Get help faster from the community! Share implementation strategies! Make friends :)

Installation

npm install --save ngx-logger

Once installed you need to import our main module (optionally you will need to import HttpClientModule):

import { LoggerModule, NgxLoggerLevel } from "ngx-logger";
// HttpClientModule is only needed if you want to log on server or if you want to inspect sourcemaps
import { HttpClientModule } from "@angular/common/http";

The only remaining part is to list the imported module in your application module, passing in a config to initialize the logger.

@NgModule({
  declarations: [AppComponent, ...],
  imports:
  [
    // HttpClientModule is only needed if you want to log on server or if you want to inspect sourcemaps
    HttpClientModule,
    LoggerModule.forRoot({
      serverLoggingUrl: '/api/logs',
      level: NgxLoggerLevel.DEBUG,
      serverLogLevel: NgxLoggerLevel.ERROR
    }),
    ...
  ],
  bootstrap: [AppComponent]
})
export class AppModule {
}

Usage

To use the Logger, you will need to import it locally, then call one of the logging functions

import { Component } from "@angular/core";
import { NGXLogger } from "ngx-logger";

@Component({
  selector: "your-component",
  templateUrl: "./your.component.html",
  styleUrls: ["your.component.scss"],
})
export class YourComponent {
  constructor(private logger: NGXLogger) {
    this.logger.error("Your log message goes here");
    this.logger.warn("Multiple", "Argument", "support");
  }
}

For most browsers, you need to enable "verbose" or "debug" mode in the developper tools to see debug logs

Configuration

Configuration is sent by the forRoot call LoggerModule.forRoot({level: NgxLoggerLevel.DEBUG})

For more information about configuration see the doc

Customise logger behavior

Since version 5 NGXLogger is fully customisable

See how in the doc

Features

You can see more of the features supported by NGXLogger in this doc

Demo App

There is a demo application with examples of how to use ngx-logger. To run it perform the following:

  • Clone the repo
  • Run npm ci or npm install
  • Build ngx-logger using ng build
  • Run ng serve demo to serve the app

A convenience script has been added to package.json that performs the above steps. Simply run npm run demo to have the demo built and served.

Dependencies

  • @angular/common
  • @angular/core

Testing Your App When Using NGXLogger

If you inject any of the NGX Logger services into your application, you will need to provide them in your Testing Module.

To provide them in your Testing Module:

import { LoggerTestingModule } from 'ngx-logger/testing';

TestBed.configureTestingModule({
  imports: [
    LoggerTestingModule
  ],
  ...
});

All services have mocked classes that can be used for testing located here

Contribute

All are welcome to contribute to NGX Logger.

See the doc to know how