#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 . #include #include #include 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 indent(); void unindent(); void addEntry(EntryType type, StringView message); auto entries() -> ArrayView; 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();