@edirect/logger
v10.0.0
Published
Logger Module
Downloads
433
Maintainers
Keywords
Readme
@edirect/logger
The EDirectInsure Logger module.
Installation
$ npm i --save @edirect/logger
Usage
Import and register LoggerModule on AppModule (app.module.ts):
imports: [
...
LoggerModule.register({
output: "output",
logs: {
errorFile: "error_file",
warningFile: "warning_file",
infoFile: "info_file",
},
name: 'subscription-service',
}),
...
]
OR
import { ConfigService } from '@edirect/config';
...
imports: [
...
LoggerModule.registerAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
output: configService.get(Variables.LOGS_OUTPUT),
logs: {
errorFile: configService.get(Variables.LOGS_ERROR_FILE),
warningFile: configService.get(Variables.LOGS_WARNING_FILE),
infoFile: configService.get(Variables.LOGS_INFO_FILE),
},
name: 'subscription-service',
}),
inject: [ConfigService],
}),
...
]
Inject the LoggerService where needed:
constructor(
private loggerService: LoggerService
) {}
Log using the exposed methods:
this.loggerService.log(message: string, payload?: string)
this.loggerService.info(message: string, payload?: string)
this.loggerService.warn(message: string, payload: string)
this.loggerService.error(message: string, trace: string)
this.loggerService.debug(message: string)
this.loggerService.verbose(message: string)