Repo-Init
 
Loading...
Searching...
No Matches
spdlog::sinks::sentry_api_sink< Mutex > Class Template Reference

#include <Sentry.hpp>

Inheritance diagram for spdlog::sinks::sentry_api_sink< Mutex >:
Collaboration diagram for spdlog::sinks::sentry_api_sink< Mutex >:

Public Member Functions

 sentry_api_sink (const std::string &sentryAddress)
 
 ~sentry_api_sink ()
 

Protected Member Functions

void sink_it_ (const details::log_msg &msg) override
 
void flush_ () override
 

Private Attributes

bool _sentryAvailable {false}
 

Detailed Description

template<typename Mutex>
class spdlog::sinks::sentry_api_sink< Mutex >

A sink for sending log messages to a Sentry server.

This sink is used to send log messages to a Sentry server for error tracking and monitoring. It provides an interface for sending log messages and flushing the sink.

Template Parameters
MutexThe type of mutex to use for thread safety.

Definition at line 20 of file Sentry.hpp.

Constructor & Destructor Documentation

◆ sentry_api_sink()

template<typename Mutex >
spdlog::sinks::sentry_api_sink< Mutex >::sentry_api_sink ( const std::string & sentryAddress)
explicit

Constructs a Sentry API sink with the specified Sentry server address.

Parameters
sentryAddressThe address of the Sentry server.

Definition at line 119 of file Sentry.cpp.

120 {
121 if (sentryAddress.empty())
122 {
123 return;
124 }
125 _sentryAvailable = true;
126
127 // Set options
128 sentry_options_t *sentryOptions = sentry_options_new();
129 sentry_options_set_release(sentryOptions, PROJECT_FULL_REVISION);
130 sentry_options_set_dsn(sentryOptions, sentryAddress.c_str());
131
132 // Init
133 sentry_init(sentryOptions);
134
135 // Tags
136 sentry_set_tag("compiler.name", COMPILER_NAME);
137 sentry_set_tag("compiler.version", COMPILER_VERSION);
138 sentry_set_tag("build", BUILD_TYPE);
139
140 /* ################################################################################### */
141 /* ############################# MAKE MODIFICATIONS HERE ############################# */
142 /* ################################################################################### */
143
144 /* ################################################################################### */
145 /* ################################ END MODIFICATIONS ################################ */
146 /* ################################################################################### */
147
148 setVersionContext();
149 setHostContext();
150 setNetworkContext();
151 }

◆ ~sentry_api_sink()

template<typename Mutex >
spdlog::sinks::sentry_api_sink< Mutex >::~sentry_api_sink ( )

Destroys the Sentry API sink.

Definition at line 153 of file Sentry.cpp.

153{ sentry_close(); }

Member Function Documentation

◆ flush_()

template<typename Mutex >
void spdlog::sinks::sentry_api_sink< Mutex >::flush_ ( )
overrideprotected

Flushes the sink.

This function is called to flush any buffered log messages to the Sentry server.

Definition at line 186 of file Sentry.cpp.

187 {
188 // Sentry library handles all operations, so no need to flush
189 }

◆ sink_it_()

template<typename Mutex >
void spdlog::sinks::sentry_api_sink< Mutex >::sink_it_ ( const details::log_msg & msg)
overrideprotected

Sends the log message to the Sentry server.

This function is called for each log message that needs to be sent to the Sentry server.

Parameters
msgThe log message to be sent.

Definition at line 155 of file Sentry.cpp.

156 {
157 if (!_sentryAvailable)
158 {
159 return;
160 }
161 switch (msg.level)
162 {
163 case spdlog::level::warn:
164 sentry_capture_event(sentry_value_new_message_event(
165 SENTRY_LEVEL_WARNING, "main", std::string(msg.payload.data(), msg.payload.size()).c_str()));
166 break;
167 case spdlog::level::err:
168 sentry_capture_event(sentry_value_new_message_event(
169 SENTRY_LEVEL_ERROR, "main", std::string(msg.payload.data(), msg.payload.size()).c_str()));
170 break;
171 case spdlog::level::critical:
172 sentry_capture_event(sentry_value_new_message_event(
173 SENTRY_LEVEL_FATAL, "main", std::string(msg.payload.data(), msg.payload.size()).c_str()));
174 break;
175 case spdlog::level::trace:
176 case spdlog::level::debug:
177 case spdlog::level::info:
178 case spdlog::level::off:
179 // For lower levels, do nothing for now. But you can easily handle them here.
180 break;
181 default:
182 break;
183 }
184 }

Member Data Documentation

◆ _sentryAvailable

template<typename Mutex >
bool spdlog::sinks::sentry_api_sink< Mutex >::_sentryAvailable {false}
private

Flag indicating if the Sentry server is available.

Definition at line 52 of file Sentry.hpp.

52{false};

The documentation for this class was generated from the following files: