SkyWay Linux SDK
読み取り中…
検索中…
一致する文字列を見つけられません
logger.hpp
1#ifndef SKYWAY_GLOBAL_LOGGER_HPP
2#define SKYWAY_GLOBAL_LOGGER_HPP
3
4#include <mutex>
5
6#include <rtc_base/logging.h>
7
8#include <skyway/global/interface/logger.hpp>
9
11
12namespace skyway {
13namespace global {
14
16class Logger : public interface::Logger, public rtc::LogSink {
17public:
22 class Listener {
23 public:
24 virtual ~Listener() = default;
29 virtual void OnLog(domain::LogLevel level, const std::string& text) = 0;
30 };
31
33
36 Logger(domain::LogLevel level = domain::LogLevel::kInfo, bool enable_webrtc_log = false);
37 Logger(Level level, bool enable_webrtc_log = false);
38 ~Logger();
39
42 void Log(Level level,
43 const std::string& message,
44 const std::string& filename = "",
45 const std::string& function = "",
46 int line = -1);
47
50 void Trace(const std::string& message,
51 const std::string& filename = __builtin_FILE(),
52 const std::string& function = __builtin_FUNCTION(),
53 int line = __builtin_LINE()) override;
56 void Debug(const std::string& message,
57 const std::string& filename = __builtin_FILE(),
58 const std::string& function = __builtin_FUNCTION(),
59 int line = __builtin_LINE()) override;
62 void Info(const std::string& message,
63 const std::string& filename = __builtin_FILE(),
64 const std::string& function = __builtin_FUNCTION(),
65 int line = __builtin_LINE()) override;
68 void Warn(const std::string& message,
69 const std::string& filename = __builtin_FILE(),
70 const std::string& function = __builtin_FUNCTION(),
71 int line = __builtin_LINE()) override;
74 void Error(const std::string& message,
75 const std::string& filename = __builtin_FILE(),
76 const std::string& function = __builtin_FUNCTION(),
77 int line = __builtin_LINE()) override;
78
81 void OnLogMessage(const std::string& message) override;
82
85 void OnLogMessage(const std::string& message, rtc::LoggingSeverity severity) override;
86
88
92 static void RegisterListener(const std::shared_ptr<Listener> listener);
93
95 static void UnregisterListener();
96
97private:
98 void SetLogLevel(Level level);
99 Level WebRTCSeverityToLogLevel(rtc::LoggingSeverity severity);
100 static Level ToCoreLevel(domain::LogLevel level);
101 static domain::LogLevel ToLogLevel(Level level);
102 bool enable_webrtc_log_ = false;
103 Level level_ = kInfo;
104 inline static std::mutex listener_mtx_;
105 inline static std::shared_ptr<Listener> listener_ = nullptr;
106};
107
108} // namespace global
109} // namespace skyway
110
111#endif /* SKYWAY_GLOBAL_LOGGER_HPP */
Logger のリスナー
Definition logger.hpp:22
virtual void OnLog(domain::LogLevel level, const std::string &text)=0
SkyWayのログが出力されたときのイベント
SkyWayのログを出力するクラス
Definition logger.hpp:16
static void UnregisterListener()
登録済みのロガーのリスナーを消去します。
static void RegisterListener(const std::shared_ptr< Listener > listener)
ロガーのリスナーを登録します。
SkyWay全体で使用される列挙型や定数を定義するヘッダーファイル
LogLevel
ログレベル
Definition domain.hpp:25