Commits

Kévin Delbrayelle committed d59d0e6

log debug macro

Comments (0)

Files changed (6)

game/inc/common/log.h

 #include "singleton.h"
 
 
-#define LOG     common::Log::instance()
+#if defined(DEBUG)
+#define LOG(format, ...) { common::Log::instance()->write(format, __VA_ARGS__); }
+#else
+#define LOG(format, ...)
+#endif // defined(DEBUG)
 
 
 namespace common {

game/src/game/state/state_factory.cpp

 {
     std::string str = std::string(name);
 
-    LOG->write("Registering state %s\n", name);
+    LOG("Registering state %s\n", name);
 
     return creators_.insert(creator_map_t::value_type(str, creator)).second;
 }

game/src/game/state/state_game.cpp

 
 void StateGame::enter()
 {
-    LOG->write("Entering state game\n");
+    LOG("Entering state game\n");
 
     color_ = 0.0;
 }

game/src/game/state/state_intro.cpp

 
 void StateIntro::enter()
 {
-    LOG->write("Entering state intro\n");
+    LOG("Entering state intro\n");
 
     color_ = 0.0;
 }

game/src/platform/application.cpp

 {
     finish();
     delete platform_;
-    LOG->write("Platform terminated\n");
+    LOG("Platform terminated\n");
 }
 
 
 void Application::run()
 {
     if (!init())
-        LOG->write("Application succesfully initialized\n");
+        LOG("Application succesfully initialized\n");
         //printf("Application succesfully initialized\n");
     else
     {
-        LOG->write("Failed to initialize Application\n");
+        LOG("Failed to initialize Application\n");
         //printf("Failed to initialize Application\n");
         return;
     }
         int mouse_y = mouse->get_y();
 
         if (mouse_x || mouse_y)
-            LOG->write("mouse: %3i %3i\n", mouse_x, mouse_y);
+            LOG("mouse: %3i %3i\n", mouse_x, mouse_y);
 
         int key = keyboard->get_pressed_key();
         if (key >= 0)
         {
             char key_symbol[32];
             keyboard->get_key_symbol(key, key_symbol);
-            LOG->write("Key pressed: %s\n", key_symbol);
+            LOG("Key pressed: %s\n", key_symbol);
         }
 
         if (keyboard->is_pressed(key_esc)) exit_requested_ = true;

game/src/platform/x11/display.cpp

     xrr_config_(::XRRGetScreenInfo(display_, root_window_))
 {
     if (!display_)
-        LOG->write("Failed to open X display\n");
+        LOG("Failed to open X display\n");
     else
         get_available_video_modes();
 }
     int rh = xrrs[original_mode].height;
 
     get_ratio(rw, rh);
-    LOG->write("Screen original resolution is %4i x %4i (%i/%i)\n",
+    LOG("Screen original resolution is %4i x %4i (%i/%i)\n",
         xrrs[original_mode].width, xrrs[original_mode].height, rw, rh);
 
     // Register selected video modes from slot 1 to max
 
     // Debug display of available resolutions
     for (int i = 0; i < num_video_modes_; i++) {
-        LOG->write("%2i: mode %2i: %4i x %4i @ %3i Hz\n", i,
+        LOG("%2i: mode %2i: %4i x %4i @ %3i Hz\n", i,
         video_modes_[i].index,
         video_modes_[i].width,
         video_modes_[i].height,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.