WIP: The Road to 1.4 #23
2 changed files with 27 additions and 25 deletions
|
@ -35,7 +35,7 @@ using Utility::Error;
|
|||
|
||||
using namespace Magnum;
|
||||
|
||||
namespace MassBuilderSaveTool { namespace Logger {
|
||||
namespace Logger {
|
||||
|
||||
#ifndef SAVETOOL_DEBUG_BUILD
|
||||
static std::ofstream log_file{"SaveToolLog.txt", std::ios::trunc};
|
||||
|
@ -54,33 +54,33 @@ operator<<(Debug& out, const LogEntry& entry) {
|
|||
out << "["_s << Debug::nospace << entry.timestamp << Debug::nospace << "]"_s;
|
||||
|
||||
#ifdef SAVETOOL_DEBUG_BUILD
|
||||
#define COLOUR(col) << Debug::color(Debug::Color::col)
|
||||
#define COLOURED_TEXT(colour, text) Debug::color(Debug::Color::colour) << (text) << Debug::resetColor
|
||||
#else
|
||||
#define COLOUR(col)
|
||||
#define COLOURED_TEXT(colour, text) (text)
|
||||
#endif
|
||||
|
||||
switch(entry.type) {
|
||||
case EntryType::Info:
|
||||
out << "[INFO]"_s COLOUR(Default);
|
||||
out << COLOURED_TEXT(Default, "[INFO]"_s);
|
||||
break;
|
||||
case EntryType::Success:
|
||||
out << "[SUCCESS]"_s COLOUR(Green);
|
||||
out << COLOURED_TEXT(Green, "[SUCCESS]"_s);
|
||||
break;
|
||||
case EntryType::Warning:
|
||||
out << "[WARNING]"_s COLOUR(Yellow);
|
||||
out << COLOURED_TEXT(Yellow, "[WARNING]"_s);
|
||||
break;
|
||||
case EntryType::Error:
|
||||
out << "[ERROR]"_s COLOUR(Red);
|
||||
out << COLOURED_TEXT(Red, "[ERROR]"_s);
|
||||
break;
|
||||
}
|
||||
|
||||
#undef DEBUG_COLOUR
|
||||
#undef COLOURED_TEXT
|
||||
|
||||
for(UnsignedInt i = 0; i < _indentLevel; i++) {
|
||||
out << Debug::nospace << " "_s << Debug::nospace;
|
||||
}
|
||||
|
||||
out << entry.message << Debug::resetColor;
|
||||
out << entry.message;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
@ -149,5 +149,3 @@ tryLockMutex() {
|
|||
}
|
||||
|
||||
} // Logger
|
||||
|
||||
} // MassBuilderSaveTool
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include <Corrade/Containers/String.h>
|
||||
#include <Corrade/Containers/ArrayView.h>
|
||||
#include <Corrade/Utility/Format.h>
|
||||
|
||||
using namespace Corrade;
|
||||
|
||||
|
@ -27,7 +28,7 @@ using Containers::ArrayView;
|
|||
using Containers::String;
|
||||
using Containers::StringView;
|
||||
|
||||
namespace MassBuilderSaveTool { namespace Logger {
|
||||
namespace Logger {
|
||||
|
||||
enum class EntryType {
|
||||
Info,
|
||||
|
@ -57,17 +58,20 @@ bool tryLockMutex();
|
|||
|
||||
} // Logger
|
||||
|
||||
} // MassBuilderSaveTool
|
||||
#define LOG_INFO(message) Logger::lockMutex(); \
|
||||
Logger::addEntry(Logger::EntryType::Info, message); \
|
||||
Logger::unlockMutex()
|
||||
#define LOG_SUCCESS(message) Logger::lockMutex(); \
|
||||
Logger::addEntry(Logger::EntryType::Success, message); \
|
||||
Logger::unlockMutex()
|
||||
#define LOG_WARNING(message) Logger::lockMutex(); \
|
||||
Logger::addEntry(Logger::EntryType::Warning, message); \
|
||||
Logger::unlockMutex()
|
||||
#define LOG_ERROR(message) Logger::lockMutex(); \
|
||||
Logger::addEntry(Logger::EntryType::Error, message); \
|
||||
Logger::unlockMutex()
|
||||
|
||||
#define LOG_INFO(message) MassBuilderSaveTool::Logger::lockMutex(); \
|
||||
MassBuilderSaveTool::Logger::addEntry(MassBuilderSaveTool::Logger::EntryType::Info, message); \
|
||||
MassBuilderSaveTool::Logger::unlockMutex()
|
||||
#define LOG_SUCCESS(message) MassBuilderSaveTool::Logger::lockMutex(); \
|
||||
MassBuilderSaveTool::Logger::addEntry(MassBuilderSaveTool::Logger::EntryType::Success, message); \
|
||||
MassBuilderSaveTool::Logger::unlockMutex()
|
||||
#define LOG_WARNING(message) MassBuilderSaveTool::Logger::lockMutex(); \
|
||||
MassBuilderSaveTool::Logger::addEntry(MassBuilderSaveTool::Logger::EntryType::Warning, message); \
|
||||
MassBuilderSaveTool::Logger::unlockMutex()
|
||||
#define LOG_ERROR(message) MassBuilderSaveTool::Logger::lockMutex(); \
|
||||
MassBuilderSaveTool::Logger::addEntry(MassBuilderSaveTool::Logger::EntryType::Error, message); \
|
||||
MassBuilderSaveTool::Logger::unlockMutex()
|
||||
#define LOG_INFO_FORMAT(message, ...) LOG_INFO(Utility::format(message, __VA_ARGS__))
|
||||
#define LOG_SUCCESS_FORMAT(message, ...) LOG_SUCCESS(Utility::format(message, __VA_ARGS__))
|
||||
#define LOG_WARNING_FORMAT(message, ...) LOG_WARNING(Utility::format(message, __VA_ARGS__))
|
||||
#define LOG_ERROR_FORMAT(message, ...) LOG_ERROR(Utility::format(message, __VA_ARGS__))
|
||||
|
|
Loading…
Reference in a new issue