1
+ //! Interfaces for controlling system log.
2
+
1
3
use std:: ffi:: CString ;
2
4
3
5
#[ cfg( target_os = "macos" ) ]
@@ -15,61 +17,91 @@ pub fn syslog(priority: libc::c_int, message: &str) {
15
17
unsafe { libc:: syslog ( priority, formatter. as_ptr ( ) , message. as_ptr ( ) ) }
16
18
}
17
19
18
- pub use self :: consts:: * ;
19
-
20
- #[ cfg( target_os = "macos" ) ]
21
- mod consts {
22
- libc_bitflags ! {
23
- pub struct LogFlags : libc:: c_int {
24
- /// Log the process id with each message: useful for identifying instantiations of
25
- /// daemons.
26
- LOG_PID ;
27
- /// If syslog() cannot pass the message to syslogd(8) it will attempt to write the
28
- /// message to the console ("/dev/console").
29
- LOG_CONS ;
30
- /// Open the connection to syslogd(8) immediately. Normally the open is delayed until
31
- /// the first message is logged. Useful for programs that need to manage the order in
32
- /// which file descriptors are allocated.
33
- LOG_NDELAY ;
34
- /// Write the message to standard error output as well to the system log.
35
- LOG_PERROR ;
36
- }
20
+ libc_bitflags ! {
21
+ pub struct LogFlags : libc:: c_int {
22
+ /// Log the process id with each message: useful for identifying instantiations of
23
+ /// daemons.
24
+ LOG_PID ;
25
+ /// If syslog() cannot pass the message to syslogd(8) it will attempt to write the
26
+ /// message to the console ("/dev/console").
27
+ LOG_CONS ;
28
+ /// Open the connection to syslogd(8) immediately. Normally the open is delayed until
29
+ /// the first message is logged. Useful for programs that need to manage the order in
30
+ /// which file descriptors are allocated.
31
+ LOG_NDELAY ;
32
+ /// Write the message to standard error output as well to the system log.
33
+ LOG_PERROR ;
37
34
}
35
+ }
38
36
39
- #[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
37
+ libc_enum ! {
38
+ /// Severity levels for log messages.
40
39
#[ repr( i32 ) ]
41
40
#[ non_exhaustive]
42
41
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 ,
42
+ /// A panic condition.
43
+ ///
44
+ /// This is normally broadcast to all users.
45
+ LOG_EMERG ,
46
+ /// A condition that should be corrected immediately, such as a corrupted system database.
47
+ LOG_ALERT ,
48
+ /// Critical conditions, e.g., hard device errors.
49
+ LOG_CRIT ,
50
+ /// Errors.
51
+ LOG_ERR ,
52
+ /// Warning messages.
53
+ LOG_WARNING ,
54
+ /// Conditions that are not error conditions, but should possibly be handled specially.
55
+ LOG_NOTICE ,
56
+ /// Informational messages.
57
+ LOG_INFO ,
58
+ /// Messages that contain information normally of use only when debugging a program.
59
+ LOG_DEBUG ,
51
60
}
61
+ }
52
62
53
- #[ derive( Clone , Copy , Debug , Eq , PartialEq ) ]
63
+ libc_enum ! {
64
+ /// Facilities for log messages.
54
65
#[ repr( i32 ) ]
55
66
#[ non_exhaustive]
56
67
pub enum Facility {
57
- LOG_KERN = libc:: LOG_KERN ,
58
- LOG_USER = libc:: LOG_USER ,
59
- LOG_MAIL = libc:: LOG_MAIL ,
60
- LOG_DAEMON = libc:: LOG_DAEMON ,
61
- LOG_AUTH = libc:: LOG_AUTH ,
62
- LOG_SYSLOG = libc:: LOG_SYSLOG ,
63
- LOG_LPR = libc:: LOG_LPR ,
64
- LOG_NEWS = libc:: LOG_NEWS ,
65
- LOG_UUCP = libc:: LOG_UUCP ,
66
- LOG_LOCAL0 = libc:: LOG_LOCAL0 ,
67
- LOG_LOCAL1 = libc:: LOG_LOCAL1 ,
68
- LOG_LOCAL2 = libc:: LOG_LOCAL2 ,
69
- LOG_LOCAL3 = libc:: LOG_LOCAL3 ,
70
- LOG_LOCAL4 = libc:: LOG_LOCAL4 ,
71
- LOG_LOCAL5 = libc:: LOG_LOCAL5 ,
72
- LOG_LOCAL6 = libc:: LOG_LOCAL6 ,
73
- LOG_LOCAL7 = libc:: LOG_LOCAL7 ,
68
+ /// Messages generated by the kernel.
69
+ ///
70
+ /// These cannot be generated by any user processes.
71
+ LOG_KERN ,
72
+ /// Messages generated by random user processes.
73
+ ///
74
+ /// This is the default facility identifier if none is specified.
75
+ LOG_USER ,
76
+ /// The mail system.
77
+ LOG_MAIL ,
78
+ /// System daemons, such as routed(8), that are not provided for explicitly by other facilities.
79
+ LOG_DAEMON ,
80
+ /// The authorization system: login(1), su(1), getty(8), etc.
81
+ LOG_AUTH ,
82
+ /// Messages generated internally by syslogd(8).
83
+ LOG_SYSLOG ,
84
+ /// The line printer spooling system: cups-lpd(8), cupsd(8), etc.
85
+ LOG_LPR ,
86
+ /// The network news system.
87
+ LOG_NEWS ,
88
+ /// The uucp system.
89
+ LOG_UUCP ,
90
+ /// Reserved for local use.
91
+ LOG_LOCAL0 ,
92
+ /// Reserved for local use.
93
+ LOG_LOCAL1 ,
94
+ /// Reserved for local use.
95
+ LOG_LOCAL2 ,
96
+ /// Reserved for local use.
97
+ LOG_LOCAL3 ,
98
+ /// Reserved for local use.
99
+ LOG_LOCAL4 ,
100
+ /// Reserved for local use.
101
+ LOG_LOCAL5 ,
102
+ /// Reserved for local use.
103
+ LOG_LOCAL6 ,
104
+ /// Reserved for local use.
105
+ LOG_LOCAL7 ,
74
106
}
75
107
}
0 commit comments