Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Default for formatters and Facility; get hostname automatically #51

Merged
merged 2 commits into from
Dec 5, 2021
Merged

Implement Default for formatters and Facility; get hostname automatically #51

merged 2 commits into from
Dec 5, 2021

Conversation

argv-minus-one
Copy link
Contributor

This PR implements Default for Facility, Formatter3164, and Formatter5424.

Motivation

Most of the Formatter* fields are about the host environment. The only one that the application really needs to fill in is facility. By implementing Default for Formatter*, constructing one is made much easier:

let formatter = syslog::Formatter3164 {
  facility: syslog::Facility::LOG_DAEMON,
  ..Default::default()
};

Defaults

The default Facility is LOG_USER, as specified by POSIX.

Formatter defaults are as follows:

syslog::init

In addition to the Default implementations, the init function now fills in the hostname in the same way.

Dependencies & MSRV

This PR adds a dependency on the hostname crate.

This PR does not change the minimum supported Rust version of this crate, which appears to be 1.31. (Even without this PR, this crate fails to build on Rust ≤ 1.30.)

@Geal
Copy link
Owner

Geal commented Dec 5, 2021

great idea, thanks

@Geal Geal merged commit 4f7b35e into Geal:master Dec 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants