Pass log levels from emugl layer
This commit is contained in:
parent
ddc022466e
commit
1b1b2c35a1
9 changed files with 54 additions and 25 deletions
|
|
@ -823,12 +823,7 @@ int ApiGen::genDecoderImpl(const std::string &filename)
|
|||
fprintf(fp, "typedef unsigned int tsize_t; // Target \"size_t\", which is 32-bit for now. It may or may not be the same as host's size_t when emugen is compiled.\n\n");
|
||||
|
||||
// helper macros
|
||||
fprintf(fp,
|
||||
"#ifdef OPENGL_DEBUG_PRINTOUT\n"
|
||||
"# define DEBUG(...) do { if (emugl_cxt_logger) { emugl_cxt_logger(__VA_ARGS__); } } while(0)\n"
|
||||
"#else\n"
|
||||
"# define DEBUG(...) ((void)0)\n"
|
||||
"#endif\n\n");
|
||||
fprintf(fp, "# define DEBUG(...) do { if (emugl_cxt_logger) { emugl_cxt_logger(LogLevel::TRACE, __VA_ARGS__); } } while(0)\n\n");
|
||||
|
||||
fprintf(fp,
|
||||
"#ifdef CHECK_GLERROR\n"
|
||||
|
|
@ -913,7 +908,7 @@ int ApiGen::genDecoderImpl(const std::string &filename)
|
|||
}
|
||||
} else if (pass == PASS_DebugPrint) {
|
||||
fprintf(fp,
|
||||
"\t\t\tDEBUG(\"%s(%%p): %s(%s)\\n\", stream",
|
||||
"\t\t\tDEBUG(\"%s(%%p): %s(%s)\", stream",
|
||||
m_basename.c_str(),
|
||||
e->name().c_str(),
|
||||
printString.c_str());
|
||||
|
|
|
|||
|
|
@ -98,6 +98,6 @@ void ChecksumCalculatorThreadInfo::validOrDie(void* buf,
|
|||
// We should actually call crashhandler_die(message), but I don't think we
|
||||
// can link to that library from here
|
||||
if (!validate(buf, bufLen, checksum, checksumLen)) {
|
||||
emugl_crash_reporter(message);
|
||||
emugl_crash_reporter(emugl::LogLevel::FATAL, message);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@
|
|||
|
||||
#include <cstdlib>
|
||||
|
||||
void default_crash_reporter(const char* format, ...) {
|
||||
void default_crash_reporter(const emugl::LogLevel &level, const char* format, ...) {
|
||||
abort();
|
||||
}
|
||||
|
||||
crash_reporter_t emugl_crash_reporter = default_crash_reporter;
|
||||
logger_t emugl_crash_reporter = default_crash_reporter;
|
||||
|
||||
void set_emugl_crash_reporter(crash_reporter_t crash_reporter) {
|
||||
void set_emugl_crash_reporter(logger_t crash_reporter) {
|
||||
if (crash_reporter) {
|
||||
emugl_crash_reporter = crash_reporter;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
typedef void (*crash_reporter_t)(const char* format, ...);
|
||||
#include "emugl/common/logging.h"
|
||||
|
||||
extern crash_reporter_t emugl_crash_reporter;
|
||||
void set_emugl_crash_reporter(crash_reporter_t crash_reporter);
|
||||
extern logger_t emugl_crash_reporter;
|
||||
void set_emugl_crash_reporter(logger_t crash_reporter);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#include "emugl/common/logging.h"
|
||||
|
||||
void default_logger(const char* fmt, ...) { }
|
||||
void default_logger(const emugl::LogLevel &level, const char* fmt, ...) { }
|
||||
|
||||
logger_t emugl_logger = default_logger;
|
||||
logger_t emugl_cxt_logger = default_logger;
|
||||
|
|
|
|||
|
|
@ -14,10 +14,24 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef EMUGL_COMMON_LOGGING_H_
|
||||
#define EMUGL_COMMON_LOGGING_H_
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wredundant-decls"
|
||||
|
||||
typedef void (*logger_t)(const char* fmt, ...);
|
||||
namespace emugl {
|
||||
enum class LogLevel {
|
||||
TRACE,
|
||||
DEBUG,
|
||||
INFO,
|
||||
WARNING,
|
||||
ERROR,
|
||||
FATAL,
|
||||
};
|
||||
} // namespace emugl
|
||||
|
||||
typedef void (*logger_t)(const emugl::LogLevel &level, const char* fmt, ...);
|
||||
extern logger_t emugl_logger;
|
||||
extern logger_t emugl_cxt_logger;
|
||||
void set_emugl_logger(logger_t f);
|
||||
|
|
@ -40,3 +54,5 @@ void set_emugl_cxt_logger(logger_t f);
|
|||
#endif
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue