Skip to content

Commit

Permalink
Add logging service
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-johansson committed Jul 19, 2023
1 parent 4c75ee8 commit 56c6b8a
Show file tree
Hide file tree
Showing 8 changed files with 359 additions and 307 deletions.
184 changes: 0 additions & 184 deletions source/lib/common/debug/logging.cpp

This file was deleted.

58 changes: 0 additions & 58 deletions source/lib/common/debug/logging.hpp

This file was deleted.

12 changes: 10 additions & 2 deletions source/lib/engine/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@
#include "backend/gl/gl_backend.hpp"
#include "backend/null/null_backend.hpp"
#include "common/debug/assert.hpp"
#include "common/debug/logging.hpp"
#include "common/debug/stacktrace.hpp"
#include "common/fmt/stacktrace_formatter.hpp"
#include "engine/app_delegate.hpp"
#include "engine/platform/window.hpp"
#include "io/directories.hpp"
#include "model/locator.hpp"
#include "model/services/logging_service.hpp"

namespace tactile {

Expand All @@ -54,7 +56,11 @@ Engine::Engine(const BackendAPI api)
: mAPI {api}
{
std::set_terminate(&on_terminate);
init_logger();

mLoggingService = std::make_unique<LoggingService>();
mLoggingService->install_logger();

Locator<LoggingService>::reset(mLoggingService.get());

mProtobuf.emplace();
auto& sdl = mSDL.emplace(mAPI);
Expand All @@ -80,6 +86,8 @@ Engine::Engine(const BackendAPI api)
spdlog::debug("[IO] Persistent file directory: {}", get_persistent_file_dir());
}

Engine::~Engine() noexcept = default;

void Engine::start()
{
TACTILE_ASSERT(mBackend != nullptr);
Expand Down
10 changes: 8 additions & 2 deletions source/lib/engine/engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,27 @@

#include <centurion/input/keyboard.hpp>

#include "backend/backend.hpp"
#include "common/enum/backend_api.hpp"
#include "common/macros.hpp"
#include "common/predef.hpp"
#include "common/type/maybe.hpp"
#include "common/type/ptr.hpp"
#include "engine/app_delegate.hpp"
#include "engine/platform/imgui_context.hpp"
#include "engine/platform/protobuf_context.hpp"
#include "engine/platform/sdl_context.hpp"

namespace tactile {

TACTILE_FWD_DECLARE_CLASS(LoggingService)
TACTILE_FWD_DECLARE_CLASS(Backend)
TACTILE_FWD_DECLARE_CLASS(AppDelegate)

class Engine final {
public:
explicit Engine(BackendAPI api);

~Engine() noexcept;

void start();

void set_app_delegate(Unique<AppDelegate> app);
Expand All @@ -45,6 +50,7 @@ class Engine final {

private:
BackendAPI mAPI;
Unique<LoggingService> mLoggingService;
Maybe<ProtobufContext> mProtobuf;
Maybe<SDLContext> mSDL;
Maybe<ImGuiContext> mImGui;
Expand Down
Loading

0 comments on commit 56c6b8a

Please sign in to comment.