Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Removed the 10-item limit per envelope for non-session data. Sessions are now limited to 100 per envelope, while other items (e.g., attachments) have no limit in amount. ([#1347](https://github.com/getsentry/sentry-native/pull/1347))
- Align the `breakpad` interface changes introduced with [#1083](https://github.com/getsentry/sentry-native/pull/1083) with the corresponding iOS build. ([#1465](https://github.com/getsentry/sentry-native/pull/1465))
- Add structured logs to debug output when `debug` option is set. ([#1466](https://github.com/getsentry/sentry-native/pull/1466))

## 0.12.2

Expand Down
5 changes: 5 additions & 0 deletions src/sentry_logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ void sentry__logger_disable(void);

#define SENTRY_ERROR(message) sentry__logger_log(SENTRY_LEVEL_ERROR, message)

#define SENTRY_FATALF(message, ...) \
sentry__logger_log(SENTRY_LEVEL_FATAL, message, __VA_ARGS__)

#define SENTRY_FATAL(message) sentry__logger_log(SENTRY_LEVEL_FATAL, message)

#endif
30 changes: 30 additions & 0 deletions src/sentry_logs.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,31 @@ construct_log(sentry_level_t level, const char *message, va_list args)
return log;
}

void
debug_print_log(sentry_level_t level, const char *log_body)
{
switch (level) {
case SENTRY_LEVEL_TRACE:
SENTRY_TRACEF("LOG: %s", log_body);
break;
case SENTRY_LEVEL_DEBUG:
SENTRY_DEBUGF("LOG: %s", log_body);
break;
case SENTRY_LEVEL_INFO:
SENTRY_INFOF("LOG: %s", log_body);
break;
case SENTRY_LEVEL_WARNING:
SENTRY_WARNF("LOG: %s", log_body);
break;
case SENTRY_LEVEL_ERROR:
SENTRY_ERRORF("LOG: %s", log_body);
break;
case SENTRY_LEVEL_FATAL:
SENTRY_FATALF("LOG: %s", log_body);
break;
}
}

log_return_value_t
sentry__logs_log(sentry_level_t level, const char *message, va_list args)
{
Expand All @@ -774,6 +799,11 @@ sentry__logs_log(sentry_level_t level, const char *message, va_list args)
discarded = true;
}
}
if (options->debug) {
debug_print_log(level,
sentry_value_as_string(
sentry_value_get_by_key(log, "body")));
}
}
if (discarded) {
return SENTRY_LOG_RETURN_DISCARD;
Expand Down
Loading