Flutter Engine
The Flutter Engine
log_state.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_FML_PLATFORM_FUCHSIA_LOG_STATE_H_
6#define FLUTTER_FML_PLATFORM_FUCHSIA_LOG_STATE_H_
7
8#include <fidl/fuchsia.logger/cpp/fidl.h>
9#include <lib/fidl/cpp/wire/internal/transport_channel.h>
10#include <lib/zx/socket.h>
11
12#include <atomic>
13#include <initializer_list>
14#include <memory>
15#include <mutex>
16#include <string>
17#include <vector>
18
19namespace fml {
20
21// Class for holding the global connection to the Fuchsia LogSink service.
22class LogState {
23 public:
24 // Connects to the Fuchsia LogSink service.
25 LogState();
26
27 // Get the socket for sending log messages.
28 const zx::socket& socket() const { return socket_; }
29
30 // Get the current list of tags.
31 std::shared_ptr<const std::vector<std::string>> tags() const {
32 return std::atomic_load(&tags_);
33 }
34
35 // Take ownership of the log sink channel (e.g. for LogInterestListener).
36 // This is thread-safe.
37 fidl::ClientEnd<::fuchsia_logger::LogSink> TakeClientEnd();
38
39 // Updates the default tags.
40 // This is thread-safe.
41 void SetTags(const std::initializer_list<std::string>& tags);
42
43 // Get the default instance of LogState.
44 static LogState& Default();
45
46 private:
47 std::mutex mutex_;
48 fidl::ClientEnd<::fuchsia_logger::LogSink> client_end_;
49 zx::socket socket_;
50 std::shared_ptr<const std::vector<std::string>> tags_;
51};
52
53} // namespace fml
54
55#endif // FLUTTER_FML_PLATFORM_FUCHSIA_LOG_STATE_H_
void SetTags(const std::initializer_list< std::string > &tags)
Definition: log_state.cc:56
static LogState & Default()
Definition: log_state.cc:61
const zx::socket & socket() const
Definition: log_state.h:28
std::shared_ptr< const std::vector< std::string > > tags() const
Definition: log_state.h:31
fidl::ClientEnd<::fuchsia_logger::LogSink > TakeClientEnd()
Definition: log_state.cc:51
Definition: ascii_trie.cc:9