ionic-logger-new
v0.4.9
Published
Ionic 2+ plugin providing a logger service.
Downloads
4
Maintainers
Readme
Ionic Logger
This plugin is modified to add an option to skip the writing to file and log rotations
Ionic 2+ plugin providing a logger service.
Installation
Make sure you have Ionic and Angular installed.
npm install --save ionic-logger
Check you peer-dependencies warnings after npm install
to make sure you are using a version in accordance to your Ionic version.
Import
import { IonicLoggerModule, Logger } from 'ionic-logger';
@NgModule({
imports: [
IonicLoggerModule.forRoot({
docDir: 'MyApp',
logDir: 'log'
})
],
providers: [
Logger
]
})
export class AppModule {}
Config
| Options | Type | Description | | --------------- |:---------| :------------| | docDir | string | Document directory. Defaults to 'ionic-logger' | | logDir | string | Log directory inside docDir. Defaults to 'log' | | logDayFormat | string | Day format. Defaults to 'YYYY-MM-DD' | | logHourFormat | string | Hour format. Defaults to 'HH:mm:ss:SSS' | | debug | boolean | Boolean to enable debug mode. Defaults to false |
Example
- app.component.ts
import { Platform } from 'ionic-angular';
import { Logger } from 'ionic-logger';
import { FileSystemService } from './file-system.service'; // your own service or model that implements ionic-logger FileSystem interface
...
constructor(
private logger: Logger,
private platform: Platform
) {
this.platform.ready().then(() => {
...
this.logger.init(fileSystemService).then((status) => {
this.logger.debug('[Logger] init: ' + status);
})
}
}