3 #include <condition_variable> 8 #include "Mountain/core.hpp" 16 #define DEBUG_LOG(message, ...) Mountain::Logger::LogDebug(message, __FILE__, __LINE__, __VA_ARGS__) 90 std::chrono::system_clock::time_point time;
92 bool_t printToConsole, printToFile;
97 bool_t sameAsPrevious =
false;
99 std::shared_ptr<LogEntry> previousLog =
nullptr;
101 MOUNTAIN_API LogEntry();
103 MOUNTAIN_API LogEntry(std::string&& message,
LogLevel level);
105 MOUNTAIN_API LogEntry(std::string&& message,
LogLevel level,
const std::string& file, int32_t line);
107 MOUNTAIN_API LogEntry(std::string&& message,
LogLevel level, std::chrono::system_clock::time_point timePoint);
109 MOUNTAIN_API LogEntry(std::string&& message,
LogLevel level, std::chrono::system_clock::duration duration);
111 MOUNTAIN_API bool_t
operator==(
const LogEntry& other)
const;
115 MOUNTAIN_API
static inline std::vector<std::shared_ptr<LogEntry>> m_Logs;
141 template <Concepts::FormattableT... Args>
142 static void Log(
LogLevel level,
const std::string& format, Args&&... args);
150 template <Concepts::FormattableT... Args>
151 static void LogDebug(
const std::string& format,
const char_t* file, int32_t line, Args&&... args);
156 template <Concepts::FormattableT... Args>
157 static void LogVerbose(
const std::string& format, Args&&... args);
162 template <Concepts::FormattableT... Args>
163 static void LogInfo(
const std::string& format, Args&&... args);
168 template <Concepts::FormattableT... Args>
169 static void LogWarning(
const std::string& format, Args&&... args);
174 template <Concepts::FormattableT... Args>
175 static void LogError(
const std::string& format, Args&&... args);
180 template <Concepts::FormattableT... Args>
181 static void LogFatal(
const std::string& format, Args&&... args);
188 MOUNTAIN_API
static void OpenFile(
const std::filesystem::path& filepath);
213 MOUNTAIN_API
static void Start();
221 MOUNTAIN_API
static void Stop();
223 MOUNTAIN_API
static const decltype(m_Logs)& GetLogList();
225 MOUNTAIN_API
static void Clear();
230 MOUNTAIN_API
static inline std::shared_ptr<LogEntry> m_LastLog;
232 MOUNTAIN_API
static inline bool_t m_LastLogCollapsed =
false;
234 MOUNTAIN_API
static inline std::condition_variable m_CondVar;
236 MOUNTAIN_API
static void Run();
238 MOUNTAIN_API
static inline std::thread m_Thread;
240 MOUNTAIN_API
static inline std::mutex m_Mutex;
242 MOUNTAIN_API
static inline bool_t m_Running =
false;
244 MOUNTAIN_API
static inline bool_t m_Synchronizing =
false;
246 MOUNTAIN_API
static inline std::ofstream m_File;
248 MOUNTAIN_API
static inline std::filesystem::path m_Filepath;
250 MOUNTAIN_API
static inline uint32_t m_LogIndex = 0;
252 MOUNTAIN_API
static void PushLog(
const std::shared_ptr<LogEntry>& log);
255 MOUNTAIN_API
static void PrintLog(
const std::shared_ptr<LogEntry>& log);
258 MOUNTAIN_API
static std::pair<std::string, const char_t*> BuildLogPrefix(
const std::shared_ptr<LogEntry>& log);
262 #include "Mountain/utils/logger.inl" LogLevel
Describes the severity of a log.
static void Log(LogLevel level, const std::string &format, Args &&... args)
Logs a message using the specified format string, arguments and LogLevel.
Log intended for general information.
Defines the Mountain::TsQueue class.
Log intended for debugging only.
constexpr bool_t operator==(const Color &c1, const Color &c2)
Compares 2 Color component-wise.
static MOUNTAIN_API void Start()
Starts the logger.
static void LogWarning(const std::string &format, Args &&... args)
Logs a warning message using the specified format string and arguments.
static MOUNTAIN_API LogLevel minimumFileLevel
The minimum necessary LogLevel for a log to be printed in the log file.
static void LogVerbose(const std::string &format, Args &&... args)
Logs a debug message using the specified format string and arguments.
static MOUNTAIN_API void OpenFile(const std::filesystem::path &filepath)
Opens a file for logging.
Log intended for fatal errors.
static MOUNTAIN_API void OpenDefaultFile()
Opens the default log file.
static MOUNTAIN_API void Stop()
Synchronizes the threads and stops the logger.
Static class used to log messages to the console and/or a file.
static void LogFatal(const std::string &format, Args &&... args)
Logs a fatal error message using the specified format string and arguments.
static void LogError(const std::string &format, Args &&... args)
Logs an error message using the specified format string and arguments.
static void LogInfo(const std::string &format, Args &&... args)
Logs an information message using the specified format string and arguments.
static MOUNTAIN_API void Synchronize()
Synchronizes the calling thread with the logger one, and makes sure all logs have been printed before...
Defines the Mountain::Concepts namespace which contains useful concepts used in the engine...
Log intended for warnings.
static MOUNTAIN_API bool HasFileOpen()
Returns whether the logger is already log to a file.
static MOUNTAIN_API void CloseFile()
Closes the current log file.
Log intended for temporary debugging only.
static void LogDebug(const std::string &format, const char_t *file, int32_t line, Args &&... args)
Logs a temporary debug message using the current file, line, specified format string and arguments...
static MOUNTAIN_API LogLevel minimumConsoleLevel
The minimum necessary LogLevel for a log to be printed in the console.
Contains all declarations of the Mountain Framework.