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

@nwx/logger

v1.0.5

Published

A simple logger module for Angular applications

Downloads

30

Readme

@nwx/logger

A simple logger module for Angular applications

status-image version-image coverage-image download-image

How to install

npm i @nwx/logger |OR| yarn add @nwx/logger

How to use

// In your environment{prod,staging}.ts

import { AppCfg, TargetPlatform, HttpMethod } from '@nwx/cfg';

import { LogLevels } from 'pkgs/logger';

export const environment: AppCfg = {
  // app name
  appName: 'Neekware',
  // target (browser, mobile, desktop)
  target: TargetPlatform.web,
  // production, staging or development
  production: false,
  // one or more app specific field(s)
  log: {
    // Log level, (default = none)
    level: LogLevels.info
  }
};
// In your app.module.ts

import { CfgModule } from '@nwx/cfg';
import { LoggerModule } from '@nwx/logger';
import { environment } from '../environments/environment';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, CfgModule.forRoot(environment), LoggerModule],
  bootstrap: [AppComponent]
})
export class AppModule {}
// In your app.component.ts or (some.service.ts)

import { Component } from '@angular/core';
import { CfgService } from '@nwx/cfg';
import { LoggerService } from '@nwx/logger';

@Component({
  selector: 'app-root'
})
export class AppComponent {
  title = 'Neekware';
  options = {};
  constructor(public cfg: CfgService, public log: LogService) {
    this.title = this.cfg.options.appName;
    this.log.critical('Logging critical');
    this.log.error('Logging error and above');
    this.log.warn('Logging warn and above');
    this.log.info('Logging info and above');
    this.log.debug('Logging debug and above');
  }
}

Note:

  1. @nwx/logger depends on @nwx/cfg for accessing the log level.
  2. You may want to set the log level to LogLevels.debug for development and LogLevels.warn for production.
  3. @nwx/logger should be imported at the root level of your application.
  4. To disable the logger, set the level to LogLevels.none.

Sample logs

CfgService ready ...
2018-05-17T02:47:54.184Z [DEBUG] LogService ready ...
2018-05-17T02:47:54.188Z [DEBUG] GqlService ready ...
2018-05-17T02:47:54.375Z [DEBUG] I18nService ready ... (en)
2018-05-17T02:47:54.378Z [DEBUG] UixService ready ...
2018-05-17T02:47:54.379Z [DEBUG] JwtService ready ...
2018-05-17T02:47:54.384Z [DEBUG] Token expiry ... (21 seconds)
2018-05-17T02:47:54.388Z [DEBUG] AuthService ready ... (loggedIn)
2018-05-17T02:47:54.390Z [DEBUG] UsrService ready ...
2018-05-17T02:47:54.392Z [DEBUG] Web app starting now ...
2018-05-17T02:47:54.406Z [DEBUG] LayoutService ready ...

Running the tests

To run the tests against the current environment:

npm run ci

License

Released under a (MIT) license.

Version

X.Y.Z Version

`MAJOR` version -- making incompatible API changes
`MINOR` version -- adding functionality in a backwards-compatible manner
`PATCH` version -- making backwards-compatible bug fixes