Skip to content

karan1276/LogBook

Repository files navigation

alt tag

angular2-log-book

Note: work in progress, not ready for use!

Installation

To install this library, run:

$ npm install angular2-log-book --save

Usage

Installation

To install this library, run:

$ npm install angular2-log-book --save

Adding library

Add the library in your angular 2 project. If you are following the [Angular 2's Quickstart Guide] (https://angular.io/docs/ts/latest/quickstart.html) it should be something like this:

        import { NgModule }      from '@angular/core';
        import { BrowserModule } from '@angular/platform-browser';
        import { AppComponent }  from './app.component';
        import { LogBook } from "angular2-log-book/core"; // <-- ADD THIS
    
        @NgModule({
            imports:      [ BrowserModule ],
            declarations: [ AppComponent ],
            bootstrap:    [ AppComponent ],
            providers:    [ LogBook ] // <-- AND THIS
        })
        export class AppModule { }

Use it

    @Component({
        ...
    })
    export class AppComponent(){
        constructor( private $log: LogBook ){
            this.log.error('This is a priority level 1 error message...');
            this.log.warn('This is a priority level 2 warning message...');
            this.log.info('This is a priority level 3 warning message...');
            this.log.verbose('This is a priority level 4 debug message...');
            this.log.debug('This is a priority level 5 log message...');
            this.log.silly('This is a priority level 6 log message...');
        }
    }

Functions

Supports log levels:

Supported log levels are error, warn, info, verbose, debug and silly. To log at a certain level write:

this.log.level_name('Hello world!');

replace level_name with error, warn, info, verbose, debug and silly.

Setting a log level

Set your log level:

this.log.set_level('Info');
// or
this.log.set_level(3);

Timestamp

//Enable timestamp
this.log.enableTimestamp();

//Disable timestamp
this.log.disableTimestamp();

Custom formatter

comming soon. want something like this

Sending logs to serve

comming soon

Callback emitter

comming soon

Development

To generate all *.js, *.js.map and *.d.ts files:

$ npm run tsc

To lint all *.ts files:

$ npm run lint

License

MIT © Karan Sharma

About

Flexible logging library for Angular 2 ❤

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published