Note: work in progress, not ready for use!
To install this library, run:
$ npm install angular2-log-book --save
To install this library, run:
$ npm install angular2-log-book --save
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 { }
@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...');
}
}
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
.
Set your log level:
this.log.set_level('Info');
// or
this.log.set_level(3);
//Enable timestamp
this.log.enableTimestamp();
//Disable timestamp
this.log.disableTimestamp();
comming soon. want something like this
comming soon
comming soon
To generate all *.js
, *.js.map
and *.d.ts
files:
$ npm run tsc
To lint all *.ts
files:
$ npm run lint
MIT © Karan Sharma