12 #include "../util/active.h"
42 #define YAGE_ERROR_TMP ERROR
52 #define ERROR YAGE_ERROR_TMP
86 std::ostringstream buffer_;
112 virtual ~Concept() =
default;
114 virtual Concept *clone()
const = 0;
116 std::string
const &msg)
const = 0;
119 template <
typename T>
120 struct Model : Concept {
122 virtual Concept *clone()
const override;
124 std::string
const &msg)
const override;
129 std::unique_ptr<Concept> wrapper_;
136 explicit Logger(std::string
const &file_path);
141 std::string
const &fileName =
"",
int lineNum = -1);
145 void remove(
LogSink const &sink);
154 std::vector<LogSink> sinks_;
155 std::unique_ptr<Active> active_;
169 template <
typename T>
174 template <
typename T>
175 LogSink::Model<T>::Model(T impl_i) : impl(impl_i)
179 template <
typename T>
180 LogSink::Concept *LogSink::Model<T>::clone()
const
182 return new Model<T>(impl);
185 template <
typename T>
186 void LogSink::Model<T>::write(LogMessage::Meta
const &meta,
187 std::string
const &msg)
const
192 template <
typename T>
201 #define yLogger (yage::Logger::instance())
204 (yage::Logger::instance()(yage::LogLevel::DEBUG, __FILE__, __LINE__))
207 (yage::Logger::instance()(yage::LogLevel::INFO, __FILE__, __LINE__))
209 #define yLogWarning \
210 (yage::Logger::instance()(yage::LogLevel::WARNING, __FILE__, __LINE__))
213 (yage::Logger::instance()(yage::LogLevel::ERROR, __FILE__, __LINE__))
216 (yage::Logger::instance()(yage::LogLevel::FATAL, __FILE__, __LINE__))
LogMessage & operator=(LogMessage const &msg)=delete
LogMessage(LogMessage const &msg)=delete
bool operator==(LogSink const &sink)
Fatal message that should be output when the game crashes.
LogLevel
Different log levels that can be assigned to each message sent to the Logger.
Definition: logger.h:29
LogSink & operator=(LogSink const &sink)
void add(LogSink const &sink)
Definition: logger.cpp:208
void flush(LogMessage const *msg)
Definition: logger.cpp:192
void setLevel(LogLevel min_level)
Definition: logger.cpp:234
void clear()
Definition: logger.cpp:222
LogSink makeConsoleSink()
LogSink(T impl)
Definition: logger.h:170
void write(LogMessage::Meta const &meta, std::string const &msg) const
LogSink makeFileSink(std::string const &filename)
static Logger & instance()
Definition: logger.cpp:227
LogMessage & operator<<(T const &value)
Definition: logger.h:193
Lowest log level. This is used by the game engine to output debugging information but is turned off i...
LogMessage operator()(LogLevel level=LogLevel::INFO, std::string const &fileName="", int lineNum=-1)
Definition: logger.cpp:186