Skip to content

Commit

Permalink
Change the fatal method in Logger
Browse files Browse the repository at this point in the history
  • Loading branch information
oechsler committed Jan 6, 2021
1 parent 0b54d63 commit eb60747
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/System/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void Application::onWindowClose(WindowCloseEvent *const event)
Application::Application(ContainerBuilder *containerBuilder)
: containerBuilder(containerBuilder), running(true), onWindowCloseHandle(0)
{
logger.logInformation("Welcome to the Bare rendering framework");
logger.logInformation("Bare is warming up");

// Register default dependency injection modules
containerBuilder->registerType<Dispatch>().as<IDispatch>().singleInstance();
Expand Down Expand Up @@ -55,6 +55,8 @@ void Application::initialize()

// Initialize the window
window->initialize("Bare", 720, AspectRatio(16, 9), 1.2f);

logger.logInformation("Ready! - Userland awaits you");
}

void Application::run()
Expand Down
8 changes: 3 additions & 5 deletions src/System/Display/SdlWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ void SdlWindow::initialize(const string &title, int size, AspectRatio aspect, fl
auto error = string(SDL_GetError());
auto errorMessage = "SDL window could not be created: " + error;

logger.logError(errorMessage);
throw Exception(errorMessage);
logger.logFatal(errorMessage);
}

SDL_SetWindowMinimumSize(windowHandle, width, height);
Expand All @@ -68,11 +67,10 @@ void SdlWindow::initialize(const string &title, int size, AspectRatio aspect, fl
auto error = string(SDL_GetError());
auto errorMessage = "SDL window manager info could not be created: " + error;

logger.logError(errorMessage);
throw Exception(errorMessage);
logger.logFatal(errorMessage);
}

SdlContextHandle* contextHandle;
const SdlContextHandle* contextHandle;
switch (wmInfo.subsystem) {
case SDL_SYSWM_COCOA:
contextHandle = new SdlContextHandle(nullptr, wmInfo.info.cocoa.window);
Expand Down
7 changes: 6 additions & 1 deletion src/System/Logging/Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#include <fmt/color.h>
#include <boost/core/demangle.hpp>

#include "System/Exception.hpp"

using Bare::System::Exception;
using fmt::format;
using fmt::format_args;
using fmt::make_format_args;
Expand Down Expand Up @@ -121,7 +124,9 @@ void Logger<T>::logFatal(const string &message, const Args &... args)
{
#if LOG_LEVEL <= LEVEL_FATAL
log(CHANNEL_FATAL, message, make_format_args(args...));
exit(1);

// TODO: Evaluate if this solution makes sense
throw Exception(message);
#endif
}

Expand Down
3 changes: 2 additions & 1 deletion src/System/Renderer/BgfxRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ void BgfxRenderer::initialize(const IContextHandle &contextHandle)
platformData.backBufferDS = nullptr;

Init initParams;

initParams.platformData = platformData;
init(initParams);

init(initParams);
setDebug(BGFX_DEBUG_TEXT);

logger.logInformation("Successfully initialized bgfx renderer");
Expand Down

0 comments on commit eb60747

Please sign in to comment.