tools: use Log instead of fmt::print
Since fmt::print does not flush the buffer, I added a Log macro to
ensure the output is immediately flushed.
Not needed for print on stderr as std lib already flush it.
Change-Id: Ieb7c04f9f191f1982643b005fae2d4e944a3a1fa
diff --git a/tools/dvpn/main.cpp b/tools/dvpn/main.cpp
index cd5b3df..1cf3ec9 100644
--- a/tools/dvpn/main.cpp
+++ b/tools/dvpn/main.cpp
@@ -179,7 +179,7 @@
pj_log_set_level(level);
pj_log_set_log_func([](int level, const char* data, int len) {
- fmt::print("{}", std::string_view(data, len));
+ Log("{}", std::string_view(data, len));
});
}
@@ -190,7 +190,7 @@
auto params = parse_args(argc, argv);
if (params.help) {
- fmt::print(
+ Log(
"Usage: dvpn [options] [PEER_ID]\n"
"\nOptions:\n"
" -h, --help Show this help message and exit.\n"
@@ -210,18 +210,18 @@
return EXIT_SUCCESS;
}
if (params.version) {
- fmt::print("dvpn v1.0\n");
+ Log("dvpn v1.0\n");
return EXIT_SUCCESS;
}
- fmt::print("dvpn 1.0\n");
+ Log("dvpn 1.0\n");
auto identity = dhtnet::loadIdentity(params.privateKey, params.cert);
if (!identity.first || !identity.second) {
fmt::print(stderr, "Hint: To generate new identity files, run: dhtnet-crtmgr --interactive\n");
return EXIT_FAILURE;
}
- fmt::print("Loaded identity: {}\n", identity.second->getId());
+ Log("Loaded identity: {}\n", identity.second->getId());
std::unique_ptr<dhtnet::Dvpn> dvpn;
if (params.listen) {