1+ use std:: ffi:: CString ;
2+
13#[ cfg( target_os = "macos" ) ]
24pub fn openlog ( ident : & str , logopt : LogFlags , facility : Facility ) {
35 let ident = CString :: new ( ident) . expect ( "TODO: handle error" ) ;
@@ -6,8 +8,14 @@ pub fn openlog(ident: &str, logopt: LogFlags, facility: Facility) {
68 }
79}
810
11+ #[ cfg( target_os = "macos" ) ]
12+ pub fn syslog ( priority : libc:: c_int , message : & str ) {
13+ let formatter = CString :: new ( "%s" ) . expect ( "TODO: handle error" ) ;
14+ let message = CString :: new ( message) . expect ( "TODO: handle error" ) ;
15+ unsafe { libc:: syslog ( priority, formatter. as_ptr ( ) , message. as_ptr ( ) ) }
16+ }
17+
918pub use self :: consts:: * ;
10- use std:: ffi:: CString ;
1119
1220#[ cfg( target_os = "macos" ) ]
1321mod consts {
@@ -28,6 +36,20 @@ mod consts {
2836 }
2937 }
3038
39+ #[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
40+ #[ repr( i32 ) ]
41+ #[ non_exhaustive]
42+ pub enum Severity {
43+ LOG_EMERG = libc:: LOG_EMERG ,
44+ LOG_ALERT = libc:: LOG_ALERT ,
45+ LOG_CRIT = libc:: LOG_CRIT ,
46+ LOG_ERR = libc:: LOG_ERR ,
47+ LOG_WARNING = libc:: LOG_WARNING ,
48+ LOG_NOTICE = libc:: LOG_NOTICE ,
49+ LOG_INFO = libc:: LOG_INFO ,
50+ LOG_DEBUG = libc:: LOG_DEBUG ,
51+ }
52+
3153 #[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
3254 #[ repr( i32 ) ]
3355 #[ non_exhaustive]
0 commit comments