diff options
| author | Fuwn <[email protected]> | 2021-08-24 17:03:45 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-08-24 17:03:45 -0700 |
| commit | 2c9ae7e03f24a5930488b304f6e655bb160f1f13 (patch) | |
| tree | b21c9d837f60202b2d6890c84daa489cedf33948 | |
| parent | fix(deps): fmtlib (diff) | |
| download | soyuz-2c9ae7e03f24a5930488b304f6e655bb160f1f13.tar.xz soyuz-2c9ae7e03f24a5930488b304f6e655bb160f1f13.zip | |
refactor(soyuz): use fmtlib instead of std
| -rw-r--r-- | soyuz/library.cc | 5 | ||||
| -rw-r--r-- | soyuz/soyuz.cc | 5 | ||||
| -rw-r--r-- | soyuz/tray.cc | 6 |
3 files changed, 7 insertions, 9 deletions
diff --git a/soyuz/library.cc b/soyuz/library.cc index a0bfbd7..0340a02 100644 --- a/soyuz/library.cc +++ b/soyuz/library.cc @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-3.0-only #include <cstdio> +#include <fmt/format.h> #include <fstream> #include <memory> #include <sstream> @@ -56,9 +57,7 @@ auto delete_handle(DWORD pid) -> int { pid ); if (!lunar) { - std::stringstream ss; - ss << "could not open handle to lunar client: " << GetLastError(); - soyuz::log(ss.str()); + soyuz::log(fmt::format("could not open handle to lunar client: {}", GetLastError())); return 1; } diff --git a/soyuz/soyuz.cc b/soyuz/soyuz.cc index 00457b8..95b346c 100644 --- a/soyuz/soyuz.cc +++ b/soyuz/soyuz.cc @@ -3,6 +3,7 @@ #pragma comment(lib, "ntdll.lib") +#include <fmt/format.h> #include <thread> #include <Windows.h> @@ -65,9 +66,7 @@ auto WinMain(HINSTANCE instance, HINSTANCE previous, LPSTR argument, int show) - soyuz::exit(1); } - std::stringstream ss; - ss << "located lunar client: pid " << pid; - soyuz::log(ss.str()); + soyuz::log(fmt::format("located lunar client: pid {}", GetLastError())); while (!stop.stop_requested()) { if (soyuz::delete_handle(pid) == 1) { diff --git a/soyuz/tray.cc b/soyuz/tray.cc index e57771c..d7742f5 100644 --- a/soyuz/tray.cc +++ b/soyuz/tray.cc @@ -1,6 +1,7 @@ // Copyright (C) 2021-2021 Fuwn // SPDX-License-Identifier: GPL-3.0-only +#include <fmt/format.h> #include <sstream> #include "soyuz/library.hh" @@ -131,10 +132,9 @@ namespace soyuz { auto log(const std::string &message) -> void { if (logs.size() == 16) { logs.erase(logs.begin()); } - std::ostringstream ss; - ss << "[" << current_date_time() << "] " << message; + std::string to_log = fmt::format("[{}] {}", current_date_time(), message); - LOG(ss.str()) write_log_file(ss.str()); + LOG(to_log.c_str()) write_log_file(to_log); RedrawWindow(window, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW); } |