mirror of https://github.com/bjornbytes/lovr.git
Attempt to use macros for android logging;
Does this work? It seems like it should. If it doesn't, let's use functions consistently for logging on all platforms.
This commit is contained in:
parent
7ff12740b8
commit
0cf52a2ce8
|
@ -3,22 +3,17 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef __ANDROID__
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
void lovrLog(const char * restrict format, ...);
|
||||
void lovrLogv(const char * restrict format, va_list ap);
|
||||
void lovrWarn(const char * restrict format, ...);
|
||||
void lovrWarnv(const char * restrict format, va_list ap);
|
||||
|
||||
#include <android/log.h>
|
||||
#define lovrLog(...) __android_log_print(ANDROID_LOG_DEBUG, "LOVR", __VA_ARGS__)
|
||||
#define lovrLogv(...) __android_log_vprint(ANDROID_LOG_DEBUG, "LOVR", __VA_ARGS__)
|
||||
#define lovrWarn(...) __android_log_print(ANDROID_LOG_WARN, "LOVR", __VA_ARGS__)
|
||||
#define lovrWarnv(...) __android_log_vprint(ANDROID_LOG_WARN, "LOVR", __VA_ARGS__)
|
||||
#else
|
||||
|
||||
#include <stdio.h>
|
||||
#define lovrLog(...) printf(__VA_ARGS__)
|
||||
#define lovrLogv(...) vprintf(__VA_ARGS__)
|
||||
#define lovrWarn(...) fprintf(stderr, __VA_ARGS__)
|
||||
#define lovrWarnv(...) vfprintf(stderr, __VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
||||
void lovrSleep(double seconds);
|
||||
|
|
|
@ -1,30 +1 @@
|
|||
#include "platform.h"
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <android/log.h>
|
||||
|
||||
// Currently Android targets also include the linux.c platform.
|
||||
// These additional functions are here because stdout/stderr aren't wired up on Android:
|
||||
|
||||
|
||||
void lovrLogv(const char * restrict format, va_list ap) {
|
||||
__android_log_vprint(ANDROID_LOG_DEBUG, "LOVR", format, ap);
|
||||
}
|
||||
|
||||
void lovrLog(const char * restrict format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
lovrLogv(format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void lovrWarnv(const char * restrict format, va_list ap) {
|
||||
__android_log_vprint(ANDROID_LOG_WARN, "LOVR", format, ap);
|
||||
}
|
||||
|
||||
void lovrWarn(const char * restrict format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
lovrWarnv(format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue