Skip to main content

stdout_to_debuglog/
lib.rs

1// Copyright 2020 The Fuchsia 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
5use anyhow::Error;
6use fidl_fuchsia_boot as fboot;
7
8pub async fn init() -> Result<(), Error> {
9    let write_only_log_proxy =
10        fuchsia_component::client::connect_to_protocol::<fboot::WriteOnlyLogMarker>()?;
11
12    let debuglog_handle = write_only_log_proxy.get().await?;
13
14    for fd in &[1, 2] {
15        let debuglog_dup = debuglog_handle.duplicate_handle(zx::Rights::SAME_RIGHTS)?;
16        fdio::bind_to_fd(debuglog_dup.into_handle(), *fd)?;
17    }
18    Ok(())
19}