-
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
139 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#include <stdio.h> | ||
|
||
#include "sentry_logger.h" | ||
#include "sentry_options.h" | ||
|
||
#if defined(SENTRY_PLATFORM_ANDROID) | ||
|
||
# include <android/log.h> | ||
void | ||
sentry__logger_defaultlogger( | ||
sentry_level_t level, const char *message, va_list args) | ||
{ | ||
android_LogPriority priority = ANDROID_LOG_UNKNOWN; | ||
switch (level) { | ||
case SENTRY_LEVEL_DEBUG: | ||
priority = ANDROID_LOG_DEBUG; | ||
break; | ||
case SENTRY_LEVEL_INFO: | ||
priority = ANDROID_LOG_INFO; | ||
break; | ||
case SENTRY_LEVEL_WARNING: | ||
priority = ANDROID_LOG_WARN; | ||
break; | ||
case SENTRY_LEVEL_ERROR: | ||
priority = ANDROID_LOG_ERROR; | ||
break; | ||
case SENTRY_LEVEL_FATAL: | ||
priority = ANDROID_LOG_FATAL; | ||
break; | ||
default: | ||
break; | ||
} | ||
__android_log_vprint(priority, "sentry-native", message, args); | ||
} | ||
|
||
#else | ||
|
||
void | ||
sentry__logger_defaultlogger( | ||
sentry_level_t level, const char *message, va_list args) | ||
{ | ||
const char *prefix = "[sentry] "; | ||
const char *priority = sentry__logger_describe(level); | ||
|
||
char *format = sentry_malloc( | ||
strlen(prefix) + strlen(priority) + strlen(message) + 1); | ||
strcpy(format, prefix); | ||
strcat(format, priority); | ||
strcat(format, message); | ||
|
||
vfprintf(stderr, format, args); | ||
|
||
sentry_free(format); | ||
} | ||
|
||
#endif | ||
|
||
const char * | ||
sentry__logger_describe(sentry_level_t level) | ||
{ | ||
switch (level) { | ||
case SENTRY_LEVEL_DEBUG: | ||
return "DEBUG "; | ||
case SENTRY_LEVEL_INFO: | ||
return "INFO "; | ||
case SENTRY_LEVEL_WARNING: | ||
return "WARN "; | ||
case SENTRY_LEVEL_ERROR: | ||
return "ERROR "; | ||
case SENTRY_LEVEL_FATAL: | ||
return "FATAL "; | ||
default: | ||
return "UNKNOWN "; | ||
} | ||
} | ||
|
||
void | ||
sentry__logger_log(sentry_level_t level, const char *message, ...) | ||
{ | ||
const sentry_options_t *options = sentry_get_options(); | ||
if (options && options->logger && sentry_options_get_debug(options)) { | ||
|
||
va_list args; | ||
va_start(args, message); | ||
|
||
options->logger(level, message, args); | ||
|
||
va_end(args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "sentry.h" | ||
|
||
void sentry__logger_defaultlogger( | ||
sentry_level_t level, const char *message, va_list args); | ||
|
||
const char *sentry__logger_describe(sentry_level_t level); | ||
|
||
void sentry__logger_log(sentry_level_t level, const char *message, ...); | ||
|
||
#define SENTRY_TRACEF(message, ...) \ | ||
sentry__logger_log(SENTRY_LEVEL_DEBUG, message "\n", __VA_ARGS__) | ||
|
||
#define SENTRY_TRACE(message) \ | ||
sentry__logger_log(SENTRY_LEVEL_DEBUG, message "\n") | ||
|
||
#define SENTRY_DEBUGF(message, ...) \ | ||
sentry__logger_log(SENTRY_LEVEL_INFO, message "\n", __VA_ARGS__) | ||
|
||
#define SENTRY_DEBUG(message) \ | ||
sentry__logger_log(SENTRY_LEVEL_INFO, message "\n") | ||
|
||
#define SENTRY_WARNF(message, ...) \ | ||
sentry__logger_log(SENTRY_LEVEL_WARNING, message "\n", __VA_ARGS__) | ||
|
||
#define SENTRY_WARN(message) \ | ||
sentry__logger_log(SENTRY_LEVEL_WARNING, message "\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters