Skip to content

Commit

Permalink
Cleaned up debug logging for better user experience :)
Browse files Browse the repository at this point in the history
  • Loading branch information
adya committed Jan 23, 2025
1 parent 6a98ede commit 01a064c
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 57 deletions.
7 changes: 6 additions & 1 deletion SPID/include/OutfitManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace Outfits
class Manager :
public ISingleton<Manager>,
public RE::BSTEventSink<RE::TESFormDeleteEvent>,
public RE::BSTEventSink<RE::TESDeathEvent>
public RE::BSTEventSink<RE::TESDeathEvent>,
public RE::BSTEventSink<RE::TESContainerChangedEvent>
{
public:
void HandleMessage(SKSE::MessagingInterface::Message*);
Expand Down Expand Up @@ -75,6 +76,10 @@ namespace Outfits
/// TESDeathEvent is used to update outfit after potential Death Distribution of a new outfit.
RE::BSEventNotifyControl ProcessEvent(const RE::TESDeathEvent*, RE::BSTEventSource<RE::TESDeathEvent>*) override;

// TODO: Delete this event once all issues with outfits are solved.
/// TESContainerChangedEvent is used to log when items are added/removed. For debugging only!
RE::BSEventNotifyControl ProcessEvent(const RE::TESContainerChangedEvent*, RE::BSTEventSource<RE::TESContainerChangedEvent>*) override;

private:
struct OutfitReplacement
{
Expand Down
12 changes: 6 additions & 6 deletions SPID/src/DeathDistribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ namespace DeathDistribution
static bool thunk(RE::Character* actor)
{
#ifndef NDEBUG
logger::info("Distribute: ShouldBackgroundClone({})", *(actor->As<RE::Actor>()));
//logger::info("Distribute: ShouldBackgroundClone({})", *(actor->As<RE::Actor>()));
#endif
if (const auto npc = actor->GetActorBase()) {
auto npcData = NPCData(actor, npc);
Expand All @@ -216,7 +216,7 @@ namespace DeathDistribution

static inline void post_hook()
{
logger::info("Death Distribution: Installed ShouldBackgroundClone hook.");
logger::info("\t\t🪝Installed ShouldBackgroundClone hook.");
}

static inline REL::Relocation<decltype(thunk)> func;
Expand All @@ -225,18 +225,18 @@ namespace DeathDistribution
void Manager::HandleMessage(SKSE::MessagingInterface::Message* message)
{
switch (message->type) {
case SKSE::MessagingInterface::kDataLoaded:
case SKSE::MessagingInterface::kPostLoad:
if (INI::deathConfigs.empty()) {
return;
}

logger::info("💀Death Distribution");
if (const auto scripts = RE::ScriptEventSourceHolder::GetSingleton()) {
scripts->PrependEventSink<RE::TESDeathEvent>(this);
logger::info("Death Distribution: Registered for {}.", typeid(RE::TESDeathEvent).name());
logger::info("\t\t📝Registered for {}.", typeid(RE::TESDeathEvent).name());
}

stl::install_hook<ShouldBackgroundClone>();

break;
default:
break;
Expand Down
12 changes: 8 additions & 4 deletions SPID/src/Distribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,14 @@ namespace Distribute
}

logger::info("Distribution for {}", *npcData.GetActor());
for (const auto& pair : results) {
logger::info("\t{}", pair.first);
for (const auto& form : pair.second) {
logger::info("\t\t{} @ {}", *form.first, form.second);
if (results.empty()) {
logger::info("\tNothing");
} else {
for (const auto& pair : results) {
logger::info("\t{}", pair.first);
for (const auto& form : pair.second) {
logger::info("\t\t{} @ {}", *form.first, form.second);
}
}
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion SPID/src/DistributeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace Distribute

static bool thunk(RE::Character* actor)
{
logger::debug("Distribute: ShouldBackgroundClone({})", *(actor->As<RE::Actor>()));
// logger::debug("Distribute: ShouldBackgroundClone({})", *(actor->As<RE::Actor>()));
if (const auto npc = actor->GetActorBase()) {
detail::distribute_on_load(actor, npc);
}
Expand Down
Loading

0 comments on commit 01a064c

Please sign in to comment.