1.0.5 • Published 5 years ago
gamanza-rollbar-logger v1.0.5
Gamanza Rollbar Logger
This package is intended to use for sending errors and messages to rollbar account.
Table of contents
Technologies
- Npm - version 6.9.0
- Typescript - version 3.6.3
- Nestjs - version 6.9.0
- Rxjs -version 6.5.3
Usage
Install the package
$ npm i gamanza-rollbar-logger
Register the module in app.module
import { RollbarLoggerModule } from ‘gamanza-rollbar-logger’;
@Module({
imports: [
// …
RollbarLoggerModule.forRoot({
accessToken: ROLLBAR_TOKEN,
environment: ENVIRONMENT,
captureUncaught: true,
captureUnhandledRejections: true,
}),
],
})
export class AppModule {}
- accessToken - rollbar project token
- environment - a selected rollbar environment see
You can use the Rollbar Logger in services or controllers by using the @InjectRollbar
decorator in the constructor
import { RollbarLogger, InjectRollbar } from ‘gamanza-rollbar-logger’;
constructor(
@InjectRollbar() private readonly rollbarLogger: RollbarLogger,
) {}
To log errors in rollbar, use the .error()
method and pass the error
object or the error.message
property to the first parameter, and an error level to the second parameter. see
import { ErrorLevel } from ‘gamanza-rollbar-logger’;
//…
this.rollbarLogger.error(error.message, ErrorLevel.CRITICAL);
Status
Project is: finished
Contact
Author - Fabricio Vargas Email - fabricio.vargas@gamanza.com