forked from getsentry/sentry-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.c
More file actions
55 lines (45 loc) · 1.86 KB
/
example.c
File metadata and controls
55 lines (45 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sentry.h"
#ifdef _WIN32
const char *handler_path = "bin/Release/crashpad_handler.exe";
#else
const char *handler_path = "bin/Release/crashpad_handler";
#endif
int main(void) {
sentry_options_t *options = sentry_options_new();
sentry_options_set_dsn(options, getenv("SENTRY_DSN"));
sentry_options_set_handler_path(options, handler_path);
sentry_options_set_environment(options, "Production");
sentry_options_set_release(options, "5fd7a6cd");
sentry_options_set_database_path(options, "sentrypad-db");
sentry_options_set_debug(options, 1);
sentry_options_add_attachment(options, "example", "../example.c");
sentry_init(options);
sentry_set_transaction("tran");
sentry_set_level(SENTRY_LEVEL_WARNING);
sentry_set_extra("extra stuff", "some value");
sentry_set_tag("expected-tag", "some value");
sentry_set_tag("not-expected-tag", "some value");
sentry_remove_tag("not-expected-tag");
sentry_set_fingerprint("foo", "bar", NULL);
sentry_breadcrumb_t default_crumb = {.message = "default level is info"};
sentry_add_breadcrumb(&default_crumb);
sentry_breadcrumb_t debug_crumb = {.message = "debug crumb",
.category = "example!",
.type = "http",
.level = SENTRY_LEVEL_DEBUG};
sentry_add_breadcrumb(&debug_crumb);
for (size_t i = 0; i < 101; i++) {
char buffer[4];
sprintf(buffer, "%zu", i);
sentry_breadcrumb_t crumb = {
.message = buffer,
.level = i % 2 == 0 ? SENTRY_LEVEL_ERROR : SENTRY_LEVEL_WARNING};
sentry_add_breadcrumb(&crumb);
}
sentry_user_t user = {.id = "some_id", .username = "some name"};
sentry_set_user(&user);
memset((char *)0x0, 1, 100);
}