Lugdunum  0.1.0
Logger.inl
Go to the documentation of this file.
1 template<typename T>
2 inline void Logger::log(Level lvl, const T& msg) {
3  try {
4  priv::Message logMsg(_name, lvl);
5  logMsg.raw.write("{}", msg);
6  handle(logMsg);
7  } catch (const std::exception& ex) {
8  defaultErrHandler(ex);
9  }
10 }
11 
12 template<typename... Args, typename T>
13 inline void Logger::log(Level lvl, const T& fmt, Args&&... args) {
14  try {
15  priv::Message logMsg(_name, lvl);
16  logMsg.raw.write(fmt, std::forward<Args>(args)...);
17  handle(logMsg);
18  } catch (const std::exception& ex) {
19  defaultErrHandler(ex);
20  }
21 }
22 
23 template<typename T, typename... Args>
24 inline void Logger::debug(const T& fmt, Args&&... args) {
25  log(Level::Debug, fmt, std::forward<Args>(args)...);
26 }
27 
28 template<typename T, typename... Args>
29 inline void Logger::info(const T& fmt, Args&&... args) {
30  log(Level::Info, fmt, std::forward<Args>(args)...);
31 }
32 
33 template<typename T, typename... Args>
34 inline void Logger::warn(const T& fmt, Args&&... args) {
35  log(Level::Warning, fmt, std::forward<Args>(args)...);
36 }
37 
38 template<typename T, typename... Args>
39 inline void Logger::error(const T& fmt, Args&&... args) {
40  log(Level::Error, fmt, std::forward<Args>(args)...);
41 }
42 
43 template<typename T, typename... Args>
44 inline void Logger::fatal(const T& fmt, Args&&... args) {
45  log(Level::Fatal, fmt, std::forward<Args>(args)...);
46 }
47 
48 template<typename T, typename... Args>
49 inline void Logger::assrt(const T& fmt, Args&&... args) {
50  log(Level::Assert, fmt, std::forward<Args>(args)...);
51 }
52 
53 
54 inline Logger* makeLogger(const std::string& loggerName) {
55  std::unique_ptr<Logger> logger = std::make_unique<Logger>(loggerName);
56  Logger* loggerRawPtr = logger.get();
57  LoggingFacility::registerLogger(loggerName, std::move(logger));
58  return loggerRawPtr;
59 }
Logger * makeLogger(const std::string &loggerName)
Definition: Logger.inl:54