Greenbone Vulnerability Management Libraries 22.32.0
gvm_sentry.c File Reference

Implementation of sentry methods. More...

#include "gvm_sentry.h"
#include <stdio.h>
Include dependency graph for gvm_sentry.c:

Go to the source code of this file.

Functions

int gvm_has_sentry_support ()
 Check for sentry support.
void gvm_sentry_init (const char *dsn, const char *release)
 Initialize Sentry.
void gvm_sentry_log (const char *message)
 Send a message to Sentry server if it was initialized.
void gvm_close_sentry (void)
 Shutdown Sentry if it was initialized.

Detailed Description

Implementation of sentry methods.

This file contains all methods needed for sentry. To enable sentry and log log in the sentry server, methods in this file are called.

Definition in file gvm_sentry.c.

Function Documentation

◆ gvm_close_sentry()

void gvm_close_sentry ( void )

Shutdown Sentry if it was initialized.

This function must be called before exiting to ensure that all message has been sent to Sentry.

The function does nothing if HAVE_SENTRY is not defined

Definition at line 122 of file gvm_sentry.c.

123{
124#ifdef HAVE_SENTRY
125 if (is_sentry_initialized ())
126 {
127 sentry_close ();
128 reset_init_sentry ();
129 }
130#endif /* HAVE_SENTRY */
131}

◆ gvm_has_sentry_support()

int gvm_has_sentry_support ( void )

Check for sentry support.

Returns
1 if gvm-libs has been built with sentry support, 0 otherwise.

Definition at line 26 of file gvm_sentry.c.

27{
28#ifdef HAVE_SENTRY
29 return 1;
30#endif /* HAVE_SENTRY */
31 return 0;
32}

◆ gvm_sentry_init()

void gvm_sentry_init ( const char * dsn,
const char * release )

Initialize Sentry.

The function does nothing if HAVE_SENTRY is not defined

Parameters
[in]dsnSentry DSN
[in]releaseModule release to be sent to Sentry.

Definition at line 74 of file gvm_sentry.c.

75{
76#ifdef HAVE_SENTRY
77 sentry_options_t *options = sentry_options_new ();
78 sentry_options_set_dsn (options, dsn);
79 sentry_options_set_release (options, release);
80 sentry_options_set_sample_rate (options, 1.0);
81 sentry_init (options);
82 set_init_sentry ();
83#else
84 (void) dsn;
85 (void) release;
86#endif /* HAVE_SENTRY */
87}

◆ gvm_sentry_log()

void gvm_sentry_log ( const char * message)

Send a message to Sentry server if it was initialized.

The function does nothing if HAVE_SENTRY is not defined

Parameters
[in]messageMessage to send

Definition at line 97 of file gvm_sentry.c.

98{
99#ifdef HAVE_SENTRY
100 if (is_sentry_initialized ())
101 {
102 sentry_capture_event (sentry_value_new_message_event (
103 /* level */ SENTRY_LEVEL_INFO,
104 /* logger */ "custom",
105 /* message */ message));
106 }
107#else
108 (void) message;
109#endif /* HAVE_SENTRY */
110}

Referenced by gvm_log_func().

Here is the caller graph for this function: