Print info logs to stdout
All server logs were printed to stdout, while all client logs were printed to stderr. Instead, use stderr for warnings and errors, stdout for the others: - stdout: verbose, debug, info - stderr: warn, error
This commit is contained in:
parent
bb56472d4e
commit
4a25f3e53b
2 changed files with 24 additions and 2 deletions
|
@ -125,8 +125,30 @@ sc_av_log_callback(void *avcl, int level, const char *fmt, va_list vl) {
|
||||||
free(local_fmt);
|
free(local_fmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *const sc_sdl_log_priority_names[SDL_NUM_LOG_PRIORITIES] = {
|
||||||
|
[SDL_LOG_PRIORITY_VERBOSE] = "VERBOSE",
|
||||||
|
[SDL_LOG_PRIORITY_DEBUG] = "DEBUG",
|
||||||
|
[SDL_LOG_PRIORITY_INFO] = "INFO",
|
||||||
|
[SDL_LOG_PRIORITY_WARN] = "WARN",
|
||||||
|
[SDL_LOG_PRIORITY_ERROR] = "ERROR",
|
||||||
|
[SDL_LOG_PRIORITY_CRITICAL] = "CRITICAL",
|
||||||
|
};
|
||||||
|
|
||||||
|
static void SDLCALL
|
||||||
|
sc_sdl_log_print(void *userdata, int category, SDL_LogPriority priority,
|
||||||
|
const char *message) {
|
||||||
|
(void) userdata;
|
||||||
|
(void) category;
|
||||||
|
|
||||||
|
FILE *out = priority < SDL_LOG_PRIORITY_WARN ? stdout : stderr;
|
||||||
|
assert(priority < SDL_NUM_LOG_PRIORITIES);
|
||||||
|
const char *prio_name = sc_sdl_log_priority_names[priority];
|
||||||
|
fprintf(out, "%s: %s\n", prio_name, message);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sc_log_configure() {
|
sc_log_configure() {
|
||||||
|
SDL_LogSetOutputFunction(sc_sdl_log_print, NULL);
|
||||||
// Redirect FFmpeg logs to SDL logs
|
// Redirect FFmpeg logs to SDL logs
|
||||||
av_log_set_callback(sc_av_log_callback);
|
av_log_set_callback(sc_av_log_callback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ public final class Ln {
|
||||||
public static void w(String message, Throwable throwable) {
|
public static void w(String message, Throwable throwable) {
|
||||||
if (isEnabled(Level.WARN)) {
|
if (isEnabled(Level.WARN)) {
|
||||||
Log.w(TAG, message, throwable);
|
Log.w(TAG, message, throwable);
|
||||||
System.out.print(PREFIX + "WARN: " + message + '\n');
|
System.err.print(PREFIX + "WARN: " + message + '\n');
|
||||||
if (throwable != null) {
|
if (throwable != null) {
|
||||||
throwable.printStackTrace();
|
throwable.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ public final class Ln {
|
||||||
public static void e(String message, Throwable throwable) {
|
public static void e(String message, Throwable throwable) {
|
||||||
if (isEnabled(Level.ERROR)) {
|
if (isEnabled(Level.ERROR)) {
|
||||||
Log.e(TAG, message, throwable);
|
Log.e(TAG, message, throwable);
|
||||||
System.out.print(PREFIX + "ERROR: " + message + "\n");
|
System.err.print(PREFIX + "ERROR: " + message + "\n");
|
||||||
if (throwable != null) {
|
if (throwable != null) {
|
||||||
throwable.printStackTrace();
|
throwable.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue