24 if (sentryAddress.empty())
28 _sentryAvailable =
true;
31 sentry_options_t *sentryOptions = sentry_options_new();
32 sentry_options_set_release(sentryOptions, PROJECT_FULL_REVISION);
33 sentry_options_set_dsn(sentryOptions, sentryAddress.c_str());
36 sentry_init(sentryOptions);
39 sentry_set_tag(
"compiler.name", COMPILER_NAME);
40 sentry_set_tag(
"compiler.version", COMPILER_VERSION);
41 sentry_set_tag(
"build", BUILD_TYPE);
44 std::string versionBuffer;
45 const sentry_value_t versionContext = sentry_value_new_object();
46 versionBuffer =
"v" + std::string(PROJECT_FULL_REVISION);
47 sentry_value_set_by_key(versionContext, PROJECT_NAME, sentry_value_new_string(versionBuffer.c_str()));
48 versionBuffer = std::string(PROJECT_BUILD_DATE) +
" " + PROJECT_BUILD_TIME;
49 sentry_value_set_by_key(versionContext,
"Release Date", sentry_value_new_string(versionBuffer.c_str()));
58 sentry_set_context(
"Version", versionContext);
61 std::array<char, BUFSIZ> hostBuffer{};
62 gethostname(hostBuffer.data(), BUFSIZ);
63 const sentry_value_t hostContext = sentry_value_new_object();
64 sentry_value_set_by_key(hostContext,
"Hostname", sentry_value_new_string(hostBuffer.data()));
67 const std::string cpuInfoPath =
"/proc/cpuinfo";
71 sentry_value_set_by_key(hostContext,
"Thread count", sentry_value_new_string(word.c_str()));
73 sentry_value_set_by_key(hostContext,
"Core count", sentry_value_new_string(word.c_str()));
75 sentry_value_set_by_key(hostContext,
"Model", sentry_value_new_string(word.c_str()));
77 sentry_value_set_by_key(hostContext,
"Vendor ID", sentry_value_new_string(word.c_str()));
79 sentry_set_context(
"Host", hostContext);
82 const sentry_value_t networkContext = sentry_value_new_object();
84 if (ifaddrs *ifaddr =
nullptr; getifaddrs(&ifaddr) != -1)
87 for (ifaddrs *ifa = ifaddr; ifa !=
nullptr; ifa = ifa->ifa_next)
89 if (ifa->ifa_addr ==
nullptr)
94 switch (ifa->ifa_addr->sa_family)
97 if (((ifa->ifa_flags & IFF_PROMISC) != 0) || ((ifa->ifa_flags & IFF_UP) != 0))
99 std::array<char, INET_ADDRSTRLEN> host{};
100 inet_ntop(AF_INET, &(
reinterpret_cast<sockaddr_in *
>(ifa->ifa_addr))->sin_addr, host.data(),
102 sentry_value_set_by_key(networkContext, (std::string(ifa->ifa_name) +
".ipv4").c_str(),
103 sentry_value_new_string(host.data()));
107 if (((ifa->ifa_flags & IFF_PROMISC) != 0) || ((ifa->ifa_flags & IFF_UP) != 0))
109 std::array<char, INET6_ADDRSTRLEN> host{};
110 inet_ntop(AF_INET6, &(
reinterpret_cast<sockaddr_in6 *
>(ifa->ifa_addr))->sin6_addr, host.data(),
112 sentry_value_set_by_key(networkContext, (std::string(ifa->ifa_name) +
".ipv6").c_str(),
113 sentry_value_new_string(host.data()));
117 if (((ifa->ifa_flags & IFF_PROMISC) != 0) || ((ifa->ifa_flags & IFF_UP) != 0))
119 std::array<char, MAC_LEN> host{};
120 const auto *sock =
reinterpret_cast<sockaddr_ll *
>(ifa->ifa_addr);
121 if (snprintf(host.data(),
MAC_LEN,
"%02x:%02x:%02x:%02x:%02x:%02x", sock->sll_addr[0],
122 sock->sll_addr[1], sock->sll_addr[2], sock->sll_addr[3], sock->sll_addr[4],
123 sock->sll_addr[5]) > 0)
125 sentry_value_set_by_key(networkContext, (std::string(ifa->ifa_name) +
".mac").c_str(),
126 sentry_value_new_string(host.data()));
136 sentry_set_context(
"Network", networkContext);
143 if (!_sentryAvailable)
149 case spdlog::level::warn:
150 sentry_capture_event(sentry_value_new_message_event(
151 SENTRY_LEVEL_WARNING,
"main", std::string(msg.payload.data(), msg.payload.size()).c_str()));
153 case spdlog::level::err:
154 sentry_capture_event(sentry_value_new_message_event(
155 SENTRY_LEVEL_ERROR,
"main", std::string(msg.payload.data(), msg.payload.size()).c_str()));
157 case spdlog::level::critical:
158 sentry_capture_event(sentry_value_new_message_event(
159 SENTRY_LEVEL_FATAL,
"main", std::string(msg.payload.data(), msg.payload.size()).c_str()));
161 case spdlog::level::trace:
162 case spdlog::level::debug:
163 case spdlog::level::info:
164 case spdlog::level::off:
sentry_api_sink(const std::string &sentryAddress)
void sink_it_(const details::log_msg &msg) override