Просмотр исходного кода

Disable debug messages by default and downgrade a few messages.

From now on, msg::debug will not display anything, unless this is a debug
build, or the LOL_DEBUG environment variable is set.
legacy
Sam Hocevar 7 лет назад
Родитель
Сommit
aca1660e1e
5 измененных файлов: 41 добавлений и 24 удалений
  1. +14
    -1
      src/base/log.cpp
  2. +6
    -6
      src/engine/ticker.cpp
  3. +10
    -6
      src/image/resource.cpp
  4. +8
    -8
      src/platform/android/androidapp.cpp
  5. +3
    -3
      src/platform/sdl/sdlinput.cpp

+ 14
- 1
src/base/log.cpp Просмотреть файл

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net>
// Copyright © 2010—2017 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
@@ -13,6 +13,7 @@
#include <lol/engine-internal.h>

#include <cstdio>
#include <cstdlib>

#if defined(_WIN32)
# define WIN32_LEAN_AND_MEAN
@@ -72,6 +73,18 @@ void msg::error(char const *fmt, ...)

void msg::helper(MessageType type, char const *fmt, va_list ap)
{
/* Unless this is a debug build, ignore debug messages unless
* the LOL_DEBUG environment variable is set. */
#if !defined LOL_BUILD_DEBUG
if (type == MessageType::Debug)
{
static char const *var = getenv("LOL_DEBUG");
static bool const disable_debug = !var || !var[0];
if (disable_debug)
return;
}
#endif

#if defined __ANDROID__
static int const prio[] =
{


+ 6
- 6
src/engine/ticker.cpp Просмотреть файл

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net>
// Copyright © 2010—2017 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
@@ -150,7 +150,7 @@ int Ticker::Unref(Entity *entity)
void TickerData::GameThreadMain()
{
#if LOL_BUILD_DEBUG
msg::info("ticker game thread initialised\n");
msg::debug("ticker game thread initialised\n");
#endif

for (;;)
@@ -167,7 +167,7 @@ void TickerData::GameThreadMain()
drawtick.push(0);

#if LOL_BUILD_DEBUG
msg::info("ticker game thread terminated\n");
msg::debug("ticker game thread terminated\n");
#endif
}
#endif /* LOL_FEATURE_THREADS */
@@ -176,7 +176,7 @@ void TickerData::GameThreadMain()
void TickerData::DrawThreadMain() /* unused */
{
#if LOL_BUILD_DEBUG
msg::info("ticker draw thread initialised\n");
msg::debug("ticker draw thread initialised\n");
#endif

for (;;)
@@ -191,7 +191,7 @@ void TickerData::DrawThreadMain() /* unused */
}

#if LOL_BUILD_DEBUG
msg::info("ticker draw thread terminated\n");
msg::debug("ticker draw thread terminated\n");
#endif
}
#endif /* LOL_FEATURE_THREADS */
@@ -255,7 +255,7 @@ void TickerData::GameThreadTick()
data->keepalive += data->deltatime;
if (data->keepalive > 10.f)
{
msg::info("ticker keepalive: tick!\n");
msg::debug("ticker keepalive: tick!\n");
data->keepalive = 0.f;
}
#endif


+ 10
- 6
src/image/resource.cpp Просмотреть файл

@@ -1,8 +1,8 @@
//
// Lol Engine
//
// Copyright © 2016—2017 Sam Hocevar <sam@hocevar.net>
// Copyright © 2016—2017 Benjamin “Touky” Huet <huet.benjamin@gmail.com>
// Copyright © 2010—2017 Sam Hocevar <sam@hocevar.net>
// Copyright © 2016—2017 Benjamin “Touky� Huet <huet.benjamin@gmail.com>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
@@ -88,13 +88,15 @@ ResourceCodecData* ResourceLoader::Load(char const *path)
auto data = codec->Load(path);
if (data != nullptr)
{
msg::info("image::Load: Codec %s succesfully loaded %s.\n", codec->GetName(), path);
msg::debug("image::load: codec %s succesfully loaded %s.\n",
codec->GetName(), path);
return data;
}
}

//Log error, because we shouldn't be here
msg::error("image::Load: Last codec %s, Error loading resource %s.\n", last_codec->GetName(), path);
msg::error("image::load: last codec %s, error loading resource %s.\n",
last_codec->GetName(), path);
return nullptr;
}

@@ -106,13 +108,15 @@ bool ResourceLoader::Save(char const *path, ResourceCodecData* data)
last_codec = codec;
if (codec->Save(path, data))
{
msg::info("image::Save: Codec %s succesfully saved %s.\n", codec->GetName(), path);
msg::info("image::save: codec %s succesfully saved %s.\n",
codec->GetName(), path);
return true;
}
}

//Log error, because we shouldn't be here
msg::error("image::Save: Last codec %s, Error saving resource %s.\n", last_codec->GetName(), path);
msg::error("image::save: last codec %s, error saving resource %s.\n",
last_codec->GetName(), path);
return false;
}



+ 8
- 8
src/platform/android/androidapp.cpp Просмотреть файл

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net>
// Copyright © 2010—2017 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
@@ -42,7 +42,7 @@ AAssetManager *g_assets;
extern "C" jint
JNI_OnLoad(JavaVM* vm, void* reserved)
{
msg::info("Java layer loading library, vm=0x%08lx", (long)(intptr_t)vm);
msg::debug("Java layer loading library, vm=0x%08lx", (long)(intptr_t)vm);
return JNI_VERSION_1_4;
}

@@ -152,7 +152,7 @@ int lol::AndroidAppData::CreateDisplay()
eglQuerySurface(m_display, m_surface, EGL_HEIGHT, &h);

/* Launch our renderer */
msg::info("Java layer initialising renderer (%dx%d)", w, h);
msg::debug("Java layer initialising renderer (%dx%d)", w, h);
Video::Setup(ivec2(w, h));

return 0;
@@ -267,8 +267,8 @@ AndroidAppData *g_data;

void android_main(android_app* native_app)
{
msg::info("Java layer calling android_main() for app 0x%08lx",
(long)native_app);
msg::debug("Java layer calling android_main() for app 0x%08lx",
(long)native_app);

/* Register native activity */
g_activity = native_app->activity;
@@ -278,7 +278,7 @@ void android_main(android_app* native_app)
jint res = g_activity->vm->GetEnv((void **)&jni_env, JNI_VERSION_1_2);
if (res < 0)
{
msg::info("JVM environment not found, trying to attach thread\n");
msg::debug("JVM environment not found, trying to attach thread\n");
res = g_activity->vm->AttachCurrentThread(&jni_env, nullptr);
}
if (res < 0)
@@ -329,7 +329,7 @@ void android_main(android_app* native_app)
source->process(native_app, source);
}

msg::info("Java layer running real main()\n");
msg::debug("Java layer running real main()\n");

/* Call the user's main() function. One of these will work. */
lol_android_main();
@@ -341,7 +341,7 @@ lol::AndroidApp::AndroidApp(char const *title, ivec2 res, float fps)
: m_data(g_data)
{
/* Launch our ticker */
msg::info("Java layer initialising ticker at %g fps", fps);
msg::debug("Java layer initialising ticker at %g fps", fps);
Ticker::Setup(fps);

m_data->m_wanted_resolution = res;


+ 3
- 3
src/platform/sdl/sdlinput.cpp Просмотреть файл

@@ -1,7 +1,7 @@
//
// Lol Engine
//
// Copyright © 2010—2016 Sam Hocevar <sam@hocevar.net>
// Copyright © 2010—2017 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
@@ -300,7 +300,7 @@ void SdlInputData::Tick(float seconds)
}
m_keyboard->SetKey(sc2, !m_keyboard->GetKey(sc2));
/* DEBUG STUFF
msg::info("Repeat: 0x%02x : %s/%s/%s/%i\n",
msg::debug("Repeat: 0x%02x : %s/%s/%s/%i\n",
(int)m_keyboard, ScanCodeToText(sc2).C(), ScanCodeToName(sc2).C(),
m_keyboard->GetKey(sc2) ? "up" : "down", event.key.repeat);
*/
@@ -317,7 +317,7 @@ void SdlInputData::Tick(float seconds)
m_keyboard->SetKey(sc, event.type == SDL_KEYDOWN);

/* DEBUG STUFF
msg::info("Repeat: 0x%02x : %s/%s/%s/%i\n",
msg::debug("Repeat: 0x%02x : %s/%s/%s/%i\n",
(int)m_keyboard, ScanCodeToText(sc).C(), ScanCodeToName(sc).C(),
event.type == SDL_KEYDOWN ? "up" : "down", event.key.repeat);
*/


Загрузка…
Отмена
Сохранить