New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

ng2.logger

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng2.logger

Simple Logger for angular 2

latest
Source
npmnpm
Version
1.0.6
Version published
Weekly downloads
4
-73.33%
Maintainers
1
Weekly downloads
 
Created
Source

NG2 Logger

NG2 Logger is a simple logging module for angular 2. It allows "pretty print" to the console, as well as allowing log messages to be POSTed to a URL for server-side logging.

Dependencies

  • @angular/common
  • @angular/core
  • @angular/http
  • moment

Installation

npm install --save ng2.logger

Once installed you need to import our main module:

import { LoggerModule } from 'ng2.logger';

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

@NgModule({
  declarations: [AppComponent, ...],
  imports: [LoggerModule.forRoot({serverLoggingUrl: '/api/logs', level: 'DEBUG'}), ...],
  bootstrap: [AppComponent]
})
export class AppModule {
}

Usage

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

import { Component } from '@angular/core';
import { NG2Logger } from 'ng2.logger';

@Component({
  selector: 'your-component',
  templateUrl: './your.component.html',
  styleUrls: ['your.component.less']
})
export class YourComponent {
    constructor(private logger: NG2Logger) {
        this.logger.debug('Your log message goes here');
    };
}

Config Options

  • serverLogLevel - Only sends logs to the server for the level specified or higher
  • serverLoggingUrl - URL to POST logs
  • level: The log level. The app will only log message for that level or higher (OFF disables the logger)
TRACE|DEBUG|INFO|LOG|WARN|ERROR|OFF

Server Side Logging

If serverLogginUrl exists, NG2 Logger will attempt to POST that log to the server.

Payload Example {level: 'DEBUG', message: 'Your log message goes here'}

Keywords

angular2

FAQs

Package last updated on 28 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts