diff --git a/src/Logger/Logger.cpp b/src/Logger/Logger.cpp index f2e47ac..1a0a6da 100644 --- a/src/Logger/Logger.cpp +++ b/src/Logger/Logger.cpp @@ -24,6 +24,8 @@ #include #include +#include + #include "Logger.h" using Containers::Array; @@ -31,12 +33,16 @@ using Utility::Debug; using Utility::Warning; using Utility::Error; +using namespace Magnum; + namespace MassBuilderSaveTool { namespace Logger { #ifndef SAVETOOL_DEBUG_BUILD static std::ofstream log_file{"SaveToolLog.txt", std::ios::trunc}; #endif +static UnsignedInt _indentLevel = 0; + static std::mutex _logMutex; static Array _entries; @@ -70,6 +76,10 @@ operator<<(Debug& out, const LogEntry& entry) { #undef DEBUG_COLOUR + for(UnsignedInt i = 0; i < _indentLevel; i++) { + out << Debug::nospace << " "_s << Debug::nospace; + } + out << entry.message << Debug::resetColor; return out; @@ -80,6 +90,18 @@ initialise() { arrayReserve(_entries, 100); } +void +indent() { + _indentLevel++; +} + +void +unindent() { + if(_indentLevel > 0) { + _indentLevel--; + } +} + void addEntry(EntryType type, StringView message) { auto time = std::time(nullptr); diff --git a/src/Logger/Logger.h b/src/Logger/Logger.h index d24dc6c..80ce9f6 100644 --- a/src/Logger/Logger.h +++ b/src/Logger/Logger.h @@ -44,14 +44,15 @@ struct LogEntry { void initialise(); +void indent(); +void unindent(); + void addEntry(EntryType type, StringView message); auto entries() -> ArrayView; void lockMutex(); - void unlockMutex(); - bool tryLockMutex(); } // Logger