Skip to content

Commit

Permalink
even more cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
matcool committed Dec 25, 2023
1 parent c57db81 commit b01db1f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 36 deletions.
19 changes: 1 addition & 18 deletions loader/include/Geode/loader/Log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,6 @@ namespace geode {
using log_clock = std::chrono::system_clock;
GEODE_DLL std::string generateLogName();

// template <class T>
// requires std::convertible_to<T*, cocos2d::CCNode*>
// std::string serialize(T* node) {
// return serialize(static_cast<cocos2d::CCNode*>(node));
// }
// template <class T>
// requires(
// std::convertible_to<T*, cocos2d::CCObject*> &&
// !std::convertible_to<T*, cocos2d::CCNode*>
// )
// std::string serialize(T* node) {
// return serialize(static_cast<cocos2d::CCObject*>(node));
// }

// Log

class GEODE_DLL Log final {
Expand All @@ -76,9 +62,6 @@ namespace geode {
public:
~Log();
Log(Severity sev, Mod* mod, std::string content);
Log(Log&& l) = default;
Log& operator=(Log&& l) = default;
// bool operator==(Log const& l) const;

std::string toString(bool logTime = true) const;
std::string toString(bool logTime, uint32_t nestLevel) const;
Expand Down Expand Up @@ -108,7 +91,7 @@ namespace geode {
static void pushNest();
static void popNest();

static std::vector<Log*> list();
static std::vector<Log> const& list();
static void clear();
};

Expand Down
24 changes: 8 additions & 16 deletions loader/src/loader/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ std::string cocos2d::format_as(cocos2d::ccColor4B const& col) {
// Log

void log::vlogImpl(Severity sev, Mod* mod, fmt::string_view format, fmt::format_args args) {
Log obj(sev, mod, fmt::vformat(format, args));

Logger::push(std::move(obj));
Logger::push(Log(
sev,
mod,
fmt::vformat(format, args)
));
}


Expand All @@ -101,12 +103,7 @@ Log::Log(Severity sev, Mod* mod, std::string content) :
m_severity(sev),
m_content(std::move(content)) {}

Log::~Log() {
}

// bool Log::operator==(Log const& l) {
// return this == &l;
// }
Log::~Log() {}

std::string Log::toString(bool logTime) const {
return toString(logTime, 0);
Expand Down Expand Up @@ -219,13 +216,8 @@ void Logger::popNest() {
nestLevel()--;
}

std::vector<Log*> Logger::list() {
std::vector<Log*> logs_;
logs_.reserve(logs().size());
for (auto& log : logs()) {
logs_.push_back(&log);
}
return logs_;
std::vector<Log> const& Logger::list() {
return logs();
}

void Logger::clear() {
Expand Down
2 changes: 1 addition & 1 deletion loader/src/platform/mac/LoaderImpl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
m_platformConsoleOpen = true;

for (auto const& log : log::Logger::list()) {
this->logConsoleMessageWithSeverity(log->toString(true), log->getSeverity());
this->logConsoleMessageWithSeverity(log.toString(true), log.getSeverity());
}
}

Expand Down
2 changes: 1 addition & 1 deletion loader/src/platform/windows/LoaderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void Loader::Impl::openPlatformConsole() {
m_platformConsoleOpen = true;

for (auto const& log : log::Logger::list()) {
this->logConsoleMessageWithSeverity(log->toString(true), log->getSeverity());
this->logConsoleMessageWithSeverity(log.toString(true), log.getSeverity());
}
}

Expand Down

0 comments on commit b01db1f

Please sign in to comment.