Skip to main content

setup_systemd_journal_logging_when_connected

Function setup_systemd_journal_logging_when_connected 

Source
pub fn setup_systemd_journal_logging_when_connected(
    max_level: impl Into<LevelFilter>,
) -> Result<(), Error>
Expand description

Sets up a global systemd journal logger based on a maximum logging level filter, when connected to the journal.

§Note

Only sets up logging, if the current process is connected to the journal (see JOURNAL_STREAM in systemd.exec(5)). This is particularly useful e.g. in systemd.service(5) files in which the executed command is connected to the journal with the help of the StandardOutput and StandardError logging and standard input/output settings.

§Errors

Returns an error, if

  • the process is not connected to the systemd journal
  • globally installing a [JournalLog] fails