hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
logger_spdlog.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_LOGGER_SPDLOG_HPP
7 #define IROHA_LOGGER_SPDLOG_HPP
8 
9 #include "logger/logger.hpp"
10 
11 #include <map>
12 #include <memory>
13 #include <string>
14 
15 namespace spdlog {
16  class logger;
17 }
18 
19 namespace logger {
20 
21  class LogPatterns;
22  struct LoggerConfig;
23 
24  using ConstLoggerConfigPtr = std::shared_ptr<const LoggerConfig>;
25 
27 
29  class LogPatterns {
30  public:
32  void setPattern(LogLevel level, std::string pattern);
33 
39  std::string getPattern(LogLevel level) const;
40 
42  LogPatterns &inherit(const LogPatterns &base);
43 
44  private:
45  std::map<LogLevel, std::string> patterns_;
46  };
47 
48  // TODO mboldyrev 29.12.2018 IR-188 Add sink options (console, file, syslog)
49  struct LoggerConfig {
52  };
53 
54  class LoggerSpdlog : public Logger {
55  public:
60  LoggerSpdlog(std::string tag, ConstLoggerConfigPtr config);
61 
62  private:
63  void logInternal(Level level, const std::string &s) const override;
64 
67  bool shouldLog(Level level) const override;
68 
70  void setupLogger();
71 
72  const std::string tag_;
73  const ConstLoggerConfigPtr config_;
74  const std::shared_ptr<spdlog::logger> logger_;
75  };
76 
77 } // namespace logger
78 
79 #endif // IROHA_LOGGER_SPDLOG_HPP
LogLevel log_level
Definition: logger_spdlog.hpp:50
LogPatterns getDefaultLogPatterns()
Definition: logger_spdlog.cpp:55
std::shared_ptr< const LoggerConfig > ConstLoggerConfigPtr
Definition: logger_spdlog.hpp:24
Definition: grpc_response_handler.hpp:14
Definition: logger_spdlog.hpp:54
Patterns for logging depending on the log level.
Definition: logger_spdlog.hpp:29
Definition: dummy_logger.hpp:11
Definition: logger.hpp:45
LogPatterns patterns
Definition: logger_spdlog.hpp:51
Definition: logger_spdlog.hpp:49
LogLevel
Log levels.
Definition: logger.hpp:36