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 D-Bus 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.
§Errors
Return an error if the level is not supported, or if changing the level
fails.
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.
§Errors
Return an error if the target is not supported, or if switching to the target failed.
Sourcefn syslog_identifier(&self) -> &str
fn syslog_identifier(&self) -> &str
Get the syslog identifier.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.