5#include "flutter/fml/platform/fuchsia/log_state.h"
7#include <fidl/fuchsia.logger/cpp/fidl.h>
8#include <lib/component/incoming/cpp/protocol.h>
9#include <lib/fidl/cpp/channel.h>
10#include <lib/fidl/cpp/wire/internal/transport_channel.h>
11#include <lib/zx/socket.h>
12#include <zircon/assert.h>
13#include <zircon/types.h>
16#include <initializer_list>
23#include "flutter/fml/platform/fuchsia/log_interest_listener.h"
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));
34 zx::socket
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());
42 auto interest_result = log_sink->WaitForInterestChange();
43 ZX_ASSERT_MSG(interest_result.is_ok(),
"%s",
44 interest_result.error_value().FormatDescription().c_str());
47 socket_ = std::move(
local);
48 client_end_ = log_sink.TakeClientEnd();
52 std::lock_guard lock(mutex_);
53 return std::move(client_end_);
57 std::atomic_store(&tags_,
58 std::make_shared<
const std::vector<std::string>>(
tags));
static void HandleInterestChange(const fuchsia_diagnostics::Interest &interest)
void SetTags(const std::initializer_list< std::string > &tags)
static LogState & Default()
std::shared_ptr< const std::vector< std::string > > tags() const
fidl::ClientEnd<::fuchsia_logger::LogSink > TakeClientEnd()