pub fn journal_print(priority: Priority, msg: &str) -> Result<()> {
    let sock = UnixDatagram::unbound()?;

    let mut data = String::new();
    add_field_and_payload(&mut data, "PRIORITY", &(u8::from(priority)).to_string());
    add_field_and_payload(&mut data, "MESSAGE", msg);

    // Message sending logic:
    //  * fast path: data within datagram body.
    //  * slow path: data in a sealed memfd, which is sent as an FD in ancillary data.
    //
    // Maximum data size is system dependent, thus this always tries the fast path and
    // falls back to the slow path if the former fails with `EMSGSIZE`.
    let fast_res = sock.send_to(data.as_bytes(), SD_JOURNAL_SOCK_PATH);
    let res = match fast_res {
        // `EMSGSIZE` (errno code 90) means the message was too long for a UNIX socket,
        Err(ref err) if err.raw_os_error() == Some(90) => send_memfd_payload(sock, data.as_bytes()),
        r => r.map_err(|err| err.into()),
    };

    res.chain_err(|| format!("failed to print to journal at '{}'", SD_JOURNAL_SOCK_PATH))?;
    Ok(())
}
/// Print a message to the journal with the given priority.
///
/// This uses the default systemd-journald socket.
Print a message to the journal with the given priority.
This uses the default systemd-journald socket.
Print a message to the journal with the given priority . This uses the default systemd - journald socket .
pub fn journal_print(priority: Priority, msg: &str) -> Result<()> {
    let sock = UnixDatagram::unbound()?;
    let mut data = String::new();
    add_field_and_payload(&mut data, "PRIORITY", &(u8::from(priority)).to_string());
    add_field_and_payload(&mut data, "MESSAGE", msg);
    // Message sending logic:
    //  * fast path: data within datagram body.
    //  * slow path: data in a sealed memfd, which is sent as an FD in ancillary data.
    //
    // Maximum data size is system dependent, thus this always tries the fast path and
    // falls back to the slow path if the former fails with `EMSGSIZE`.
    let fast_res = sock.send_to(data.as_bytes(), SD_JOURNAL_SOCK_PATH);
    let res = match fast_res {
        // `EMSGSIZE` (errno code 90) means the message was too long for a UNIX socket,
        Err(ref err) if err.raw_os_error() == Some(90) => send_memfd_payload(sock, data.as_bytes()),
        r => r.map_err(|err| err.into()),
    };
    res.chain_err(|| format!("failed to print to journal at '{}'", SD_JOURNAL_SOCK_PATH))?;
    Ok(())
}
pub fn journal_print ( priority : Priority , msg : & str ) -> Result < ( ) > { let sock = UnixDatagram :: unbound ( ) ? ; let mut data = String :: new ( ) ; add_field_and_payload ( & mut data , " " , & ( u8 :: from ( priority ) ) . to_string ( ) ) ; add_field_and_payload ( & mut data , " " , msg ) ; // Message sending logic: //  * fast path: data within datagram body. //  * slow path: data in a sealed memfd, which is sent as an FD in ancillary data. // // Maximum data size is system dependent, thus this always tries the fast path and // falls back to the slow path if the former fails with `EMSGSIZE`. let fast_res = sock . send_to ( data . as_bytes ( ) , SD_JOURNAL_SOCK_PATH ) ; let res = match fast_res { // `EMSGSIZE` (errno code 90) means the message was too long for a UNIX socket, Err ( ref err ) if err . raw_os_error ( ) == Some ( 90 ) => send_memfd_payload ( sock , data . as_bytes ( ) ) , r => r . map_err ( | err | err . into ( ) ) , } ; res . chain_err ( | | format ! ( " " SD_JOURNAL_SOCK_PATH ) ) ? ; Ok ( ( ) ) }
Print a message to the journal with the given priority.
Print a message to the journal with the given priority .
priority
Priority
msg
&str