Index

zydeco / 5a717fe

Experiment in graphics programming, C++, OpenGL, simulation techniques.

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
703 Sep 2023 16:015f524c5OpenGL render abstractionsJosh Stockin120G

Blob @ zydeco / include / Logger.hpp

text/plain1012 bytesdownload raw
1#ifndef LOGGER_HPP_
2#define LOGGER_HPP_
3
4
5#include <ostream>
6#include <string>
7#include <mutex>
8#include <fmt/format.h>
9
10
11class Logger
12{
13public:
14 Logger(std::string logger_name);
15 ~Logger() = default;
16
17 enum Verbosity
18 {
19 DISABLED,
20 ERROR,
21 WARNING,
22 INFO,
23 DEBUG,
24 VERBOSE,
25 TRACE,
26 };
27
28 static void InitializeLogging(Verbosity max_verbosity, std::ostream *ostream);
29
30 void Log(Verbosity verbosity, std::string message);
31
32 template<typename... Args>
33 void Log(Verbosity verbosity, fmt::format_string<Args...> message, Args&&... args)
34 {
35 Log(verbosity, fmt::vformat(message, fmt::make_format_args(args...)));
36 }
37
38protected:
39 static std::ostream *s_ostream;
40 static Verbosity s_maxVerbosity;
41 static int s_loggerNameLongestLen;
42 static std::mutex s_outputMutex;
43
44 std::string m_loggerName;
45 std::string m_leftPadding;
46 int m_loggerNameLen;
47 int m_loggerNameLongestLen;
48};
49
50
51#endif /* LOGGER_HPP_ */
52