aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-08-24 17:15:30 -0700
committerFuwn <[email protected]>2021-08-24 17:15:30 -0700
commita1ab269ca822f4033ecf58cc9e83e068ca637320 (patch)
tree1ebe20fc9afafc682efb3e2237e57e9f0fffcd9a
parentrefactor(tray): emplace_back instead of push_back (diff)
downloadsoyuz-a1ab269ca822f4033ecf58cc9e83e068ca637320.tar.xz
soyuz-a1ab269ca822f4033ecf58cc9e83e068ca637320.zip
refactor(library): log using fmtlib
-rw-r--r--soyuz/library.cc21
1 files changed, 11 insertions, 10 deletions
diff --git a/soyuz/library.cc b/soyuz/library.cc
index 5777fe2..83c6072 100644
--- a/soyuz/library.cc
+++ b/soyuz/library.cc
@@ -3,7 +3,7 @@
#include <cstdio>
#include <fmt/format.h>
-#include <fstream>
+#include <fmt/os.h>
#include <memory>
#include <string>
#include <Windows.h>
@@ -15,7 +15,7 @@
namespace soyuz {
-std::ofstream log_file("soyuz.log");
+fmt::ostream log_file = fmt::output_file("soyuz.log");
static auto enum_windows_proc(HWND hwnd, LPARAM lparam) -> BOOL {
int length = GetWindowTextLength(hwnd);
@@ -138,16 +138,16 @@ auto delete_handle(DWORD pid) -> int {
}
auto write_log_file(const std::string &message) -> void {
- log_file << message << std::endl;
+ log_file.print("{}\n", message);
}
auto init_log_file() -> void {
- if (!log_file.is_open()) {
- soyuz::log("could not open 'soyuz.log'");
- soyuz::log("proceeding without logging to file");
-
- return;
- }
+// if (!log_file.is_open()) {
+// soyuz::log("could not open 'soyuz.log'");
+// soyuz::log("proceeding without logging to file");
+//
+// return;
+// }
soyuz::log("opened 'soyuz.log'");
}
@@ -157,7 +157,8 @@ auto close_log_file() -> void {
}
auto exit(int exit_code) -> void {
- if (log_file.is_open()) { close_log_file(); }
+ // if (log_file.is_open()) { close_log_file(); }
+ close_log_file();
::exit(exit_code);
}