ionic-logger
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Ionic Logger

NPM

Ionic 5 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 loggerLogger,
  private platformPlatform
) {
  this.platform.ready().then(() => {
 
    ...
 
    this.logger.init(fileSystemService).then((status) => {
      this.logger.debug('[Logger] init: ' + status);
    })
  }
}

Package Sidebar

Install

npm i ionic-logger

Weekly Downloads

5

Version

1.0.0

License

MIT

Unpacked Size

44.7 kB

Total Files

27

Last publish

Collaborators

  • antonio-spinelli