Git Product home page Git Product logo

Comments (6)

ntegral avatar ntegral commented on July 30, 2024 3

import { Injectable } from '@nestjs/common';
import { InjectSentry, SentryService } from '@ntegral/nestjs-sentry';

@Injectable()
export class AppService {
public constructor(@InjectSentry() private readonly client: SentryService) {
client.instance().captureMessage(message, Sentry.Severity.Log);
client.instance().captureException(exception);
... and more
}
}

from nestjs-sentry.

ntegral avatar ntegral commented on July 30, 2024 2

@MatthewHerbst - To enable logging across the entire app you can do the following:

async function bootstrap() {
const app = await NestFactory.create(AppModule, {
logger: SentryService.SentryServiceInstance(),
});
or // app.useLogger(app.get(SentryService)); // either or will turn on logging at the application level.
await app.listen(3000);
}
bootstrap();

Note: this package extends NestJS logging. Please see the NestJS documentation of application logging for details. Thanks.

https://docs.nestjs.com/techniques/logger

from nestjs-sentry.

meirka avatar meirka commented on July 30, 2024 1

Sorry, I know you said without interceptors, but so far I figured: you need to add interceptor in order for Sentry to receive any exceptions raised from any end-point. Example:

    imports: [
        SentryModule.forRoot({
            dsn: 'dsn_here',
            debug: true,
            environment: 'production',
            release: null, // must create a release in sentry.io dashboard
            logLevel: LogLevel.Debug, //based on sentry.io loglevel //
            tracesSampleRate: 1.0,
            close: {
                enabled: true,
                timeout: 1000
            },
        }),
        ConfigModule.forRoot(),
        HttpModule,
    ],
    controllers: [AppController],
    providers: [
        AppService,
        {
            provide: APP_INTERCEPTOR,
            useValue: new SentryInterceptor()
        }
    ]

What I can't figure out so far, is: how to get console.log('example') to be sent to Sentry.

from nestjs-sentry.

MatthewHerbst avatar MatthewHerbst commented on July 30, 2024

@meirka did you figure this out?

@ntegral the goal here is to enable Sentry across the entire app without having to inject it into every injectable.

from nestjs-sentry.

meirka avatar meirka commented on July 30, 2024

Hey @MatthewHerbst
No, I haven't figured out how to automagically get console.log(..) to be sent to Sentry.

from nestjs-sentry.

meirka avatar meirka commented on July 30, 2024

@ntegral thank you!

from nestjs-sentry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.