Skip to content

Commit

Permalink
fix(logging): don't unconditionally log to console (#4136)
Browse files Browse the repository at this point in the history
  • Loading branch information
armcknight authored Jul 10, 2024
1 parent 152437a commit e773cad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 3 additions & 4 deletions Sources/Sentry/SentryAsyncSafeLog.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ writeToLog(const char *const str)
pos += bytesWritten;
}
}
write(STDOUT_FILENO, str, strlen(str));

#if SENTRY_ASYNC_SAFE_LOG_ALSO_WRITE_TO_CONSOLE
// if we're debugging, also write the log statements to the console; we only check once for
Expand Down Expand Up @@ -150,10 +149,10 @@ sentry_asyncLogSetFileName(const char *filename, bool overwrite)
}

void
sentry_asyncLogC(const char *const level, const char *const file, const int line,
const char *const function, const char *const fmt, ...)
sentry_asyncLogC(
const char *const level, const char *const file, const int line, const char *const fmt, ...)
{
writeFmtToLog("%s: %s (%u): %s: ", level, lastPathEntry(file), line, function);
writeFmtToLog("%s: %s (%u): ", level, lastPathEntry(file), line);
va_list args;
va_start(args, fmt);
writeFmtArgsToLog(fmt, args);
Expand Down
5 changes: 2 additions & 3 deletions Sources/Sentry/SentryAsyncSafeLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ extern "C" {

static char g_logFilename[1024];

void sentry_asyncLogC(
const char *level, const char *file, int line, const char *function, const char *fmt, ...);
void sentry_asyncLogC(const char *level, const char *file, int line, const char *fmt, ...);

#define i_SENTRY_ASYNC_SAFE_LOG sentry_asyncLogC

Expand All @@ -62,7 +61,7 @@ void sentry_asyncLogC(
#define SENTRY_ASYNC_SAFE_LOG_LEVEL SENTRY_ASYNC_SAFE_LOG_LEVEL_ERROR

#define a_SENTRY_ASYNC_SAFE_LOG(LEVEL, FMT, ...) \
i_SENTRY_ASYNC_SAFE_LOG(LEVEL, __FILE__, __LINE__, __PRETTY_FUNCTION__, FMT, ##__VA_ARGS__)
i_SENTRY_ASYNC_SAFE_LOG(LEVEL, __FILE__, __LINE__, FMT, ##__VA_ARGS__)

// ============================================================================
#pragma mark - API -
Expand Down

0 comments on commit e773cad

Please sign in to comment.