SkyWay Linux SDK
読み取り中…
検索中…
一致する文字列を見つけられません
logger_observer.hpp
1//
2// © NTT DOCOMO BUSINESS, Inc. All Rights Reserved.
3//
4
5#ifndef SKYWAY_GLOBAL_REMOTE_LOGGER_HPP
6#define SKYWAY_GLOBAL_REMOTE_LOGGER_HPP
7
8#include <future>
9
10#include "skyway/analytics/client_event.hpp"
11#include "skyway/global/interface/logger.hpp"
12#include "skyway/global/interface/logger_observer.hpp"
13
14namespace skyway {
15namespace global {
16
18public:
20
21 ~LoggerObserver() override;
22
23 void StopSendingLogs();
24
25 void OnLog(const std::string& log_level,
26 const std::string& message,
27 const std::string& filename,
28 const std::string& function,
29 int line) override;
30
31 void OnLogs(std::vector<SdkLog> sdkLogs) override;
32
33 virtual std::future<bool> SendSDKLogAsync(const analytics::SDKLogsPayload& payload) = 0;
34
35private:
36 static constexpr size_t kMaxBufferSize = 50;
37 static constexpr int kFlushIntervalSeconds = 5;
38 std::string BuildLogMessage(const std::string& level,
39 const std::string& message,
40 const std::string& filename,
41 const std::string& function,
42 int line);
43
44 void FlushLoop();
45 void SendSdkLogs();
46
47 std::vector<analytics::SDKLogsPayload::SDKLog> buffer_;
48 std::mutex buffer_mtx_;
49 std::condition_variable cv_;
50 std::thread flush_thread_;
51 std::atomic<bool> stop_thread_ = false;
52 std::atomic<bool> is_sending_thread_stopped_ = false;
53};
54} // namespace global
55} // namespace skyway
56
57#endif // SKYWAY_GLOBAL_REMOTE_LOGGER_HPP
Definition logger_observer.hpp:17
Definition logger_observer.hpp:12