Adds engine configurable minimum logging level, closes #7
This commit is contained in:
@@ -8,6 +8,9 @@ rendering_engine = 0
|
|||||||
[overlay]
|
[overlay]
|
||||||
show_fps = true
|
show_fps = true
|
||||||
|
|
||||||
|
[logging]
|
||||||
|
minimum_level = 1
|
||||||
|
|
||||||
[font]
|
[font]
|
||||||
default_font_name = "Consolas-Regular"
|
default_font_name = "Consolas-Regular"
|
||||||
default_font_size = 12
|
default_font_size = 12
|
||||||
@@ -54,7 +54,7 @@ Engine::Engine(std::unique_ptr<Game> game,
|
|||||||
this->game = std::move(game);
|
this->game = std::move(game);
|
||||||
this->input_processor = std::move(input_processor);
|
this->input_processor = std::move(input_processor);
|
||||||
this->parse_config(ENGINE_CONFIG_FILE);
|
this->parse_config(ENGINE_CONFIG_FILE);
|
||||||
Logger::set_minimum_loglevel(LogLevel::DEBUG);
|
Logger::set_minimum_loglevel(this->config.minimum_loglevel);
|
||||||
this->setup_renderer(this->config.selected_renderer);
|
this->setup_renderer(this->config.selected_renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +75,8 @@ void Engine::parse_config(const std::string& config_file_path) {
|
|||||||
auto default_font_path = fmt::format("fonts/{}.ttf", table["font"]["default_font_name"].value_or(DEFAULT_FONT_NAME));
|
auto default_font_path = fmt::format("fonts/{}.ttf", table["font"]["default_font_name"].value_or(DEFAULT_FONT_NAME));
|
||||||
auto default_font_size = table["font"]["default_font_size"].value_or(DEFAULT_FONT_SIZE);
|
auto default_font_size = table["font"]["default_font_size"].value_or(DEFAULT_FONT_SIZE);
|
||||||
new_config.default_font = TextRenderDetails{default_font_path, default_font_size, COLOR_WHITE};
|
new_config.default_font = TextRenderDetails{default_font_path, default_font_size, COLOR_WHITE};
|
||||||
new_config.selected_renderer = static_cast<RendererTypes>(table["display"]["rendering_engine"].value_or(0));
|
new_config.selected_renderer = static_cast<RendererTypes>(table["display"]["rendering_engine"].value_or((int)RendererTypes::SDL_HARDWARE));
|
||||||
|
new_config.minimum_loglevel = static_cast<LogLevel>(table["logging"]["minimum_level"].value_or((int)LogLevel::DEBUG));
|
||||||
});
|
});
|
||||||
this->config = new_config;
|
this->config = new_config;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ struct EngineConfig {
|
|||||||
std::string window_title;
|
std::string window_title;
|
||||||
TextRenderDetails default_font;
|
TextRenderDetails default_font;
|
||||||
RendererTypes selected_renderer;
|
RendererTypes selected_renderer;
|
||||||
|
LogLevel minimum_loglevel;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Engine {
|
class Engine {
|
||||||
|
|||||||
Reference in New Issue
Block a user