diff --git a/inferno/src/inferno/application.cpp b/inferno/src/inferno/application.cpp index e41da50..286279f 100644 --- a/inferno/src/inferno/application.cpp +++ b/inferno/src/inferno/application.cpp @@ -122,7 +122,7 @@ namespace Inferno { // borderwidth // borderedge // bordercolor - // offse + // offset while (!m_window->shouldClose()) { @@ -172,7 +172,7 @@ namespace Inferno { // Suppress unused warning (void)e; - dbg(Log::Info) << "WindowCloseEvent triggered"; + info() << "WindowCloseEvent triggered"; m_window->setShouldClose(true); @@ -184,7 +184,7 @@ namespace Inferno { // Suppress unused warning (void)e; - dbgln(Log::Info, "WindowResizeEvent {}x{} triggered", e.getWidth(), e.getHeight()); + infoln("WindowResizeEvent {}x{} triggered", e.getWidth(), e.getHeight()); m_window->getContext()->setViewport(0, 0, e.getWidth(), e.getHeight()); @@ -196,7 +196,7 @@ namespace Inferno { // Suppress unused warning (void)e; - dbgln(Log::Info, "KeyPressEvent {} ({}) triggered", + infoln("KeyPressEvent {} ({}) triggered", Input::getKeyName(e.getKey()), e.getKey()); diff --git a/inferno/src/inferno/assert.h b/inferno/src/inferno/assert.h index d42e643..8bd2860 100644 --- a/inferno/src/inferno/assert.h +++ b/inferno/src/inferno/assert.h @@ -41,17 +41,17 @@ namespace Inferno { #ifdef NF_ENABLE_ASSERTS template - void __assertion_failed(const char* message, const char* file, unsigned line, const char* function, const P&... parameters) + void __assertion_failed(const char* message, const char* file, unsigned line, const char* function, P&&... parameters) { - dbg(Log::Danger, false) << "ASSERTION FAILED: " << message; + danger(false) << "ASSERTION FAILED: " << message; if (sizeof...(P) > 0) { - dbg(Log::Danger, false) << ": "; - dbgln(Log::Danger, false, parameters...); - dbg(Log::Danger, false); + danger(false) << ": "; + dbgln(Log::Danger, false, std::forward

(parameters)...); + danger(false); } - dbg(Log::Danger) << "\n\t" << file << ":" << line << ": " << function; + danger() << "\n\t" << file << ":" << line << ": " << function; raise(ABORT_SIGNAL); } diff --git a/inferno/src/inferno/io/input.cpp b/inferno/src/inferno/io/input.cpp index cc95dab..33e587b 100644 --- a/inferno/src/inferno/io/input.cpp +++ b/inferno/src/inferno/io/input.cpp @@ -20,7 +20,7 @@ namespace Inferno { m_xPosLast = Application::the().getWindow().getWidth() / 2.0f; m_yPosLast = Application::the().getWindow().getHeight() / 2.0f; - dbg(Log::Info) << "Input initialized"; + info() << "Input initialized"; } void Input::update() diff --git a/inferno/src/inferno/io/log.cpp b/inferno/src/inferno/io/log.cpp index c496d4c..999bcf0 100644 --- a/inferno/src/inferno/io/log.cpp +++ b/inferno/src/inferno/io/log.cpp @@ -252,66 +252,66 @@ namespace Inferno { return DebugLogStream(newline); } - DebugLogStream dbg(Log type) + DebugLogStream info() { - return DebugLogStream(type); + return DebugLogStream(Log::Info); } - DebugLogStream dbg(Log type, bool newline) + DebugLogStream warn() { - return DebugLogStream(type, newline); + return DebugLogStream(Log::Warn); } -// ----------------------------------------- - - void dbgln(Log type, bool newline) { - (void)type; - dbg(newline); + DebugLogStream danger() + { + return DebugLogStream(Log::Danger); } - void dbgln(const char* format) + DebugLogStream success() { - dbg() << format; + return DebugLogStream(Log::Success); } - void dbgln(Log type, const char* format) + DebugLogStream comment() { - dbg(type) << format; + return DebugLogStream(Log::Comment); } - void dbgln(Log type, bool newline, const char* format) + DebugLogStream info(bool newline) { - dbg(type, newline) << format; + return DebugLogStream(Log::Info, newline); } - void dbgln(std::string format) + DebugLogStream warn(bool newline) { - dbg() << format; + return DebugLogStream(Log::Warn, newline); } - void dbgln(Log type, std::string format) + DebugLogStream danger(bool newline) { - dbg(type) << format; + return DebugLogStream(Log::Danger, newline); } - void dbgln(Log type, bool newline, std::string format) + DebugLogStream success(bool newline) { - dbg(type, newline) << format; + return DebugLogStream(Log::Success, newline); } - void dbgln(std::string_view format) + DebugLogStream comment(bool newline) { - dbg() << format; + return DebugLogStream(Log::Comment, newline); } - void dbgln(Log type, std::string_view format) +// ----------------------------------------- + + void dbgln(Log type, bool newline) { - dbg(type) << format; + (void)type, DebugLogStream(newline); } - void dbgln(Log type, bool newline, std::string_view format) + void dbgln(Log type, bool newline, const char* format) { - dbg(type, newline) << format; + DebugLogStream(type, newline) << format; } // ----------------------------------------- diff --git a/inferno/src/inferno/io/log.h b/inferno/src/inferno/io/log.h index 4fe92e2..c663a1d 100644 --- a/inferno/src/inferno/io/log.h +++ b/inferno/src/inferno/io/log.h @@ -137,34 +137,67 @@ namespace Inferno { // ----------------------------------------- DebugLogStream dbg(); + DebugLogStream info(); + DebugLogStream warn(); + DebugLogStream danger(); + DebugLogStream success(); + DebugLogStream comment(); + DebugLogStream dbg(bool newline); - DebugLogStream dbg(Log type); - DebugLogStream dbg(Log type, bool newline); + DebugLogStream info(bool newline); + DebugLogStream warn(bool newline); + DebugLogStream danger(bool newline); + DebugLogStream success(bool newline); + DebugLogStream comment(bool newline); // ----------------------------------------- - void dbgln(Log type, bool newline); - void dbgln(const char* format); - void dbgln(Log type, const char* format); - void dbgln(Log type, bool newline, const char* format); - void dbgln(std::string format); - void dbgln(Log type, std::string format); - void dbgln(Log type, bool newline, std::string format); - void dbgln(std::string_view format); - void dbgln(Log type, std::string_view format); - void dbgln(Log type, bool newline, std::string_view format); + template void dbgln(const char* format, P&&... parameters) { return dbgln(Log::None, true, format, std::forward

(parameters)...); } + template void infoln(const char* format, P&&... parameters) { return dbgln(Log::Info, true, format, std::forward

(parameters)...); } + template void warnln(const char* format, P&&... parameters) { return dbgln(Log::Warn, true, format, std::forward

(parameters)...); } + template void dangerln(const char* format, P&&... parameters) { return dbgln(Log::Danger, true, format, std::forward

(parameters)...); } + template void successln(const char* format, P&&... parameters) { return dbgln(Log::Success, true, format, std::forward

(parameters)...); } + template void commentln(const char* format, P&&... parameters) { return dbgln(Log::Comment, true, format, std::forward

(parameters)...); } + + template void dbgln(const std::string& format, P&&... parameters) { return dbgln(Log::None, true, format.c_str(), std::forward

(parameters)...); } + template void infoln(const std::string& format, P&&... parameters) { return dbgln(Log::Info, true, format.c_str(), std::forward

(parameters)...); } + template void warnln(const std::string& format, P&&... parameters) { return dbgln(Log::Warn, true, format.c_str(), std::forward

(parameters)...); } + template void dangerln(const std::string& format, P&&... parameters) { return dbgln(Log::Danger, true, format.c_str(), std::forward

(parameters)...); } + template void successln(const std::string& format, P&&... parameters) { return dbgln(Log::Success, true, format.c_str(), std::forward

(parameters)...); } + template void commentln(const std::string& format, P&&... parameters) { return dbgln(Log::Comment, true, format.c_str(), std::forward

(parameters)...); } + + template void dbgln(const std::string_view& format, P&&... parameters) { return dbgln(Log::None, true, format.data(), std::forward

(parameters)...); } + template void infoln(const std::string_view& format, P&&... parameters) { return dbgln(Log::Info, true, format.data(), std::forward

(parameters)...); } + template void warnln(const std::string_view& format, P&&... parameters) { return dbgln(Log::Warn, true, format.data(), std::forward

(parameters)...); } + template void dangerln(const std::string_view& format, P&&... parameters) { return dbgln(Log::Danger, true, format.data(), std::forward

(parameters)...); } + template void successln(const std::string_view& format, P&&... parameters) { return dbgln(Log::Success, true, format.data(), std::forward

(parameters)...); } + template void commentln(const std::string_view& format, P&&... parameters) { return dbgln(Log::Comment, true, format.data(), std::forward

(parameters)...); } + + template void dbgln(bool newline, const char* format, P&&... parameters) { return dbgln(Log::None, newline, format, std::forward

(parameters)...); } + template void infoln(bool newline, const char* format, P&&... parameters) { return dbgln(Log::Info, newline, format, std::forward

(parameters)...); } + template void warnln(bool newline, const char* format, P&&... parameters) { return dbgln(Log::Warn, newline, format, std::forward

(parameters)...); } + template void dangerln(bool newline, const char* format, P&&... parameters) { return dbgln(Log::Danger, newline, format, std::forward

(parameters)...); } + template void successln(bool newline, const char* format, P&&... parameters) { return dbgln(Log::Success, newline, format, std::forward

(parameters)...); } + template void commentln(bool newline, const char* format, P&&... parameters) { return dbgln(Log::Comment, newline, format, std::forward

(parameters)...); } + + template void dbgln(bool newline, const std::string& format, P&&... parameters) { return dbgln(Log::None, newline, format.c_str(), std::forward

(parameters)...); } + template void infoln(bool newline, const std::string& format, P&&... parameters) { return dbgln(Log::Info, newline, format.c_str(), std::forward

(parameters)...); } + template void warnln(bool newline, const std::string& format, P&&... parameters) { return dbgln(Log::Warn, newline, format.c_str(), std::forward

(parameters)...); } + template void dangerln(bool newline, const std::string& format, P&&... parameters) { return dbgln(Log::Danger, newline, format.c_str(), std::forward

(parameters)...); } + template void successln(bool newline, const std::string& format, P&&... parameters) { return dbgln(Log::Success, newline, format.c_str(), std::forward

(parameters)...); } + template void commentln(bool newline, const std::string& format, P&&... parameters) { return dbgln(Log::Comment, newline, format.c_str(), std::forward

(parameters)...); } + + template void dbgln(bool newline, const std::string_view& format, P&&... parameters) { return dbgln(Log::None, newline, format.data(), std::forward

(parameters)...); } + template void infoln(bool newline, const std::string_view& format, P&&... parameters) { return dbgln(Log::Info, newline, format.data(), std::forward

(parameters)...); } + template void warnln(bool newline, const std::string_view& format, P&&... parameters) { return dbgln(Log::Warn, newline, format.data(), std::forward

(parameters)...); } + template void dangerln(bool newline, const std::string_view& format, P&&... parameters) { return dbgln(Log::Danger, newline, format.data(), std::forward

(parameters)...); } + template void successln(bool newline, const std::string_view& format, P&&... parameters) { return dbgln(Log::Success, newline, format.data(), std::forward

(parameters)...); } + template void commentln(bool newline, const std::string_view& format, P&&... parameters) { return dbgln(Log::Comment, newline, format.data(), std::forward

(parameters)...); } - template - void dbgln(const char* format, T value, P&&... parameters) - { - dbgln(Log::None, format, value, std::forward

(parameters)...); - } +// ----------------------------------------- - template - void dbgln(Log type, const char* format, T value, P&&... parameters) - { - dbgln(type, true, format, value, std::forward

(parameters)...); - } + void dbgln(Log type, bool newline); + void dbgln(Log type, bool newline, const char* format); // https://en.cppreference.com/w/cpp/language/parameter_pack#Example template @@ -176,7 +209,7 @@ namespace Inferno { while(format[i] != '\0') { if (format[i] == '{' && format[i + 1] == '}') { - dbg(type, false) << view.substr(0, i) << value; + DebugLogStream(type, false) << view.substr(0, i) << value; dbgln(type, newline, format + i + 2, parameters...); return; } @@ -185,42 +218,6 @@ namespace Inferno { } } - template - void dbgln(std::string format, T value, P&&... parameters) - { - dbgln(format.c_str(), value, std::forward

(parameters)...); - } - - template - void dbgln(Log type, std::string format, T value, P&&... parameters) - { - dbgln(type, format.c_str(), value, std::forward

(parameters)...); - } - - template - void dbgln(Log type, bool newline, std::string format, T value, P&&... parameters) - { - dbgln(type, newline, format.c_str(), value, std::forward

(parameters)...); - } - - template - void dbgln(std::string_view format, T value, P&&... parameters) - { - dbgln(format.data(), value, std::forward

(parameters)...); - } - - template - void dbgln(Log type, std::string_view format, T value, P&&... parameters) - { - dbgln(type, format.data(), value, std::forward

(parameters)...); - } - - template - void dbgln(Log type, bool newline, std::string_view format, T value, P&&... parameters) - { - dbgln(type, newline, format.data(), value, std::forward

(parameters)...); - } - // ----------------------------------------- StringLogStream str(std::string* fill); diff --git a/inferno/src/inferno/render/context.cpp b/inferno/src/inferno/render/context.cpp index 3008703..f3f3358 100644 --- a/inferno/src/inferno/render/context.cpp +++ b/inferno/src/inferno/render/context.cpp @@ -24,10 +24,10 @@ namespace Inferno { ASSERT(glad, "Failed to initialize glad!"); // Log OpenGL properties - dbg(Log::Comment) << "OpenGL Info:"; - dbg(Log::Comment) << " Vendor: " << glGetString(GL_VENDOR); - dbg(Log::Comment) << " Renderer: " << glGetString(GL_RENDERER); - dbg(Log::Comment) << " Version: " << glGetString(GL_VERSION); + comment() << "OpenGL Info:"; + comment() << " Vendor: " << glGetString(GL_VENDOR); + comment() << " Renderer: " << glGetString(GL_RENDERER); + comment() << " Version: " << glGetString(GL_VERSION); #ifdef NF_ENABLE_ASSERTS int versionMajor; diff --git a/inferno/src/inferno/render/font.cpp b/inferno/src/inferno/render/font.cpp index ad75b5d..a693c86 100644 --- a/inferno/src/inferno/render/font.cpp +++ b/inferno/src/inferno/render/font.cpp @@ -95,7 +95,7 @@ namespace Inferno { ASSERT(!s_instance, "FontManager already exists!"); s_instance = this; - dbg(Log::Info) << "FontManager initialized"; + info() << "FontManager initialized"; } void FontManager::destroy() diff --git a/inferno/src/inferno/render/renderer.cpp b/inferno/src/inferno/render/renderer.cpp index 19a1277..edabc17 100644 --- a/inferno/src/inferno/render/renderer.cpp +++ b/inferno/src/inferno/render/renderer.cpp @@ -174,7 +174,7 @@ namespace Inferno { m_vertexArray->setIndexBuffer(indexBuffer); delete[] indices; - dbg(Log::Info) << "Renderer2D initialized"; + info() << "Renderer2D initialized"; } void Renderer2D::destroy() @@ -331,7 +331,7 @@ namespace Inferno { m_vertexArray->setIndexBuffer(indexBuffer); delete[] indices; - dbg(Log::Info) << "RendererCharacter initialized"; + info() << "RendererCharacter initialized"; } void RendererCharacter::destroy() diff --git a/inferno/src/inferno/render/shader.cpp b/inferno/src/inferno/render/shader.cpp index 3dab6bb..5bab00c 100644 --- a/inferno/src/inferno/render/shader.cpp +++ b/inferno/src/inferno/render/shader.cpp @@ -181,7 +181,7 @@ namespace Inferno { ? glGetShaderInfoLog(check, maxLength, nullptr, &infoLog[0]) : glGetProgramInfoLog(check, maxLength, nullptr, &infoLog[0]); - dbg(Log::Warn) << "Shader " << infoLog.data(); + warn() << "Shader " << infoLog.data(); } ASSERT(success == GL_TRUE, "Shader program creation failed!"); @@ -198,7 +198,7 @@ namespace Inferno { ASSERT(!s_instance, "ShaderManager already exists!"); s_instance = this; - dbg(Log::Info) << "ShaderManager initialized"; + info() << "ShaderManager initialized"; } void ShaderManager::destroy() diff --git a/inferno/src/inferno/render/texture.cpp b/inferno/src/inferno/render/texture.cpp index 5c900cd..97ad200 100644 --- a/inferno/src/inferno/render/texture.cpp +++ b/inferno/src/inferno/render/texture.cpp @@ -108,7 +108,7 @@ namespace Inferno { ASSERT(!s_instance, "TextureManager already exists!"); s_instance = this; - dbg(Log::Info) << "TextureManager initialized"; + info() << "TextureManager initialized"; } void TextureManager::destroy() diff --git a/inferno/src/inferno/scene/scene.cpp b/inferno/src/inferno/scene/scene.cpp index 2e04060..942f427 100644 --- a/inferno/src/inferno/scene/scene.cpp +++ b/inferno/src/inferno/scene/scene.cpp @@ -67,7 +67,7 @@ namespace Inferno { quad3Transform.translate.x = 2.2f; addComponent(quad3, glm::vec4 { 1.0f, 1.0f, 1.0f, 1.0f }, m_texture2); - dbg(Log::Info) << "Scene initialized"; + info() << "Scene initialized"; } void Scene::update(float deltaTime) diff --git a/inferno/src/inferno/settings.cpp b/inferno/src/inferno/settings.cpp index 0f32d37..06909ad 100644 --- a/inferno/src/inferno/settings.cpp +++ b/inferno/src/inferno/settings.cpp @@ -13,7 +13,7 @@ namespace Inferno { { Settings::update(); - dbg(Log::Info) << "Settings initialized"; + info() << "Settings initialized"; } void Settings::update() @@ -29,7 +29,7 @@ namespace Inferno { m_properties.window.vsync = json["window"]["vsync"].get(); } catch (...) { - dbg(Log::Warn) << "Settings syntax error: using default values"; + warn() << "Settings syntax error: using default values"; } } @@ -54,7 +54,7 @@ namespace Inferno { json["window"]["vsync"] = m_properties.window.vsync; File::ioWrite(json, m_path); - dbg(Log::Info) << "Settings saved"; + info() << "Settings saved"; return true; } diff --git a/inferno/src/inferno/system/camerasystem.cpp b/inferno/src/inferno/system/camerasystem.cpp index 97ae826..4983870 100644 --- a/inferno/src/inferno/system/camerasystem.cpp +++ b/inferno/src/inferno/system/camerasystem.cpp @@ -17,7 +17,7 @@ namespace Inferno { ASSERT(!s_instance, "CameraSystem already exists!"); s_instance = this; - dbg(Log::Info) << "CameraSystem initialized"; + info() << "CameraSystem initialized"; } void CameraSystem::update() diff --git a/inferno/src/inferno/system/rendersystem.cpp b/inferno/src/inferno/system/rendersystem.cpp index 045856c..ca732e8 100644 --- a/inferno/src/inferno/system/rendersystem.cpp +++ b/inferno/src/inferno/system/rendersystem.cpp @@ -16,7 +16,7 @@ namespace Inferno { ASSERT(!s_instance, "RenderSystem already exists!"); s_instance = this; - dbg(Log::Info) << "RenderSystem initialized"; + info() << "RenderSystem initialized"; } void RenderSystem::render() diff --git a/inferno/src/inferno/system/scriptsystem.cpp b/inferno/src/inferno/system/scriptsystem.cpp index 4d550ac..9c46eca 100644 --- a/inferno/src/inferno/system/scriptsystem.cpp +++ b/inferno/src/inferno/system/scriptsystem.cpp @@ -19,7 +19,7 @@ namespace Inferno { ASSERT(!s_instance, "ScriptSystem already exists!"); s_instance = this; - dbg(Log::Info) << "ScriptSystem initialized"; + info() << "ScriptSystem initialized"; } void ScriptSystem::destroy() diff --git a/inferno/src/inferno/system/transformsystem.cpp b/inferno/src/inferno/system/transformsystem.cpp index 00f0da0..16797e0 100644 --- a/inferno/src/inferno/system/transformsystem.cpp +++ b/inferno/src/inferno/system/transformsystem.cpp @@ -14,7 +14,7 @@ namespace Inferno { ASSERT(!s_instance, "TransformSystem already exists!"); s_instance = this; - dbg(Log::Info) << "TransformSystem initialized"; + info() << "TransformSystem initialized"; } void TransformSystem::update()