73 lines
2.4 KiB
C++
73 lines
2.4 KiB
C++
#pragma once
|
|
|
|
// MassBuilderSaveTool
|
|
// Copyright (C) 2021-2022 Guillaume Jacquemin
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
#include <ctime>
|
|
|
|
#include <Corrade/Containers/String.h>
|
|
#include <Corrade/Containers/ArrayView.h>
|
|
|
|
using namespace Corrade;
|
|
|
|
using Containers::ArrayView;
|
|
using Containers::String;
|
|
using Containers::StringView;
|
|
|
|
namespace MassBuilderSaveTool { namespace Logger {
|
|
|
|
enum class EntryType {
|
|
Info,
|
|
Success,
|
|
Warning,
|
|
Error,
|
|
};
|
|
|
|
struct LogEntry {
|
|
String timestamp;
|
|
EntryType type;
|
|
String message;
|
|
};
|
|
|
|
void initialise();
|
|
|
|
void addEntry(EntryType type, StringView message);
|
|
|
|
auto entries() -> ArrayView<const LogEntry>;
|
|
|
|
void lockMutex();
|
|
|
|
void unlockMutex();
|
|
|
|
bool tryLockMutex();
|
|
|
|
} // Logger
|
|
|
|
} // MassBuilderSaveTool
|
|
|
|
#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();
|