pub fn redirect_stderr(
buffer: BufferId,
tag: &str,
prio: Priority,
) -> Result<()>Expand description
Open an unstructured connection to a DLog logging sink.
Opens a connection with stderr 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
std::io::ErrorKind::InvalidInput- Buffer does not allow connections.std::io::ErrorKind::PermissionDenied- Buffer disabled via dlog config.std::io::ErrorKind::Uncategorized- Buffer not configured via dlog config.std::io::ErrorKind::Uncategorized- Unsupported DLog backend.std::io::ErrorKind::InvalidInput- Tag empty.
§Examples
use dlog::{BufferId, Priority};
use dlog_redirect_stdout::redirect_stderr;
fn main() -> Result<(), std::io::Error> {
redirect_stderr(BufferId::LogIdMain, "foo", Priority::Info)?;
// The following sends an info log with tag "foo" and message "my_message".
eprintln!("my_message");
Ok(())
}