Skip to content

Commit

Permalink
feat(log): play around with log levels in load()
Browse files Browse the repository at this point in the history
  • Loading branch information
Fleeym committed Jan 6, 2025
1 parent 143ef8d commit 91e61ad
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
56 changes: 28 additions & 28 deletions loader/src/loader/LoaderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,28 @@ Result<> Loader::Impl::setup() {
}

if (this->supportsLaunchArguments()) {
log::debug("Loading launch arguments");
log::info("Loading launch arguments");
log::NestScope nest;
this->initLaunchArguments();
}

// on some platforms, using the crash handler overrides more convenient native handlers
if (!this->getLaunchFlag("disable-crash-handler")) {
log::debug("Setting up crash handler");
log::info("Setting up crash handler");
log::NestScope nest;
if (!crashlog::setupPlatformHandler()) {
log::debug("Failed to set up crash handler");
}
} else {
log::debug("Crash handler setup skipped");
log::info("Crash handler setup skipped");
}

log::debug("Loading hooks");
log::info("Loading hooks");
if (log::NestScope nest; !this->loadHooks()) {
return Err("There were errors loading some hooks, see console for details");
}

log::debug("Setting up directories");
log::info("Setting up directories");
{
log::NestScope nest;
this->createDirectories();
Expand All @@ -112,6 +112,7 @@ Result<> Loader::Impl::setup() {
// this function is already on the gd thread, so this should be fine
ModStateEvent(Mod::get(), ModEventType::Loaded).post();

log::info("Refreshing mod graph");
this->refreshModGraph();

m_isSetup = true;
Expand Down Expand Up @@ -405,18 +406,18 @@ void Loader::Impl::loadModGraph(Mod* node, bool early) {
}

if (node->hasUnresolvedDependencies()) {
log::debug("{} {} has unresolved dependencies", node->getID(), node->getVersion());
log::warn("{} {} has unresolved dependencies", node->getID(), node->getVersion());
return;
}
if (node->hasUnresolvedIncompatibilities()) {
log::debug("{} {} has unresolved incompatibilities", node->getID(), node->getVersion());
log::warn("{} {} has unresolved incompatibilities", node->getID(), node->getVersion());
return;
}

log::NestScope nest;

if (node->isEnabled()) {
log::warn("Mod {} already loaded, this should never happen", node->getID());
log::error("Mod {} already loaded, this should never happen", node->getID());
return;
}

Expand All @@ -426,16 +427,14 @@ void Loader::Impl::loadModGraph(Mod* node, bool early) {
m_lateRefreshedModCount += early ? 0 : 1;

auto unzipFunction = [this, node]() {
log::debug("Unzip");
log::NestScope nest;
log::debug("Unzipping .geode file");
auto res = node->m_impl->unzipGeodeFile(node->getMetadata());
return res;
};

auto loadFunction = [this, node, early]() {
if (node->shouldLoad()) {
log::debug("Load");
log::NestScope nest;
log::debug("Loading binary");
auto res = node->m_impl->loadBinary();
if (!res) {
this->addProblem({
Expand Down Expand Up @@ -513,7 +512,7 @@ void Loader::Impl::findProblems() {
continue;
}
if (mod->targetsOutdatedVersion()) {
log::debug("{} is outdated", id);
log::warn("{} is outdated", id);
continue;
}
log::debug("{}", id);
Expand All @@ -536,7 +535,7 @@ void Loader::Impl::findProblems() {
log::info("{} suggests {} {}", id, dep.id, dep.version);
}
else {
log::info("{} suggests {} {}, but that suggestion was dismissed", id, dep.id, dep.version);
log::debug("{} suggests {} {}, but that suggestion was dismissed", id, dep.id, dep.version);
}
break;
case ModMetadata::Dependency::Importance::Recommended:
Expand All @@ -546,10 +545,10 @@ void Loader::Impl::findProblems() {
mod,
fmt::format("{} {}", dep.id, dep.version.toString())
});
log::warn("{} recommends {} {}", id, dep.id, dep.version);
log::info("{} recommends {} {}", id, dep.id, dep.version);
}
else {
log::warn("{} recommends {} {}, but that suggestion was dismissed", id, dep.id, dep.version);
log::debug("{} recommends {} {}, but that suggestion was dismissed", id, dep.id, dep.version);
}
break;
case ModMetadata::Dependency::Importance::Required:
Expand Down Expand Up @@ -648,7 +647,6 @@ void Loader::Impl::findProblems() {
}

void Loader::Impl::refreshModGraph() {
log::info("Refreshing mod graph");
log::NestScope nest;

if (m_isSetup) {
Expand All @@ -661,52 +659,54 @@ void Loader::Impl::refreshModGraph() {
m_problems.clear();

m_loadingState = LoadingState::Queue;
log::debug("Queueing mods");
log::info("Queueing mods");
std::vector<ModMetadata> modQueue;
{
log::NestScope nest;
this->queueMods(modQueue);
}

m_loadingState = LoadingState::List;
log::debug("Populating mod list");
log::info("Populating mod list");
{
log::NestScope nest;
this->populateModList(modQueue);
modQueue.clear();
}

m_loadingState = LoadingState::Graph;
log::debug("Building mod graph");
log::info("Building mod graph");
{
log::NestScope nest;
this->buildModGraph();
}

log::debug("Ordering mod stack");
log::info("Ordering mod stack");
{
log::NestScope nest;
this->orderModStack();
}

m_loadingState = LoadingState::EarlyMods;
log::debug("Loading early mods");
log::info("Loading early mods");
{
log::NestScope nest;
while (!m_modsToLoad.empty() && m_modsToLoad.front()->needsEarlyLoad()) {
auto mod = m_modsToLoad.front();
m_modsToLoad.pop_front();
log::info("Loading mod {} {}", mod->getID(), mod->getVersion());
this->loadModGraph(mod, true);
}
}

auto end = std::chrono::high_resolution_clock::now();
auto time = std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count();
log::info("Took {}s. Continuing next frame...", static_cast<float>(time) / 1000.f);
log::debug("Took {}s. Continuing next frame...", static_cast<float>(time) / 1000.f);

m_loadingState = LoadingState::Mods;

queueInMainThread([this]() {
log::info("Loading non-early mods");
this->continueRefreshModGraph();
});
}
Expand Down Expand Up @@ -769,10 +769,10 @@ void Loader::Impl::continueRefreshModGraph() {
if (m_lateRefreshedModCount > 0) {
auto end = std::chrono::high_resolution_clock::now();
auto time = std::chrono::duration_cast<std::chrono::milliseconds>(end - m_timerBegin).count();
log::info("Took {}s", static_cast<float>(time) / 1000.f);
log::debug("Took {}s", static_cast<float>(time) / 1000.f);
}

log::info("Continuing mod graph refresh...");
log::debug("Continuing mod graph refresh...");
log::NestScope nest;

m_timerBegin = std::chrono::high_resolution_clock::now();
Expand All @@ -782,14 +782,14 @@ void Loader::Impl::continueRefreshModGraph() {
if (!m_modsToLoad.empty()) {
auto mod = m_modsToLoad.front();
m_modsToLoad.pop_front();
log::debug("Loading mod {} {}", mod->getID(), mod->getVersion());
log::info("Loading mod {} {}", mod->getID(), mod->getVersion());
this->loadModGraph(mod, false);
break;
}
m_loadingState = LoadingState::Problems;
[[fallthrough]];
case LoadingState::Problems:
log::debug("Finding problems");
log::info("Finding problems");
{
log::NestScope nest;
this->findProblems();
Expand All @@ -798,7 +798,7 @@ void Loader::Impl::continueRefreshModGraph() {
{
auto end = std::chrono::high_resolution_clock::now();
auto time = std::chrono::duration_cast<std::chrono::milliseconds>(end - m_timerBegin).count();
log::info("Took {}s", static_cast<float>(time) / 1000.f);
log::debug("Took {}s", static_cast<float>(time) / 1000.f);
}
break;
default:
Expand Down
6 changes: 3 additions & 3 deletions loader/src/loader/updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,11 @@ void updater::downloadLoaderResources(bool useLatestRelease) {
}
}
if (useLatestRelease) {
log::debug("Loader version {} does not exist, trying to download latest resources", Loader::get()->getVersion().toVString());
log::info("Loader version {} does not exist, trying to download latest resources", Loader::get()->getVersion().toVString());
downloadLatestLoaderResources();
}
else {
log::debug("Loader version {} does not exist on GitHub, not downloading the resources", Loader::get()->getVersion().toVString());
log::warn("Loader version {} does not exist on GitHub, not downloading the resources", Loader::get()->getVersion().toVString());
ResourceDownloadEvent(UpdateFinished()).post();
}
return *response;
Expand Down Expand Up @@ -361,7 +361,7 @@ void updater::checkForLoaderUpdates() {
VersionInfo ver { 0, 0, 0 };
root.needs("tag_name").into(ver);

log::info("Latest version is {}", ver.toVString());
log::info("Latest Geode version is {}", ver.toVString());
Mod::get()->setSavedValue("latest-version-auto-update-check", ver.toVString());

// make sure release is newer
Expand Down

0 comments on commit 91e61ad

Please sign in to comment.