Skip to content

Commit 98289d5

Browse files
committed
try add setlogmask
Signed-off-by: tison <[email protected]>
1 parent 953fdec commit 98289d5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/syslog.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,25 @@ pub fn syslog<S: AsRef<OsStr> + ?Sized>(priority: Priority, message: &S) {
2929
unsafe { libc::syslog(priority.0, formatter.as_ptr(), message.as_ptr()) }
3030
}
3131

32+
/// Closes the log file.
33+
pub fn closelog() {
34+
unsafe { libc::closelog() }
35+
}
36+
37+
/// Sets the log priority mask to `maskpri` and returns the previous mask.
38+
///
39+
/// A process has a log priority mask that determines which calls to [`syslog`] may be logged.
40+
/// All other calls will be ignored. Logging is enabled for the priorities that have the
41+
/// corresponding bit set in `maskpri`. The initial mask is such that logging is enabled for all
42+
/// priorities.
43+
///
44+
/// The [`setlogmask`] function sets this mask for the calling process, and returns the previous
45+
/// mask. If `maskpri` is 0, the current log mask is not modified.
46+
pub fn setlogmask(maskpri: libc::c_int) -> libc::c_int {
47+
let mask = unsafe { libc::setlogmask(maskpri) };
48+
mask
49+
}
50+
3251
/// The priority for a log message.
3352
#[derive(Debug, Clone, Copy)]
3453
pub struct Priority(libc::c_int);

0 commit comments

Comments
 (0)