Logger: move away from the MassBuilderSaveTool namespace.
Might be useful if I ever use it in another project.
This commit is contained in:
parent
45c1cc2f9e
commit
65bb0d82a9
2 changed files with 27 additions and 25 deletions
|
@ -35,7 +35,7 @@ using Utility::Error;
|
||||||
|
|
||||||
using namespace Magnum;
|
using namespace Magnum;
|
||||||
|
|
||||||
namespace MassBuilderSaveTool { namespace Logger {
|
namespace Logger {
|
||||||
|
|
||||||
#ifndef SAVETOOL_DEBUG_BUILD
|
#ifndef SAVETOOL_DEBUG_BUILD
|
||||||
static std::ofstream log_file{"SaveToolLog.txt", std::ios::trunc};
|
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;
|
out << "["_s << Debug::nospace << entry.timestamp << Debug::nospace << "]"_s;
|
||||||
|
|
||||||
#ifdef SAVETOOL_DEBUG_BUILD
|
#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
|
#else
|
||||||
#define COLOUR(col)
|
#define COLOURED_TEXT(colour, text) (text)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch(entry.type) {
|
switch(entry.type) {
|
||||||
case EntryType::Info:
|
case EntryType::Info:
|
||||||
out << "[INFO]"_s COLOUR(Default);
|
out << COLOURED_TEXT(Default, "[INFO]"_s);
|
||||||
break;
|
break;
|
||||||
case EntryType::Success:
|
case EntryType::Success:
|
||||||
out << "[SUCCESS]"_s COLOUR(Green);
|
out << COLOURED_TEXT(Green, "[SUCCESS]"_s);
|
||||||
break;
|
break;
|
||||||
case EntryType::Warning:
|
case EntryType::Warning:
|
||||||
out << "[WARNING]"_s COLOUR(Yellow);
|
out << COLOURED_TEXT(Yellow, "[WARNING]"_s);
|
||||||
break;
|
break;
|
||||||
case EntryType::Error:
|
case EntryType::Error:
|
||||||
out << "[ERROR]"_s COLOUR(Red);
|
out << COLOURED_TEXT(Red, "[ERROR]"_s);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef DEBUG_COLOUR
|
#undef COLOURED_TEXT
|
||||||
|
|
||||||
for(UnsignedInt i = 0; i < _indentLevel; i++) {
|
for(UnsignedInt i = 0; i < _indentLevel; i++) {
|
||||||
out << Debug::nospace << " "_s << Debug::nospace;
|
out << Debug::nospace << " "_s << Debug::nospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
out << entry.message << Debug::resetColor;
|
out << entry.message;
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -149,5 +149,3 @@ tryLockMutex() {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Logger
|
} // Logger
|
||||||
|
|
||||||
} // MassBuilderSaveTool
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include <Corrade/Containers/String.h>
|
#include <Corrade/Containers/String.h>
|
||||||
#include <Corrade/Containers/ArrayView.h>
|
#include <Corrade/Containers/ArrayView.h>
|
||||||
|
#include <Corrade/Utility/Format.h>
|
||||||
|
|
||||||
using namespace Corrade;
|
using namespace Corrade;
|
||||||
|
|
||||||
|
@ -27,7 +28,7 @@ using Containers::ArrayView;
|
||||||
using Containers::String;
|
using Containers::String;
|
||||||
using Containers::StringView;
|
using Containers::StringView;
|
||||||
|
|
||||||
namespace MassBuilderSaveTool { namespace Logger {
|
namespace Logger {
|
||||||
|
|
||||||
enum class EntryType {
|
enum class EntryType {
|
||||||
Info,
|
Info,
|
||||||
|
@ -57,17 +58,20 @@ bool tryLockMutex();
|
||||||
|
|
||||||
} // Logger
|
} // 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(); \
|
#define LOG_INFO_FORMAT(message, ...) LOG_INFO(Utility::format(message, __VA_ARGS__))
|
||||||
MassBuilderSaveTool::Logger::addEntry(MassBuilderSaveTool::Logger::EntryType::Info, message); \
|
#define LOG_SUCCESS_FORMAT(message, ...) LOG_SUCCESS(Utility::format(message, __VA_ARGS__))
|
||||||
MassBuilderSaveTool::Logger::unlockMutex()
|
#define LOG_WARNING_FORMAT(message, ...) LOG_WARNING(Utility::format(message, __VA_ARGS__))
|
||||||
#define LOG_SUCCESS(message) MassBuilderSaveTool::Logger::lockMutex(); \
|
#define LOG_ERROR_FORMAT(message, ...) LOG_ERROR(Utility::format(message, __VA_ARGS__))
|
||||||
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()
|
|
||||||
|
|
Loading…
Reference in a new issue