6 * Yet Another syslog(3) API clone.
7 * Used to unify rpmError() and rpmMessage() interfaces in rpm.
14 * priorities/facilities are encoded into a single 32-bit quantity, where the
15 * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
16 * (0-big number). Both the priorities and the facilities map roughly
17 * one-to-one to strings in the syslogd(8) source code. This mapping is
18 * included in this file.
20 * priorities (these are ordered)
22 typedef enum rpmlogLvl_e {
23 RPMLOG_EMERG = 0, /*!< system is unusable */
24 RPMLOG_ALERT = 1, /*!< action must be taken immediately */
25 RPMLOG_CRIT = 2, /*!< critical conditions */
26 RPMLOG_ERR = 3, /*!< error conditions */
27 RPMLOG_WARNING = 4, /*!< warning conditions */
28 RPMLOG_NOTICE = 5, /*!< normal but significant condition */
29 RPMLOG_INFO = 6, /*!< informational */
30 RPMLOG_DEBUG = 7 /*!< debug-level messages */
33 #define RPMLOG_PRIMASK 0x07 /* mask to extract priority part (internal) */
34 /* extract priority */
35 #define RPMLOG_PRI(p) ((p) & RPMLOG_PRIMASK)
36 #define RPMLOG_MAKEPRI(fac, pri) ((((unsigned)(fac)) << 3) | (pri))
39 #define _RPMLOG_NOPRI 0x10 /* the "no priority" priority */
41 #define _RPMLOG_MARK RPMLOG_MAKEPRI(RPMLOG_NFACILITIES, 0)
42 typedef struct _rpmcode {
47 RPMCODE rpmprioritynames[] =
49 { "alert", RPMLOG_ALERT },
50 { "crit", RPMLOG_CRIT },
51 { "debug", RPMLOG_DEBUG },
52 { "emerg", RPMLOG_EMERG },
53 { "err", RPMLOG_ERR },
54 { "error", RPMLOG_ERR }, /* DEPRECATED */
55 { "info", RPMLOG_INFO },
56 { "none", _RPMLOG_NOPRI }, /* INTERNAL */
57 { "notice", RPMLOG_NOTICE },
58 { "panic", RPMLOG_EMERG }, /* DEPRECATED */
59 { "warn", RPMLOG_WARNING }, /* DEPRECATED */
60 { "warning",RPMLOG_WARNING },
68 typedef enum rpmlogFac_e {
69 RPMLOG_KERN = (0<<3), /*!< kernel messages */
70 RPMLOG_USER = (1<<3), /*!< random user-level messages */
71 RPMLOG_MAIL = (2<<3), /*!< mail system */
72 RPMLOG_DAEMON = (3<<3), /*!< system daemons */
73 RPMLOG_AUTH = (4<<3), /*!< security/authorization messages */
74 RPMLOG_SYSLOG = (5<<3), /*!< messages generated internally by syslogd */
75 RPMLOG_LPR = (6<<3), /*!< line printer subsystem */
76 RPMLOG_NEWS = (7<<3), /*!< network news subsystem */
77 RPMLOG_UUCP = (8<<3), /*!< UUCP subsystem */
78 RPMLOG_CRON = (9<<3), /*!< clock daemon */
79 RPMLOG_AUTHPRIV = (10<<3), /*!< security/authorization messages (private) */
80 RPMLOG_FTP = (11<<3), /*!< ftp daemon */
82 /* other codes through 15 reserved for system use */
83 RPMLOG_LOCAL0 = (16<<3), /*!< reserved for local use */
84 RPMLOG_LOCAL1 = (17<<3), /*!< reserved for local use */
85 RPMLOG_LOCAL2 = (18<<3), /*!< reserved for local use */
86 RPMLOG_LOCAL3 = (19<<3), /*!< reserved for local use */
87 RPMLOG_LOCAL4 = (20<<3), /*!< reserved for local use */
88 RPMLOG_LOCAL5 = (21<<3), /*!< reserved for local use */
89 RPMLOG_LOCAL6 = (22<<3), /*!< reserved for local use */
90 RPMLOG_LOCAL7 = (23<<3), /*!< reserved for local use */
92 #define RPMLOG_NFACILITIES 24 /*!< current number of facilities */
93 RPMLOG_ERRMSG = (((unsigned)(RPMLOG_NFACILITIES+0))<<3)
96 #define RPMLOG_FACMASK 0x03f8 /*!< mask to extract facility part */
97 #define RPMLOG_FAC(p) (((p) & RPMLOG_FACMASK) >> 3)
101 CODE facilitynames[] =
103 { "auth", RPMLOG_AUTH },
104 { "authpriv",RPMLOG_AUTHPRIV },
105 { "cron", RPMLOG_CRON },
106 { "daemon", RPMLOG_DAEMON },
107 { "ftp", RPMLOG_FTP },
108 { "kern", RPMLOG_KERN },
109 { "lpr", RPMLOG_LPR },
110 { "mail", RPMLOG_MAIL },
111 { "mark", _RPMLOG_MARK }, /* INTERNAL */
112 { "news", RPMLOG_NEWS },
113 { "security",RPMLOG_AUTH }, /* DEPRECATED */
114 { "syslog", RPMLOG_SYSLOG },
115 { "user", RPMLOG_USER },
116 { "uucp", RPMLOG_UUCP },
117 { "local0", RPMLOG_LOCAL0 },
118 { "local1", RPMLOG_LOCAL1 },
119 { "local2", RPMLOG_LOCAL2 },
120 { "local3", RPMLOG_LOCAL3 },
121 { "local4", RPMLOG_LOCAL4 },
122 { "local5", RPMLOG_LOCAL5 },
123 { "local6", RPMLOG_LOCAL6 },
124 { "local7", RPMLOG_LOCAL7 },
130 * arguments to setlogmask.
132 #define RPMLOG_MASK(pri) (1 << (pri)) /*!< mask for one priority */
133 #define RPMLOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /*!< all priorities through pri */
136 * Option flags for openlog.
138 * RPMLOG_ODELAY no longer does anything.
139 * RPMLOG_NDELAY is the inverse of what it used to be.
141 #define RPMLOG_PID 0x01 /*!< log the pid with each message */
142 #define RPMLOG_CONS 0x02 /*!< log on the console if errors in sending */
143 #define RPMLOG_ODELAY 0x04 /*!< delay open until first syslog() (default) */
144 #define RPMLOG_NDELAY 0x08 /*!< don't delay open */
145 #define RPMLOG_NOWAIT 0x10 /*!< don't wait for console forks: DEPRECATED */
146 #define RPMLOG_PERROR 0x20 /*!< log to stderr as well */
149 * @todo Add argument(s), integrate with other types of callbacks.
151 typedef void (*rpmlogCallback) (void);
155 typedef /*@abstract@*/ struct rpmlogRec_s {
157 const char * message;
165 * Return number of rpmError() ressages.
166 * @return number of messages
168 int rpmlogGetNrecs(void);
171 * Return text of last rpmError() message.
172 * @return text of last message
174 /*@observer@*/ const char * rpmlogMessage(void);
177 * Return error code from last rpmError() message.
178 * @deprecated Perl-RPM needs, what's really needed is predictable, non-i18n
179 * encumbered, error text that can be retrieved through rpmlogMessage()
181 * @return code from last message
183 int rpmlogCode(void);
186 * Print all rpmError() messages.
187 * @param f file handle (NULL uses stderr)
189 void rpmlogPrint(FILE *f);
192 * Close desriptor used to write to system logger.
195 void rpmlogClose (void);
198 * Open connection to system logger.
201 void rpmlogOpen (const char *ident, int option, int facility);
204 * Set the log mask level.
206 int rpmlogSetMask (int mask);
209 * Generate a log message using FMT string and option arguments.
211 void rpmlog (int pri, const char *fmt, ...);
214 * Set rpmlog callback function.
216 rpmlogCallback rpmlogSetCallback(rpmlogCallback cb);
219 * Set rpmlog callback function.
220 * @deprecated gnorpm needs, use rpmlogSetCallback() instead.
222 rpmlogCallback rpmErrorSetCallback(rpmlogCallback cb);
225 * Return error code from last rpmError() message.
226 * @deprecated Perl-RPM needs, use rpmlogCode() instead.
227 * @return code from last message
229 int rpmErrorCode(void);
232 * Return text of last rpmError() message.
233 * @deprecated gnorpm needs, use rpmlogMessage() instead.
234 * @return text of last message
236 /*@observer@*/ const char * rpmErrorString(void);
242 #endif /* H_RPMLOG */