Trait logcontrol::LogControl1
source · pub trait LogControl1 {
// Required methods
fn level(&self) -> LogLevel;
fn set_level(&mut self, level: LogLevel) -> Result<(), LogControl1Error>;
fn target(&self) -> &str;
fn set_target<S: AsRef<str>>(
&mut self,
target: S
) -> Result<(), LogControl1Error>;
fn syslog_identifier(&self) -> &str;
}
Expand description
Abstract representation of the LogControl1 interface.
Bridges a DBus frontend to a backend logging framework.
Implementations should choose the initial log target automatically, according
to whether their stderr is already connected to the systemd journal directly,
per $JOURNAL_STREAM
(see systemd.exec(5)
).
stderr_connected_to_journal
implements this check.
Required Methods§
sourcefn set_level(&mut self, level: LogLevel) -> Result<(), LogControl1Error>
fn set_level(&mut self, level: LogLevel) -> Result<(), LogControl1Error>
Set the level of the underlying log framework.
sourcefn set_target<S: AsRef<str>>(
&mut self,
target: S
) -> Result<(), LogControl1Error>
fn set_target<S: AsRef<str>>( &mut self, target: S ) -> Result<(), LogControl1Error>
Set the target of the underlying log framework.
Systemd documents some known targets both in the LogControl1
interface
definition, as well as in the systemctl(1)
manpage. The KnownLogTarget
enum represents all these known targets.
However, implementations are free to use their own proprietary targets;
systemctl service-log-target
actually forwards any given string to the
service.
It’s a good idea though to support at least KnownLogTarget::Console
and KnownLogTarget::Journal
.
sourcefn syslog_identifier(&self) -> &str
fn syslog_identifier(&self) -> &str
Get the syslog identifier.