aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/servers/httpasio.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-11-06 20:36:30 +0100
committerGitHub <[email protected]>2023-11-06 20:36:30 +0100
commit07f288d6e119fc6bb524fb634bc9094109a2ab05 (patch)
tree8531bd38d0d8c3567ba3d0a5603f549faf99632b /src/zenhttp/servers/httpasio.cpp
parentgc v2 tests (#512) (diff)
downloadzen-07f288d6e119fc6bb524fb634bc9094109a2ab05.tar.xz
zen-07f288d6e119fc6bb524fb634bc9094109a2ab05.zip
spdlog implementation hiding (#498)
this change aims to hide logging internals from client code, in order to make it easier to extend and take more control over the logging process in the future. As a bonus side effect, the generated code is much tighter (net delta around 2.5% on the resulting executable which includes lots of thirdparty code) and should take less time to compile and link. Client usage via macros is pretty much unchanged. The main exposure client code had to spdlog internals before was the use of custom loggers per subsystem, where it would be common to have `spdlog::logger` references to keep a reference to a logger within a class. This is now replaced by `zen::LoggerRef` which currently simply encapsulates an actual `spdlog::logger` instance, but this is intended to be an implementation detail which will change in the future. The way the change works is that we now handle any formatting of log messages in the zencore logging subsystem instead of relying on `spdlog` to manage this. We use the `fmt` library to do the formatting which means the client usage is identical to using `spdlog`. The formatted message is then forwarded onto any sinks etc which are still implememted via `spdlog`.
Diffstat (limited to 'src/zenhttp/servers/httpasio.cpp')
-rw-r--r--src/zenhttp/servers/httpasio.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/zenhttp/servers/httpasio.cpp b/src/zenhttp/servers/httpasio.cpp
index 0c6b189f9..44398d92d 100644
--- a/src/zenhttp/servers/httpasio.cpp
+++ b/src/zenhttp/servers/httpasio.cpp
@@ -47,18 +47,18 @@ static constinit uint32_t HashSession = HashStringAsLowerDjb2("UE-Session"sv);
static constinit uint32_t HashRequest = HashStringAsLowerDjb2("UE-Request"sv);
static constinit uint32_t HashRange = HashStringAsLowerDjb2("Range"sv);
-inline spdlog::logger&
+inline LoggerRef
InitLogger()
{
- spdlog::logger& Logger = logging::Get("asio");
+ LoggerRef Logger = logging::Get("asio");
// Logger.set_level(spdlog::level::trace);
return Logger;
}
-inline spdlog::logger&
+inline LoggerRef
Log()
{
- static spdlog::logger& g_Logger = InitLogger();
+ static LoggerRef g_Logger = InitLogger();
return g_Logger;
}
@@ -1007,7 +1007,7 @@ HttpAsioServer::Run(bool IsInteractive)
#if ZEN_PLATFORM_WINDOWS
if (TestMode == false)
{
- zen::logging::ConsoleLog().info("Zen Server running (asio HTTP). Press ESC or Q to quit");
+ ZEN_CONSOLE("Zen Server running (asio HTTP). Press ESC or Q to quit");
}
do
@@ -1027,7 +1027,7 @@ HttpAsioServer::Run(bool IsInteractive)
#else
if (TestMode == false)
{
- zen::logging::ConsoleLog().info("Zen Server running (asio HTTP). Ctrl-C to quit");
+ ZEN_CONSOLE("Zen Server running (asio HTTP). Ctrl-C to quit");
}
do