core/log: Rename LOG_* to CORE_* so that they don't get mixed up by Urho3D's LOG_* constants

This commit is contained in:
Perttu Ahola 2014-10-28 09:31:15 +02:00
parent 24636e9dd7
commit ee48a47094
13 changed files with 72 additions and 71 deletions

View File

@ -185,15 +185,15 @@ struct Module: public interface::Module, public main_context::Interface
int magic_level = event.magic_data.Find("Level")->second_.GetInt();
ss_ message = event.magic_data.Find("Message")->second_.
GetString().CString();
int core_level = LOG_ERROR;
int core_level = CORE_ERROR;
if(magic_level == magic::LOG_DEBUG)
core_level = LOG_DEBUG;
core_level = CORE_DEBUG;
else if(magic_level == magic::LOG_INFO)
core_level = LOG_VERBOSE;
core_level = CORE_VERBOSE;
else if(magic_level == magic::LOG_WARNING)
core_level = LOG_WARNING;
core_level = CORE_WARNING;
else if(magic_level == magic::LOG_ERROR)
core_level = LOG_ERROR;
core_level = CORE_ERROR;
log_(core_level, MODULE, "Urho3D %s", cs(message));
}

View File

@ -888,7 +888,7 @@ struct Module: public interface::Module, public voxelworld::Interface
container_coord16(chunk_p, m_section_size_chunks);
Section *section = get_section(section_p);
if(section == nullptr){
log_(disable_warnings ? LOG_DEBUG : LOG_WARNING,
log_(disable_warnings ? CORE_DEBUG : CORE_WARNING,
MODULE, "set_voxel() p=" PV3I_FORMAT ", v=%i: No section "
PV3I_FORMAT " for chunk " PV3I_FORMAT,
PV3I_PARAMS(p), v.data, PV3I_PARAMS(section_p),
@ -903,7 +903,7 @@ struct Module: public interface::Module, public voxelworld::Interface
ChunkBuffer &buf = section->get_buffer(chunk_p, m_server,
&m_total_buffers_loaded);
if(!buf.volume){
log_(disable_warnings ? LOG_DEBUG : LOG_WARNING,
log_(disable_warnings ? CORE_DEBUG : CORE_WARNING,
MODULE, "set_voxel() p=" PV3I_FORMAT ", v=%i: Couldn't get "
"buffer volume for chunk " PV3I_FORMAT " in section "
PV3I_FORMAT, PV3I_PARAMS(p), v.data, PV3I_PARAMS(chunk_p),
@ -1046,7 +1046,7 @@ struct Module: public interface::Module, public voxelworld::Interface
container_coord16(chunk_p, m_section_size_chunks);
Section *section = get_section(section_p);
if(section == nullptr){
log_(disable_warnings ? LOG_DEBUG : LOG_WARNING,
log_(disable_warnings ? CORE_DEBUG : CORE_WARNING,
MODULE, "get_voxel() p=" PV3I_FORMAT ": No section "
PV3I_FORMAT " for chunk " PV3I_FORMAT,
PV3I_PARAMS(p), PV3I_PARAMS(section_p),
@ -1061,7 +1061,7 @@ struct Module: public interface::Module, public voxelworld::Interface
ChunkBuffer &buf = section->get_buffer(chunk_p, m_server,
&m_total_buffers_loaded);
if(!buf.volume){
log_(disable_warnings ? LOG_DEBUG : LOG_WARNING,
log_(disable_warnings ? CORE_DEBUG : CORE_WARNING,
MODULE, "get_voxel() p=" PV3I_FORMAT ": Couldn't get "
"buffer volume for chunk " PV3I_FORMAT " in section "
PV3I_FORMAT, PV3I_PARAMS(p), PV3I_PARAMS(chunk_p),

View File

@ -401,7 +401,7 @@ struct CApp: public App, public magic::Application
m_thread_pool->run_post();
}
#ifdef DEBUG_LOG_TIMING
#ifdef DEBUG_CORE_TIMING
int64_t t1 = get_timeofday_us();
int interval = t1 - m_last_update_us;
if(interval > 30000)
@ -475,15 +475,15 @@ struct CApp: public App, public magic::Application
int magic_level = event_data["Level"].GetInt();
ss_ message = event_data["Message"].GetString().CString();
//log_v(MODULE, "on_logmessage(): %i, %s", magic_level, cs(message));
int c55_level = LOG_ERROR;
int c55_level = CORE_ERROR;
if(magic_level == magic::LOG_DEBUG)
c55_level = LOG_DEBUG;
c55_level = CORE_DEBUG;
else if(magic_level == magic::LOG_INFO)
c55_level = LOG_VERBOSE;
c55_level = CORE_VERBOSE;
else if(magic_level == magic::LOG_WARNING)
c55_level = LOG_WARNING;
c55_level = CORE_WARNING;
else if(magic_level == magic::LOG_ERROR)
c55_level = LOG_ERROR;
c55_level = CORE_ERROR;
log_(c55_level, MODULE, "Urho3D %s", cs(message));
}

View File

@ -44,7 +44,7 @@ void basic_init()
setlocale(LC_NUMERIC, "C");
log_init();
log_set_max_level(LOG_VERBOSE);
log_set_max_level(CORE_VERBOSE);
}
int main(int argc, char *argv[])

View File

@ -16,13 +16,13 @@
pthread_mutex_t log_mutex;
const int LOG_FATAL = 0;
const int LOG_ERROR = 1;
const int LOG_WARNING = 2;
const int LOG_INFO = 3;
const int LOG_VERBOSE = 4;
const int LOG_DEBUG = 5;
const int LOG_TRACE = 6;
const int CORE_FATAL = 0;
const int CORE_ERROR = 1;
const int CORE_WARNING = 2;
const int CORE_INFO = 3;
const int CORE_VERBOSE = 4;
const int CORE_DEBUG = 5;
const int CORE_TRACE = 6;
#ifdef _WIN32
static const bool use_colors = false;
@ -32,7 +32,7 @@ static const bool use_colors = true;
static std::atomic_bool line_begin(true);
static std::atomic_int current_level(0);
static std::atomic_int max_level(LOG_INFO);
static std::atomic_int max_level(CORE_INFO);
static FILE *file = NULL;
@ -102,19 +102,19 @@ static void print(int level, const char *sys, const char *fmt, va_list va_args)
{
if(use_colors && !file &&
(level != current_level || line_begin) && level <= max_level){
if(level == LOG_FATAL)
if(level == CORE_FATAL)
fprintf(stderr, "\033[0m\033[0;1;41m"); // reset, bright red bg
else if(level == LOG_ERROR)
else if(level == CORE_ERROR)
fprintf(stderr, "\033[0m\033[1;31m"); // bright red fg, black bg
else if(level == LOG_WARNING)
else if(level == CORE_WARNING)
fprintf(stderr, "\033[0m\033[1;33m"); // bright yellow fg, black bg
else if(level == LOG_INFO)
else if(level == CORE_INFO)
fprintf(stderr, "\033[0m"); // reset
else if(level == LOG_VERBOSE)
else if(level == CORE_VERBOSE)
fprintf(stderr, "\033[0m\033[0;36m"); // cyan fg, black bg
else if(level == LOG_DEBUG)
else if(level == CORE_DEBUG)
fprintf(stderr, "\033[0m\033[1;30m"); // bright black fg, black bg
else if(level == LOG_TRACE)
else if(level == CORE_TRACE)
fprintf(stderr, "\033[0m\033[0;35m"); //
else
fprintf(stderr, "\033[0m"); // reset

View File

@ -2,13 +2,14 @@
// Copyright 2014 Perttu Ahola <celeron55@gmail.com>
#pragma once
extern const int LOG_FATAL;
extern const int LOG_ERROR;
extern const int LOG_WARNING;
extern const int LOG_INFO;
extern const int LOG_VERBOSE;
extern const int LOG_DEBUG;
extern const int LOG_TRACE;
// The numeric values of these go from fatal=0 to trace=6 in ascending order.
extern const int CORE_FATAL;
extern const int CORE_ERROR;
extern const int CORE_WARNING;
extern const int CORE_INFO;
extern const int CORE_VERBOSE;
extern const int CORE_DEBUG;
extern const int CORE_TRACE;
void log_init();
@ -20,21 +21,21 @@ void log_close();
void log_nl();
void log_(int level, const char *sys, const char *fmt, ...)
__attribute__((format(printf, 3, 4)));
#define log_f(sys, fmt, ...) log_(LOG_FATAL, sys, fmt, ##__VA_ARGS__)
#define log_e(sys, fmt, ...) log_(LOG_ERROR, sys, fmt, ##__VA_ARGS__)
#define log_w(sys, fmt, ...) log_(LOG_WARNING, sys, fmt, ##__VA_ARGS__)
#define log_i(sys, fmt, ...) log_(LOG_INFO, sys, fmt, ##__VA_ARGS__)
#define log_v(sys, fmt, ...) log_(LOG_VERBOSE, sys, fmt, ##__VA_ARGS__)
#define log_d(sys, fmt, ...) log_(LOG_DEBUG, sys, fmt, ##__VA_ARGS__)
#define log_t(sys, fmt, ...) log_(LOG_TRACE, sys, fmt, ##__VA_ARGS__)
#define log_f(sys, fmt, ...) log_(CORE_FATAL, sys, fmt, ##__VA_ARGS__)
#define log_e(sys, fmt, ...) log_(CORE_ERROR, sys, fmt, ##__VA_ARGS__)
#define log_w(sys, fmt, ...) log_(CORE_WARNING, sys, fmt, ##__VA_ARGS__)
#define log_i(sys, fmt, ...) log_(CORE_INFO, sys, fmt, ##__VA_ARGS__)
#define log_v(sys, fmt, ...) log_(CORE_VERBOSE, sys, fmt, ##__VA_ARGS__)
#define log_d(sys, fmt, ...) log_(CORE_DEBUG, sys, fmt, ##__VA_ARGS__)
#define log_t(sys, fmt, ...) log_(CORE_TRACE, sys, fmt, ##__VA_ARGS__)
void log_no_nl(int level, const char *sys, const char *fmt, ...)
__attribute__((format(printf, 3, 4)));
#define log_nf(sys, fmt, ...) log_no_nl(LOG_FATAL, sys, fmt, ##__VA_ARGS__)
#define log_ne(sys, fmt, ...) log_no_nl(LOG_ERROR, sys, fmt, ##__VA_ARGS__)
#define log_nw(sys, fmt, ...) log_no_nl(LOG_WARNING, sys, fmt, ##__VA_ARGS__)
#define log_ni(sys, fmt, ...) log_no_nl(LOG_INFO, sys, fmt, ##__VA_ARGS__)
#define log_nv(sys, fmt, ...) log_no_nl(LOG_VERBOSE, sys, fmt, ##__VA_ARGS__)
#define log_nd(sys, fmt, ...) log_no_nl(LOG_DEBUG, sys, fmt, ##__VA_ARGS__)
#define log_nt(sys, fmt, ...) log_no_nl(LOG_TRACE, sys, fmt, ##__VA_ARGS__)
#define log_nf(sys, fmt, ...) log_no_nl(CORE_FATAL, sys, fmt, ##__VA_ARGS__)
#define log_ne(sys, fmt, ...) log_no_nl(CORE_ERROR, sys, fmt, ##__VA_ARGS__)
#define log_nw(sys, fmt, ...) log_no_nl(CORE_WARNING, sys, fmt, ##__VA_ARGS__)
#define log_ni(sys, fmt, ...) log_no_nl(CORE_INFO, sys, fmt, ##__VA_ARGS__)
#define log_nv(sys, fmt, ...) log_no_nl(CORE_VERBOSE, sys, fmt, ##__VA_ARGS__)
#define log_nd(sys, fmt, ...) log_no_nl(CORE_DEBUG, sys, fmt, ##__VA_ARGS__)
#define log_nt(sys, fmt, ...) log_no_nl(CORE_TRACE, sys, fmt, ##__VA_ARGS__)
// vim: set noet ts=4 sw=4:

View File

@ -203,7 +203,7 @@ struct CThreadPool: public ThreadPool
break;
}
}
#ifdef DEBUG_LOG_TIMING
#ifdef DEBUG_CORE_TIMING
int64_t t2 = get_timeofday_us();
log_v(MODULE, "output post(): %ius (%zu calls; queue size: %zu%s)",
(int)(t2 - t1), post_count, queue_size,

View File

@ -37,7 +37,7 @@ namespace interface
void on_event(magic::StringHash event_type, magic::VariantMap &event_data)
{
auto *evreg = interface::getGlobalEventRegistry();
if(log_get_max_level() >= LOG_DEBUG){
if(log_get_max_level() >= CORE_DEBUG){
log_d(MODULE, "MagicEventHandler::on_event(): %s (%zu)",
cs(evreg->name(m_buildat_event_type)), m_buildat_event_type);
}

View File

@ -116,7 +116,7 @@ void set_8bit_voxel_geometry(const luabind::object &node_o,
cg->SetCastShadows(true);
}
#ifdef DEBUG_LOG_TIMING
#ifdef DEBUG_CORE_TIMING
struct ScopeTimer {
const char *name;
uint64_t t0;
@ -290,7 +290,7 @@ struct SetPhysicsBoxesTask: public interface::thread_pool::Task
node->GetOrCreateComponent<RigidBody>(LOCAL);
break;
case 2:
#ifdef DEBUG_LOG_TIMING
#ifdef DEBUG_CORE_TIMING
log_v(MODULE, "num boxes: %zu", result_boxes.size());
#endif
// Times on Dell Precision M6800:

View File

@ -14,19 +14,19 @@ static int l_print_log(lua_State *L)
ss_ level = lua_tocppstring(L, 1);
const char *module_c = lua_tostring(L, 2);
const char *text_c = lua_tostring(L, 3);
int loglevel = LOG_INFO;
int loglevel = CORE_INFO;
if(level == "trace")
loglevel = LOG_TRACE;
loglevel = CORE_TRACE;
else if(level == "debug")
loglevel = LOG_DEBUG;
loglevel = CORE_DEBUG;
else if(level == "verbose")
loglevel = LOG_VERBOSE;
loglevel = CORE_VERBOSE;
else if(level == "info")
loglevel = LOG_INFO;
loglevel = CORE_INFO;
else if(level == "warning")
loglevel = LOG_WARNING;
loglevel = CORE_WARNING;
else if(level == "error")
loglevel = LOG_ERROR;
loglevel = CORE_ERROR;
log_(loglevel, module_c, "%s", text_c);
return 0;
}

View File

@ -57,7 +57,7 @@ void basic_init()
setlocale(LC_NUMERIC, "C");
log_init();
log_set_max_level(LOG_VERBOSE);
log_set_max_level(CORE_VERBOSE);
interface::debug::SigConfig debug_sig_config;
interface::debug::init_signal_handlers(debug_sig_config);

View File

@ -857,7 +857,7 @@ struct CState: public State, public interface::Server
// Do not use synchronous=true unless specifically needed in a special case.
void emit_event(Event event, bool synchronous)
{
if(log_get_max_level() >= LOG_TRACE){
if(log_get_max_level() >= CORE_TRACE){
auto *evreg = interface::getGlobalEventRegistry();
log_t("state", "emit_event(): %s (%zu)",
cs(evreg->name(event.type)), event.type);
@ -878,7 +878,7 @@ struct CState: public State, public interface::Server
log_t("state", "emit_event(): %zu: No subs", event.type);
return;
}
if(log_get_max_level() >= LOG_TRACE){
if(log_get_max_level() >= CORE_TRACE){
auto *evreg = interface::getGlobalEventRegistry();
log_t("state", "emit_event(): %s (%zu): Pushing to %zu modules",
cs(evreg->name(event.type)), event.type, sublist.size());

View File

@ -44,15 +44,15 @@ namespace urho3d_log_redirect
int magic_level = event.magic_data.Find("Level")->second_.GetInt();
ss_ message =
event.magic_data.Find("Message")->second_.GetString().CString();
int core_level = LOG_ERROR;
int core_level = CORE_ERROR;
if(magic_level == magic::LOG_DEBUG)
core_level = LOG_DEBUG;
core_level = CORE_DEBUG;
else if(magic_level == magic::LOG_INFO)
core_level = LOG_VERBOSE;
core_level = CORE_VERBOSE;
else if(magic_level == magic::LOG_WARNING)
core_level = LOG_WARNING;
core_level = CORE_WARNING;
else if(magic_level == magic::LOG_ERROR)
core_level = LOG_ERROR;
core_level = CORE_ERROR;
log_(core_level, MODULE, "Urho3D %s", cs(message));
}
};