Pass log levels from emugl layer

This commit is contained in:
Simon Fels 2017-01-26 09:21:53 +01:00
commit 1b1b2c35a1
9 changed files with 54 additions and 25 deletions

View file

@ -23,7 +23,6 @@
#include "OpenGLESDispatch/GLESv2Dispatch.h"
#include "emugl/common/crash_reporter.h"
#include "emugl/common/logging.h"
#include <string.h>
@ -50,7 +49,7 @@ std::vector<GLLibrary> default_gl_libraries(bool no_glesv1) {
};
}
bool initialize(const std::vector<GLLibrary> &libs, emugl_logger_struct log_funcs, emugl_crash_func_t crash_func) {
bool initialize(const std::vector<GLLibrary> &libs, emugl_logger_struct log_funcs, logger_t crash_func) {
set_emugl_crash_reporter(crash_func);
set_emugl_logger(log_funcs.coarse);
set_emugl_cxt_logger(log_funcs.fine);

View file

@ -21,12 +21,11 @@
#include <boost/filesystem/path.hpp>
typedef void (*emugl_logger_func_t)(const char* fmt, ...);
typedef void (*emugl_crash_func_t)(const char* format, ...);
#include "emugl/common/logging.h"
typedef struct {
emugl_logger_func_t coarse;
emugl_logger_func_t fine;
logger_t coarse;
logger_t fine;
} emugl_logger_struct;
namespace anbox {
@ -40,7 +39,7 @@ struct GLLibrary {
std::vector<GLLibrary> default_gl_libraries(bool no_glesv1 = false);
bool initialize(const std::vector<GLLibrary> &libs, emugl_logger_struct log_funcs, emugl_crash_func_t crash_func);
bool initialize(const std::vector<GLLibrary> &libs, emugl_logger_struct log_funcs, logger_t crash_func);
} // namespace emugl
} // namespace graphics
} // namespace anbox

View file

@ -29,7 +29,9 @@
#include <stdexcept>
namespace {
void logger_write(const char *format, ...) {
void logger_write(const emugl::LogLevel &level, const char *format, ...) {
(void)level;
char message[2048];
va_list args;
@ -37,7 +39,25 @@ void logger_write(const char *format, ...) {
vsnprintf(message, sizeof(message) - 1, format, args);
va_end(args);
DEBUG("%s", message);
switch (level) {
case emugl::LogLevel::WARNING:
WARNING("%s", message);
break;
case emugl::LogLevel::ERROR:
ERROR("%s", message);
break;
case emugl::LogLevel::FATAL:
FATAL("%s", message);
break;
case emugl::LogLevel::DEBUG:
DEBUG("%s", message);
break;
case emugl::LogLevel::TRACE:
TRACE("%s", message);
break;
default:
break;
}
}
}