diff options
| author | Fuwn <[email protected]> | 2022-02-11 04:03:21 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-02-11 04:03:21 -0800 |
| commit | 69e288543066061fca04a5d278045fc7be02a5f0 (patch) | |
| tree | 4880e28fb46045e730572a75b7fb3faf5ad60a0c | |
| parent | feat(library): implement colourful logging (diff) | |
| download | soyuz-69e288543066061fca04a5d278045fc7be02a5f0.tar.xz soyuz-69e288543066061fca04a5d278045fc7be02a5f0.zip | |
feat: use colourful logging
| -rw-r--r-- | soyuz/library.cc | 12 | ||||
| -rw-r--r-- | soyuz/soyuz.cc | 18 |
2 files changed, 15 insertions, 15 deletions
diff --git a/soyuz/library.cc b/soyuz/library.cc index a3f1874..691aaf3 100644 --- a/soyuz/library.cc +++ b/soyuz/library.cc @@ -62,7 +62,7 @@ auto delete_handle(DWORD pid) -> int { pid ); if (!lunar) { - soyuz::log(fmt::format("could not open handle to lunar client: {}", GetLastError())); + soyuz::log(soyuz::log_level::warn, fmt::format("could not open handle to lunar client: {}", GetLastError())); return 1; } @@ -83,7 +83,7 @@ auto delete_handle(DWORD pid) -> int { if (NT_SUCCESS(status)) { break; } if (status == STATUS_INFO_LENGTH_MISMATCH) { size += 1 << 10; continue; } - soyuz::log("could not enumerate handle, skipping"); + soyuz::log(soyuz::log_level::debug, "could not enumerate handle, skipping"); return 1; } @@ -121,7 +121,7 @@ auto delete_handle(DWORD pid) -> int { auto *name = reinterpret_cast<UNICODE_STRING *>(name_buffer); if (name->Buffer && _wcsnicmp(name->Buffer, target_name, length) == 0) { - soyuz::log("found lunar client's discord ipc named pipe"); + soyuz::log(soyuz::log_level::info, "found lunar client's discord ipc named pipe"); DuplicateHandle( lunar, @@ -134,7 +134,7 @@ auto delete_handle(DWORD pid) -> int { ); CloseHandle(target); - soyuz::log("closed lunar client's discord ipc named pipe"); + soyuz::log(soyuz::log_level::info, "closed lunar client's discord ipc named pipe"); return 0; } @@ -155,11 +155,11 @@ auto init_log_file() -> void { // return; // } - soyuz::log("opened 'soyuz.log'"); + soyuz::log(soyuz::log_level::debug, "opened 'soyuz.log'"); } auto close_log_file() -> void { - soyuz::log("closing 'soyuz.log'"); log_file.close(); + soyuz::log(soyuz::log_level::debug, "closing 'soyuz.log'"); log_file.close(); } auto exit(int exit_code) -> void { diff --git a/soyuz/soyuz.cc b/soyuz/soyuz.cc index 6ea908f..9e1d8a9 100644 --- a/soyuz/soyuz.cc +++ b/soyuz/soyuz.cc @@ -75,17 +75,17 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int show) { // Check if Lunar Client is open, if not; close Soyuz DWORD pid = soyuz::find_lunar(); if (pid == 0 || pid == 3435973836) { - soyuz::log("could not locate lunar client"); - soyuz::log("this window will close in five seconds"); + soyuz::log(soyuz::log_level::error, "could not locate lunar client"); + soyuz::log(soyuz::log_level::warn, "this window will close in five seconds"); for (int i = 4; i > -1; --i) { std::this_thread::sleep_for(std::chrono::seconds(1)); - soyuz::log(fmt::format("> {} second{}", soyuz::numbers_as_string[i], i != 1 ? "s" : "")); + soyuz::log(soyuz::log_level::warn, fmt::format("> {} second{}", soyuz::numbers_as_string[i], i != 1 ? "s" : "")); } soyuz::exit(1); } - soyuz::log(fmt::format("located lunar client: pid {}", pid)); // GetLastError() - soyuz::log("hooked lunar client"); soyuz::log("you may now close this window"); + soyuz::log(soyuz::log_level::info, fmt::format("located lunar client: pid {}", pid)); // GetLastError() + soyuz::log(soyuz::log_level::info, "hooked lunar client"); soyuz::log(soyuz::log_level::info, "you may now close this window"); while (!stop.stop_requested()) { /** @@ -95,13 +95,13 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int show) { */ pid = soyuz::find_lunar(); if (pid == 0 || pid == 3435973836) { - soyuz::log("could not locate lunar client, waiting 10 seconds"); + soyuz::log(soyuz::log_level::warn, "could not locate lunar client, waiting 10 seconds"); std::this_thread::sleep_for(std::chrono::seconds(10)); } // If Lunar Client **is** open, close it's Discord IPC Named Pipe if (soyuz::delete_handle(pid) == 1) { - soyuz::log("unable to close lunar client's discord ipc named pipe"); + soyuz::log(soyuz::log_level::warn, "unable to close lunar client's discord ipc named pipe"); } } }}; @@ -111,10 +111,10 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int show) { DispatchMessage(&messages); } - soyuz::log("requesting exit"); + soyuz::log(soyuz::log_level::info, "requesting exit"); soyuz.request_stop(); soyuz.detach(); - soyuz::log("exiting"); + soyuz::log(soyuz::log_level::info, "exiting"); soyuz::close_log_file(); return (int)messages.wParam; |