aboutsummaryrefslogtreecommitdiff
path: root/zenserver-test/zenserver-test.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-09-15 11:27:48 +0200
committerStefan Boberg <[email protected]>2021-09-15 11:27:48 +0200
commit2b9bed6635d95e15847c4d9b602e34d90e277d14 (patch)
tree66fb191150ccbf9f56315a716abd23b25cc1d401 /zenserver-test/zenserver-test.cpp
parentxmake: added zenhttp dependency to make zen CLI tool buld (diff)
downloadzen-2b9bed6635d95e15847c4d9b602e34d90e277d14.tar.xz
zen-2b9bed6635d95e15847c4d9b602e34d90e277d14.zip
Changed logging implementation
* Code should no longer directly `#include spdlog/spdlog.h`, instead use `#include <zencore/logging.h>` * Instead of explicit calls to `spdlog::info(...)` and such please use the logging macros defined in `zencore/logging.h`. I.e `ZEN_INFO`, `ZEN_DEBUG`, `ZEN_TRACE`, `ZEN_ERROR`, `ZEN_CRITITCAL` * The macros will pick up the "most local" logger via a `Log()` call to retrieve a logger instance. To override the default logger in a class please implement your own `Log()` function
Diffstat (limited to 'zenserver-test/zenserver-test.cpp')
-rw-r--r--zenserver-test/zenserver-test.cpp69
1 files changed, 30 insertions, 39 deletions
diff --git a/zenserver-test/zenserver-test.cpp b/zenserver-test/zenserver-test.cpp
index 8b56c406a..df17cc353 100644
--- a/zenserver-test/zenserver-test.cpp
+++ b/zenserver-test/zenserver-test.cpp
@@ -122,7 +122,7 @@ public:
private:
void Reset() {}
- void OnError(const std::error_code& Error) { spdlog::error("HTTP client error! '{}'", Error.message()); }
+ void OnError(const std::error_code& Error) { ZEN_ERROR("HTTP client error! '{}'", Error.message()); }
int OnHeader(const char* Data, size_t Bytes)
{
@@ -136,7 +136,7 @@ private:
}
int OnHeadersComplete()
{
- spdlog::debug("Headers complete");
+ ZEN_DEBUG("Headers complete");
return 0;
}
int OnMessageComplete()
@@ -197,7 +197,7 @@ private:
{
// Something bad!
- spdlog::error("parse error {}", (uint32_t)m_HttpParser.http_errno);
+ ZEN_ERROR("parse error {}", (uint32_t)m_HttpParser.http_errno);
}
switch (m_RequestState)
@@ -612,7 +612,7 @@ main()
if (Result.status_code != 200)
{
- spdlog::warn("request response: {}", Result.status_code);
+ ZEN_WARN("request response: {}", Result.status_code);
}
}
};
@@ -630,7 +630,7 @@ main()
// cpr::Response r = cpr::Get(cpr::Url{ "http://localhost:1337/test/hello" });
- spdlog::info("{} requests in {} ({})",
+ ZEN_INFO("{} requests in {} ({})",
RequestCount,
zen::NiceTimeSpanMs(timer.getElapsedTimeMs()),
zen::NiceRate(RequestCount, (uint32_t)timer.getElapsedTimeMs(), "req"));
@@ -667,7 +667,7 @@ main(int argc, char** argv)
TestEnv.InitializeForTest(ProgramBaseDir, TestBaseDir);
- spdlog::info("Running tests...(base dir: '{}')", TestBaseDir);
+ ZEN_INFO("Running tests...(base dir: '{}')", TestBaseDir);
return doctest::Context(argc, argv).run();
}
@@ -680,7 +680,7 @@ TEST_CASE("asio.http")
Instance.SetTestDir(TestDir);
Instance.SpawnServer(13337);
- spdlog::info("Waiting...");
+ ZEN_INFO("Waiting...");
Instance.WaitUntilReady();
@@ -703,20 +703,20 @@ TEST_CASE("default.single")
Instance.SetTestDir(TestDir);
Instance.SpawnServer(13337);
- spdlog::info("Waiting...");
+ ZEN_INFO("Waiting...");
Instance.WaitUntilReady();
std::atomic<uint64_t> RequestCount{0};
std::atomic<uint64_t> BatchCounter{0};
- spdlog::info("Running single server test...");
+ ZEN_INFO("Running single server test...");
auto IssueTestRequests = [&] {
const uint64_t BatchNo = BatchCounter.fetch_add(1);
const DWORD ThreadId = GetCurrentThreadId();
- spdlog::info("query batch {} started (thread {})", BatchNo, ThreadId);
+ ZEN_INFO("query batch {} started (thread {})", BatchNo, ThreadId);
cpr::Session cli;
cli.SetUrl(cpr::Url{"http://localhost:13337/test/hello"});
@@ -725,7 +725,7 @@ TEST_CASE("default.single")
auto res = cli.Get();
++RequestCount;
}
- spdlog::info("query batch {} ended (thread {})", BatchNo, ThreadId);
+ ZEN_INFO("query batch {} ended (thread {})", BatchNo, ThreadId);
};
auto fun10 = [&] {
@@ -757,10 +757,7 @@ TEST_CASE("default.single")
uint64_t Elapsed = timer.getElapsedTimeMs();
- spdlog::info("{} requests in {} ({})",
- RequestCount,
- zen::NiceTimeSpanMs(Elapsed),
- zen::NiceRate(RequestCount, (uint32_t)Elapsed, "req"));
+ ZEN_INFO("{} requests in {} ({})", RequestCount, zen::NiceTimeSpanMs(Elapsed), zen::NiceRate(RequestCount, (uint32_t)Elapsed, "req"));
}
TEST_CASE("multi.basic")
@@ -775,7 +772,7 @@ TEST_CASE("multi.basic")
Instance2.SetTestDir(TestDir2);
Instance2.SpawnServer(13338);
- spdlog::info("Waiting...");
+ ZEN_INFO("Waiting...");
Instance1.WaitUntilReady();
Instance2.WaitUntilReady();
@@ -787,7 +784,7 @@ TEST_CASE("multi.basic")
const uint64_t BatchNo = BatchCounter.fetch_add(1);
const DWORD ThreadId = GetCurrentThreadId();
- spdlog::info("query batch {} started (thread {}) for port {}", BatchNo, ThreadId, PortNumber);
+ ZEN_INFO("query batch {} started (thread {}) for port {}", BatchNo, ThreadId, PortNumber);
cpr::Session cli;
cli.SetUrl(cpr::Url{"http://localhost:{}/test/hello"_format(PortNumber)});
@@ -797,12 +794,12 @@ TEST_CASE("multi.basic")
auto res = cli.Get();
++RequestCount;
}
- spdlog::info("query batch {} ended (thread {})", BatchNo, ThreadId);
+ ZEN_INFO("query batch {} ended (thread {})", BatchNo, ThreadId);
};
zen::Stopwatch timer;
- spdlog::info("Running multi-server test...");
+ ZEN_INFO("Running multi-server test...");
Concurrency::parallel_invoke([&] { IssueTestRequests(13337); },
[&] { IssueTestRequests(13338); },
@@ -811,10 +808,7 @@ TEST_CASE("multi.basic")
uint64_t Elapsed = timer.getElapsedTimeMs();
- spdlog::info("{} requests in {} ({})",
- RequestCount,
- zen::NiceTimeSpanMs(Elapsed),
- zen::NiceRate(RequestCount, (uint32_t)Elapsed, "req"));
+ ZEN_INFO("{} requests in {} ({})", RequestCount, zen::NiceTimeSpanMs(Elapsed), zen::NiceRate(RequestCount, (uint32_t)Elapsed, "req"));
}
TEST_CASE("cas.basic")
@@ -887,10 +881,10 @@ TEST_CASE("cas.basic")
uint64_t Elapsed = timer.getElapsedTimeMs();
- spdlog::info("{} requests in {} ({})",
- RequestCount,
- zen::NiceTimeSpanMs(Elapsed),
- zen::NiceRate(RequestCount, (uint32_t)Elapsed, "req"));
+ ZEN_INFO("{} requests in {} ({})",
+ RequestCount,
+ zen::NiceTimeSpanMs(Elapsed),
+ zen::NiceRate(RequestCount, (uint32_t)Elapsed, "req"));
}
// Verify that the data persists between process runs (the previous server has exited at this point)
@@ -1057,17 +1051,14 @@ TEST_CASE("project.basic")
CHECK(Response.text.size() == 10);
}
- spdlog::info("+++++++");
+ ZEN_INFO("+++++++");
}
- SUBCASE("build store op commit") { spdlog::info("-------"); }
+ SUBCASE("build store op commit") { ZEN_INFO("-------"); }
}
const uint64_t Elapsed = timer.getElapsedTimeMs();
- spdlog::info("{} requests in {} ({})",
- RequestCount,
- zen::NiceTimeSpanMs(Elapsed),
- zen::NiceRate(RequestCount, (uint32_t)Elapsed, "req"));
+ ZEN_INFO("{} requests in {} ({})", RequestCount, zen::NiceTimeSpanMs(Elapsed), zen::NiceRate(RequestCount, (uint32_t)Elapsed, "req"));
}
# if 0 // this is extremely WIP
@@ -1238,12 +1229,12 @@ struct RemoteExecutionRequest
if (CasResponse.status_code >= 300)
{
- spdlog::error("CAS put failed with {}", CasResponse.status_code);
+ ZEN_ERROR("CAS put failed with {}", CasResponse.status_code);
}
}
else
{
- spdlog::error("unknown hash in 'need' list: {}", NeedHash);
+ ZEN_ERROR("unknown hash in 'need' list: {}", NeedHash);
}
}
}
@@ -1259,7 +1250,7 @@ struct RemoteExecutionRequest
return zen::LoadCompactBinaryObject(std::move(Payload));
}
- spdlog::info("job exec: {}", JobResponse.status_code);
+ ZEN_INFO("job exec: {}", JobResponse.status_code);
return {};
}
@@ -1279,7 +1270,7 @@ private:
zen::IoHash Hash = Ios.GetHash();
std::wstring RelativePath = FullPath.lexically_relative(m_RootPath).native();
- // spdlog::info("File: {:32} => {} ({})", zen::WideToUtf8(RelativePath), Hash, FileSize);
+ // ZEN_INFO("File: {:32} => {} ({})", zen::WideToUtf8(RelativePath), Hash, FileSize);
FileEntry& Entry = m_Files[RelativePath];
Entry.Hash = Hash;
@@ -1359,7 +1350,7 @@ TEST_CASE("mesh.basic")
const int kInstanceCount = 4;
- spdlog::info("spawning {} instances", kInstanceCount);
+ ZEN_INFO("spawning {} instances", kInstanceCount);
std::unique_ptr<ZenServerInstance> Instances[kInstanceCount];
@@ -1394,7 +1385,7 @@ public:
void SpawnServers(auto&& Callback)
{
- spdlog::info("{}: spawning {} server instances", m_HelperId, m_ServerCount);
+ ZEN_INFO("{}: spawning {} server instances", m_HelperId, m_ServerCount);
m_Instances.resize(m_ServerCount);