asr_util_logger  1.0.0
Logger.h
[詳解]
1 #ifndef ASR_UTIL_LOGGER_H
2 #define ASR_UTIL_LOGGER_H
3 
4 #include <memory> // unique_ptr
5 #include <string>
6 
7 namespace asr
8 {
10 namespace util
11 {
12 namespace logger
13 {
14 struct ILogger;
15 } // namespace logger
16 
28 class Logger
29 {
30 public:
32  enum Level
33  {
34  VBS,
35  DBG,
36  INF,
37  WRN,
38  ERR,
39  FTL
40  };
41 
42 private:
43  std::unique_ptr<logger::ILogger> m_impl;
44 
45 public:
46  Logger() = delete;
47 
48  explicit Logger(std::unique_ptr<logger::ILogger>&& the_impl);
49 
52  void output(const Level the_log_level,
53  const std::string& the_file_name,
54  const int the_line_number,
55  const std::string& the_function_name,
56  const std::string& the_message);
57 };
58 
59 Logger& theLogger();
60 } // namespace util
61 } // namespace asr
62 
64 #define ASR_UTIL_LOGV(the_message) asr::util::theLogger().output(asr::util::Logger::VBS, __FILE__, __LINE__, __func__, the_message)
65 
67 #define ASR_UTIL_LOGD(the_message) asr::util::theLogger().output(asr::util::Logger::DBG, __FILE__, __LINE__, __func__, the_message)
68 
70 #define ASR_UTIL_LOGI(the_message) asr::util::theLogger().output(asr::util::Logger::INF, __FILE__, __LINE__, __func__, the_message)
71 
73 #define ASR_UTIL_LOGW(the_message) asr::util::theLogger().output(asr::util::Logger::WRN, __FILE__, __LINE__, __func__, the_message)
74 
76 #define ASR_UTIL_LOGE(the_message) asr::util::theLogger().output(asr::util::Logger::ERR, __FILE__, __LINE__, __func__, the_message)
77 
79 #define ASR_UTIL_LOGF(the_message) asr::util::theLogger().output(asr::util::Logger::FTL, __FILE__, __LINE__, __func__, the_message)
80 
81 #endif // ASR_UTIL_LOGGER_H
Level
ログレベル
Definition: Logger.h:32
std::unique_ptr< logger::ILogger > m_impl
Definition: Logger.h:43
デバッグ用途
Definition: Logger.h:35
処理は継続して良いが、後後のため通知するケース
Definition: Logger.h:37
詳細な調査用。プロダクションコードには残さないこと。
Definition: Logger.h:34
ログ出力
Definition: Logger.h:28
正常時、ユーザ or 運用担当者に通知したいケース
Definition: Logger.h:36
Logger & theLogger()
Definition: Logger.cpp:39
Definition: Config.h:11
異常発生時
Definition: Logger.h:38