Updated logging

This commit is contained in:
acidicoala
2023-01-08 11:52:23 +03:00
parent a2cbf55819
commit 55ada47bef
16 changed files with 132 additions and 87 deletions

View File

@@ -15,11 +15,11 @@ constexpr auto KEY_APPS = "apps";
Apps get_cached_apps() {
try {
const auto cache = koalabox::cache::read_from_cache(KEY_APPS).value();
const auto cache = koalabox::cache::read_from_cache(KEY_APPS);
return cache.get<Apps>();
} catch (const Exception& e) {
LOG_WARN("{} -> Failed to get cached apps: {}", __func__, e.what())
LOG_WARN("Failed to get cached apps: {}", e.what())
return {};
}
@@ -29,7 +29,7 @@ namespace smoke_api::app_cache {
Vector<AppId_t> get_dlc_ids(AppId_t app_id) {
try {
LOG_DEBUG("{} -> Reading cached DLC IDs for the app: {}", __func__, app_id)
LOG_DEBUG("Reading cached DLC IDs for the app: {}", app_id)
const auto app = get_cached_apps().at(std::to_string(app_id));
@@ -41,7 +41,7 @@ namespace smoke_api::app_cache {
bool save_dlc_ids(AppId_t app_id, const Vector<AppId_t>& dlc_ids) {
try {
LOG_DEBUG("{} -> Caching DLC IDs for the app: {}", __func__, app_id)
LOG_DEBUG("Caching DLC IDs for the app: {}", app_id)
auto apps = get_cached_apps();
@@ -49,9 +49,9 @@ namespace smoke_api::app_cache {
.dlc_ids = dlc_ids
};
return koalabox::cache::save_to_cache(KEY_APPS, apps);
return koalabox::cache::save_to_cache(KEY_APPS, Json(apps));
} catch (const Exception& e) {
LOG_ERROR("{} -> Failed to cache DLC IDs fro the app: {}", __func__, app_id)
LOG_ERROR("Failed to cache DLC IDs fro the app: {}", app_id)
return false;
}

View File

@@ -4,16 +4,15 @@
#include <core/globals.hpp>
#include <core/paths.hpp>
#include <steam_functions/steam_functions.hpp>
#include <koalabox/config_parser.hpp>
#include <koalabox/dll_monitor.hpp>
#include <koalabox/logger.hpp>
#include <koalabox/hook.hpp>
#include <koalabox/cache.hpp>
#include <koalabox/loader.hpp>
#include <koalabox/win_util.hpp>
#include <koalabox/util.hpp>
// TODO: Define COMPILE_KOALAGEDDON in CMake
#ifndef _WIN64
#if COMPILE_KOALAGEDDON
#include <koalageddon/koalageddon.hpp>
#endif
@@ -56,7 +55,7 @@ void init_hook_mode() {
}
bool is_valve_steam(const String& exe_name) {
if (not koalabox::util::strings_are_equal(exe_name, "steam.exe")) {
if (exe_name < not_equals > "steam.exe") {
return false;
}
@@ -71,7 +70,7 @@ bool is_valve_steam(const String& exe_name) {
}
// Steam.exe manifest is expected to contain this string
return manifest->find("valvesoftware.steam.steam") != String::npos;
return *manifest < contains > "valvesoftware.steam.steam";
}
namespace smoke_api {
@@ -90,18 +89,18 @@ namespace smoke_api {
koalabox::logger::init_file_logger(paths::get_log_path());
}
LOG_INFO("🐨 {} v{}", PROJECT_NAME, PROJECT_VERSION)
LOG_INFO("🐨 {} v{} | Compiled at '{}'", PROJECT_NAME, PROJECT_VERSION, __TIMESTAMP__)
const auto exe_path = Path(koalabox::win_util::get_module_file_name_or_throw(nullptr));
const auto exe_name = exe_path.filename().string();
LOG_DEBUG(R"(Process name: "{}" [{}-bit])", exe_name, BITNESS)
LOG_DEBUG("Process name: '{}' [{}-bit]", exe_name, BITNESS)
if (koalabox::hook::is_hook_mode(globals::smokeapi_handle, STEAMAPI_DLL)) {
koalabox::hook::init(true);
if (is_valve_steam(exe_name)) {
#ifndef _WIN64
#if COMPILE_KOALAGEDDON
LOG_INFO("🐨💥 Detected Koalageddon mode")
koalageddon::init();
#endif