Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
fml::LogState Class Reference

#include <log_state.h>

Public Member Functions

 LogState ()
 
const zx::socket & socket () const
 
std::shared_ptr< const std::vector< std::string > > tags () const
 
fidl::ClientEnd<::fuchsia_logger::LogSink > TakeClientEnd ()
 
void SetTags (const std::initializer_list< std::string > &tags)
 

Static Public Member Functions

static LogStateDefault ()
 

Detailed Description

Definition at line 22 of file log_state.h.

Constructor & Destructor Documentation

◆ LogState()

fml::LogState::LogState ( )

Definition at line 27 of file log_state.cc.

27 {
28 // Get channel to log sink
29 auto client_end = component::Connect<fuchsia_logger::LogSink>();
30 ZX_ASSERT(client_end.is_ok());
31 fidl::SyncClient log_sink(std::move(*client_end));
32
33 // Attempts to create a kernel socket object should never fail.
34 zx::socket local, remote;
35 zx::socket::create(ZX_SOCKET_DATAGRAM, &local, &remote);
36 auto result = log_sink->ConnectStructured({{.socket = std::move(remote)}});
37 ZX_ASSERT_MSG(result.is_ok(), "%s",
38 result.error_value().FormatDescription().c_str());
39
40 // Wait for the first interest change to set the initial minimum logging
41 // level (should return quickly).
42 auto interest_result = log_sink->WaitForInterestChange();
43 ZX_ASSERT_MSG(interest_result.is_ok(), "%s",
44 interest_result.error_value().FormatDescription().c_str());
45 LogInterestListener::HandleInterestChange(interest_result->data());
46
47 socket_ = std::move(local);
48 client_end_ = log_sink.TakeClientEnd();
49}
static void HandleInterestChange(const fuchsia_diagnostics::Interest &interest)
GAsyncResult * result
int_closure create

Member Function Documentation

◆ Default()

LogState & fml::LogState::Default ( )
static

Definition at line 61 of file log_state.cc.

61 {
62 static LogState* instance = new LogState();
63 return *instance;
64}
VkInstance instance
Definition: main.cc:48

◆ SetTags()

void fml::LogState::SetTags ( const std::initializer_list< std::string > &  tags)

Definition at line 56 of file log_state.cc.

56 {
57 std::atomic_store(&tags_,
58 std::make_shared<const std::vector<std::string>>(tags));
59}
std::shared_ptr< const std::vector< std::string > > tags() const
Definition: log_state.h:31

◆ socket()

const zx::socket & fml::LogState::socket ( ) const
inline

Definition at line 28 of file log_state.h.

28{ return socket_; }

◆ tags()

std::shared_ptr< const std::vector< std::string > > fml::LogState::tags ( ) const
inline

Definition at line 31 of file log_state.h.

31 {
32 return std::atomic_load(&tags_);
33 }

◆ TakeClientEnd()

fidl::ClientEnd<::fuchsia_logger::LogSink > fml::LogState::TakeClientEnd ( )

Definition at line 51 of file log_state.cc.

51 {
52 std::lock_guard lock(mutex_);
53 return std::move(client_end_);
54}

The documentation for this class was generated from the following files: