Function redirect_stdout

Source
pub fn redirect_stdout(
    buffer: BufferId,
    tag: &str,
    prio: Priority,
) -> Result<()>
Expand description

Open an unstructured connection to a DLog logging sink.

Opens a connection with stdout to which you can stream data. DLog will automatically convert it to individual logs appropriately.

§Arguments

  • buffer - Target DLog buffer.
  • tag - DLog tag for the resulting logs.
  • prio - Priority for the resulting logs.

§Errors

§Examples

use dlog::{BufferId, Priority};
use dlog_redirect_stdout::redirect_stdout;

fn main() -> Result<(), std::io::Error> {
    redirect_stdout(BufferId::LogIdMain, "foo", Priority::Info)?;
    // The following sends an info log with tag "foo" and message "my_message".
    println!("my_message");
    Ok(())
}