WIP: The Road to 1.4 #23
2 changed files with 25 additions and 2 deletions
|
@ -24,6 +24,8 @@
|
|||
#include <Corrade/Containers/GrowableArray.h>
|
||||
#include <Corrade/Utility/Debug.h>
|
||||
|
||||
#include <Magnum/Types.h>
|
||||
|
||||
#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<LogEntry> _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);
|
||||
|
|
|
@ -44,14 +44,15 @@ struct LogEntry {
|
|||
|
||||
void initialise();
|
||||
|
||||
void indent();
|
||||
void unindent();
|
||||
|
||||
void addEntry(EntryType type, StringView message);
|
||||
|
||||
auto entries() -> ArrayView<const LogEntry>;
|
||||
|
||||
void lockMutex();
|
||||
|
||||
void unlockMutex();
|
||||
|
||||
bool tryLockMutex();
|
||||
|
||||
} // Logger
|
||||
|
|
Loading…
Reference in a new issue