diff options
author | ShadowNinja <shadowninja@minetest.net> | 2015-10-13 03:57:44 -0400 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2015-10-14 01:03:54 -0400 |
commit | 2139d7d45fb1a8ed250ad96c9975c581f02f72a9 (patch) | |
tree | 3e954063710add83723798937637db7c67a254eb /src/client | |
parent | e0b57c1140554fccbf3e57a036cc4100887ab8f1 (diff) | |
download | minetest-2139d7d45fb1a8ed250ad96c9975c581f02f72a9.tar.gz minetest-2139d7d45fb1a8ed250ad96c9975c581f02f72a9.tar.bz2 minetest-2139d7d45fb1a8ed250ad96c9975c581f02f72a9.zip |
Refactor logging
- Add warning log level
- Change debug_log_level setting to enumeration string
- Map Irrlicht log events to MT log events
- Encapsulate log_* functions and global variables into a class, Logger
- Unify dstream with standard logging mechanism
- Unify core.debug() with standard core.log() script API
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/clientlauncher.cpp | 26 | ||||
-rw-r--r-- | src/client/clientlauncher.h | 4 | ||||
-rw-r--r-- | src/client/inputhandler.h | 20 |
3 files changed, 17 insertions, 33 deletions
diff --git a/src/client/clientlauncher.cpp b/src/client/clientlauncher.cpp index 60eb21674..772bbaf23 100644 --- a/src/client/clientlauncher.cpp +++ b/src/client/clientlauncher.cpp @@ -89,7 +89,7 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args) if (list_video_modes) return print_video_modes(); - if (!init_engine(game_params.log_level)) { + if (!init_engine()) { errorstream << "Could not initialize game engine." << std::endl; return false; } @@ -321,10 +321,10 @@ void ClientLauncher::init_args(GameParams &game_params, const Settings &cmd_args || cmd_args.getFlag("random-input"); } -bool ClientLauncher::init_engine(int log_level) +bool ClientLauncher::init_engine() { receiver = new MyEventReceiver(); - create_engine_device(log_level); + create_engine_device(); return device != NULL; } @@ -455,7 +455,7 @@ bool ClientLauncher::launch_game(std::string &error_message, if (game_params.game_spec.isValid() && game_params.game_spec.id != worldspec.gameid) { - errorstream << "WARNING: Overriding gamespec from \"" + warningstream << "Overriding gamespec from \"" << worldspec.gameid << "\" to \"" << game_params.game_spec.id << "\"" << std::endl; gamespec = game_params.game_spec; @@ -500,20 +500,8 @@ void ClientLauncher::main_menu(MainMenuData *menudata) smgr->clear(); /* leave scene manager in a clean state */ } -bool ClientLauncher::create_engine_device(int log_level) +bool ClientLauncher::create_engine_device() { - static const irr::ELOG_LEVEL irr_log_level[5] = { - ELL_NONE, - ELL_ERROR, - ELL_WARNING, - ELL_INFORMATION, -#if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8) - ELL_INFORMATION -#else - ELL_DEBUG -#endif - }; - // Resolution selection bool fullscreen = g_settings->getBool("fullscreen"); u16 screenW = g_settings->getU16("screenW"); @@ -561,10 +549,6 @@ bool ClientLauncher::create_engine_device(int log_level) device = createDeviceEx(params); if (device) { - // Map our log level to irrlicht engine one. - ILogger* irr_logger = device->getLogger(); - irr_logger->setLogLevel(irr_log_level[log_level]); - porting::initIrrlicht(device); } diff --git a/src/client/clientlauncher.h b/src/client/clientlauncher.h index 49ceefc52..b10bbebc9 100644 --- a/src/client/clientlauncher.h +++ b/src/client/clientlauncher.h @@ -90,13 +90,13 @@ public: protected: void init_args(GameParams &game_params, const Settings &cmd_args); - bool init_engine(int log_level); + bool init_engine(); bool launch_game(std::string &error_message, bool reconnect_requested, GameParams &game_params, const Settings &cmd_args); void main_menu(MainMenuData *menudata); - bool create_engine_device(int log_level); + bool create_engine_device(); void speed_tests(); bool print_video_modes(); diff --git a/src/client/inputhandler.h b/src/client/inputhandler.h index a894e35aa..69e4b25fa 100644 --- a/src/client/inputhandler.h +++ b/src/client/inputhandler.h @@ -17,8 +17,8 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef __INPUT_HANDLER_H__ -#define __INPUT_HANDLER_H__ +#ifndef INPUT_HANDLER_H +#define INPUT_HANDLER_H #include "irrlichttypes_extrabloated.h" @@ -86,16 +86,16 @@ public: } } } else if (event.EventType == irr::EET_LOG_TEXT_EVENT) { - static const enum LogMessageLevel irr_loglev_conv[] = { - LMT_VERBOSE, // ELL_DEBUG - LMT_INFO, // ELL_INFORMATION - LMT_ACTION, // ELL_WARNING - LMT_ERROR, // ELL_ERROR - LMT_ERROR, // ELL_NONE + static const LogLevel irr_loglev_conv[] = { + LL_VERBOSE, // ELL_DEBUG + LL_INFO, // ELL_INFORMATION + LL_WARNING, // ELL_WARNING + LL_ERROR, // ELL_ERROR + LL_NONE, // ELL_NONE }; assert(event.LogEvent.Level < ARRLEN(irr_loglev_conv)); - log_printline(irr_loglev_conv[event.LogEvent.Level], - std::string("Irrlicht: ") + (const char *)event.LogEvent.Text); + g_logger.log(irr_loglev_conv[event.LogEvent.Level], + std::string("Irrlicht: ") + (const char*) event.LogEvent.Text); return true; } /* always return false in order to continue processing events */ |