Skip to content

Commit 0c61a95

Browse files
committed
fixup
Signed-off-by: tison <[email protected]>
1 parent 169b5d0 commit 0c61a95

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/syslog.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ use std::ffi::OsStr;
99
/// The parameter `ident` is a string that will be prepended to every message. The `logopt`
1010
/// argument specifies logging options. The `facility` parameter encodes a default facility to be
1111
/// assigned to all messages that do not have an explicit facility encoded.
12-
pub fn openlog<S: AsRef<OsStr> + ?Sized>(
12+
pub fn openlog<S>(
1313
ident: Option<&S>,
1414
logopt: LogFlags,
1515
facility: Facility,
16-
) -> Result<()> {
16+
) -> Result<()>
17+
where
18+
S: AsRef<OsStr> + ?Sized,
19+
{
1720
let logopt = logopt.bits();
1821
let facility = facility as libc::c_int;
1922
match ident.map(OsStr::new) {
@@ -37,7 +40,7 @@ pub fn openlog<S: AsRef<OsStr> + ?Sized>(
3740
/// ```rust
3841
/// use nix::syslog::{openlog, syslog, Facility, LogFlags, Severity};
3942
///
40-
/// openlog(None, LogFlags::LOG_PID, Facility::LOG_USER).unwrap();
43+
/// openlog(None::<&str>, LogFlags::LOG_PID, Facility::LOG_USER).unwrap();
4144
/// syslog(Severity::LOG_EMERG, "Hello, nix!").unwrap();
4245
///
4346
/// // use `format!` to format the message

test/test_syslog.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ use nix::syslog::{openlog, syslog, Facility, LogFlags, Severity};
22

33
#[test]
44
fn test_syslog_hello_world() {
5-
openlog(None, LogFlags::LOG_PID, Facility::LOG_USER).unwrap();
5+
openlog(None::<&str>, LogFlags::LOG_PID, Facility::LOG_USER).unwrap();
66
syslog(Severity::LOG_EMERG, "Hello, nix!").unwrap();
7+
8+
let name = "syslog";
9+
syslog(Severity::LOG_NOTICE, &format!("Hello, {name}!")).unwrap();
710
}

0 commit comments

Comments
 (0)