rpm 4.15.1

rpmlog.h
Go to the documentation of this file.
1 #ifndef H_RPMLOG
2 #define H_RPMLOG 1
3
10 #include <stdarg.h>
11 #include <stdio.h>
12
13 #include <rpm/rpmutil.h>
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
29 typedef enum rpmlogLvl_e {
30 RPMLOG_EMERG = 0,
31 RPMLOG_ALERT = 1,
32 RPMLOG_CRIT = 2,
33 RPMLOG_ERR = 3,
34 RPMLOG_WARNING = 4,
35 RPMLOG_NOTICE = 5,
36 RPMLOG_INFO = 6,
37 RPMLOG_DEBUG = 7
38 } rpmlogLvl;
39
40 #define RPMLOG_PRIMASK 0x07 /* mask to extract priority part (internal) */
41 /* extract priority */
42 #define RPMLOG_PRI(p) ((p) & RPMLOG_PRIMASK)
43 #define RPMLOG_MAKEPRI(fac, pri) ((((unsigned)(fac)) << 3) | (pri))
44
48 typedef enum rpmlogFac_e {
49 RPMLOG_KERN = (0<<3),
50 RPMLOG_USER = (1<<3),
51 RPMLOG_MAIL = (2<<3),
52 RPMLOG_DAEMON = (3<<3),
53 RPMLOG_AUTH = (4<<3),
54 RPMLOG_SYSLOG = (5<<3),
55 RPMLOG_LPR = (6<<3),
56 RPMLOG_NEWS = (7<<3),
57 RPMLOG_UUCP = (8<<3),
58 RPMLOG_CRON = (9<<3),
59 RPMLOG_AUTHPRIV = (10<<3),
60 RPMLOG_FTP = (11<<3),
62 /* other codes through 15 reserved for system use */
63 RPMLOG_LOCAL0 = (16<<3),
64 RPMLOG_LOCAL1 = (17<<3),
65 RPMLOG_LOCAL2 = (18<<3),
66 RPMLOG_LOCAL3 = (19<<3),
67 RPMLOG_LOCAL4 = (20<<3),
68 RPMLOG_LOCAL5 = (21<<3),
69 RPMLOG_LOCAL6 = (22<<3),
70 RPMLOG_LOCAL7 = (23<<3),
72 #define RPMLOG_NFACILITIES 24
73 RPMLOG_ERRMSG = (((unsigned)(RPMLOG_NFACILITIES+0))<<3)
74 } rpmlogFac;
75
76 #define RPMLOG_FACMASK 0x03f8
77 #define RPMLOG_FAC(p) (((p) & RPMLOG_FACMASK) >> 3)
78
79
80 /*
81 * arguments to setlogmask.
82 */
83 #define RPMLOG_MASK(pri) (1 << ((unsigned)(pri)))
84 #define RPMLOG_UPTO(pri) ((1 << (((unsigned)(pri))+1)) - 1)
86 /*
87 * Option flags for openlog.
88 *
89 * RPMLOG_ODELAY no longer does anything.
90 * RPMLOG_NDELAY is the inverse of what it used to be.
91 */
92 #define RPMLOG_PID 0x01
93 #define RPMLOG_CONS 0x02
94 #define RPMLOG_ODELAY 0x04
95 #define RPMLOG_NDELAY 0x08
96 #define RPMLOG_NOWAIT 0x10
97 #define RPMLOG_PERROR 0x20
99 /* \ingroup rpmlog
100 * Option flags for callback return value.
101 */
102 #define RPMLOG_DEFAULT 0x01
103 #define RPMLOG_EXIT 0x02
107 typedef struct rpmlogRec_s * rpmlogRec;
108
114 const char * rpmlogRecMessage(rpmlogRec rec);
115
121 rpmlogLvl rpmlogRecPriority(rpmlogRec rec);
122
123 typedef void * rpmlogCallbackData;
124
133 typedef int (*rpmlogCallback) (rpmlogRec rec, rpmlogCallbackData data);
134
139 int rpmlogGetNrecs(void) ;
140
145 void rpmlogPrint(FILE *f);
146
151 void rpmlogClose (void);
152
157 void rpmlogOpen (const char * ident, int option, int facility);
158
164 int rpmlogSetMask (int mask);
165
169 void rpmlog (int code, const char *fmt, ...) RPM_GNUC_PRINTF(2, 3);
170
175 const char * rpmlogMessage(void);
176
184 int rpmlogCode(void);
185
191 const char * rpmlogLevelPrefix(rpmlogLvl pri);
192
199 rpmlogCallback rpmlogSetCallback(rpmlogCallback cb, rpmlogCallbackData data);
200
206 FILE * rpmlogSetFile(FILE * fp);
207
208 #define rpmSetVerbosity(_lvl) \
209 ((void)rpmlogSetMask( RPMLOG_UPTO( RPMLOG_PRI(_lvl))))
210 #define rpmIncreaseVerbosity() \
211 ((void)rpmlogSetMask(((((unsigned)(rpmlogSetMask(0) & 0xff)) << 1) | 1)))
212 #define rpmDecreaseVerbosity() \
213 ((void)rpmlogSetMask((((int)(rpmlogSetMask(0) & 0xff)) >> 1)))
214 #define rpmIsNormal() \
215 (rpmlogSetMask(0) >= RPMLOG_MASK( RPMLOG_NOTICE ))
216 #define rpmIsVerbose() \
217 (rpmlogSetMask(0) >= RPMLOG_MASK( RPMLOG_INFO ))
218 #define rpmIsDebug() \
219 (rpmlogSetMask(0) >= RPMLOG_MASK( RPMLOG_DEBUG ))
220
221 #ifdef __cplusplus
222 }
223 #endif
224
225 #endif /* H_RPMLOG */
rpmlogClose
void rpmlogClose(void)
rpmlog
void rpmlog(int code, const char *fmt,...) RPM_GNUC_PRINTF(2
RPMLOG_ALERT
@ RPMLOG_ALERT
Definition: rpmlog.h:31
rpmlogSetFile
FILE * rpmlogSetFile(FILE *fp)
RPMLOG_ERR
@ RPMLOG_ERR
Definition: rpmlog.h:33
rpmlogCallback
int(* rpmlogCallback)(rpmlogRec rec, rpmlogCallbackData data)
Definition: rpmlog.h:133
RPMLOG_LOCAL3
@ RPMLOG_LOCAL3
Definition: rpmlog.h:66
RPMLOG_KERN
@ RPMLOG_KERN
Definition: rpmlog.h:49
RPMLOG_CRON
@ RPMLOG_CRON
Definition: rpmlog.h:58
RPMLOG_LOCAL7
@ RPMLOG_LOCAL7
Definition: rpmlog.h:70
rpmlogSetMask
int rpmlogSetMask(int mask)
rpmlogFac_e
rpmlogFac_e
Definition: rpmlog.h:48
RPMLOG_WARNING
@ RPMLOG_WARNING
Definition: rpmlog.h:34
RPMLOG_INFO
@ RPMLOG_INFO
Definition: rpmlog.h:36
rpmlogRecMessage
const char * rpmlogRecMessage(rpmlogRec rec)
RPMLOG_LOCAL5
@ RPMLOG_LOCAL5
Definition: rpmlog.h:68
RPMLOG_LOCAL1
@ RPMLOG_LOCAL1
Definition: rpmlog.h:64
rpmlogCode
int rpmlogCode(void)
RPMLOG_USER
@ RPMLOG_USER
Definition: rpmlog.h:50
RPMLOG_DAEMON
@ RPMLOG_DAEMON
Definition: rpmlog.h:52
RPMLOG_LOCAL2
@ RPMLOG_LOCAL2
Definition: rpmlog.h:65
RPMLOG_FTP
@ RPMLOG_FTP
Definition: rpmlog.h:60
rpmlogLevelPrefix
const char * rpmlogLevelPrefix(rpmlogLvl pri)
RPMLOG_SYSLOG
@ RPMLOG_SYSLOG
Definition: rpmlog.h:54
RPM_GNUC_PRINTF
#define RPM_GNUC_PRINTF(format_idx, arg_idx)
Definition: rpmutil.h:68
RPMLOG_LOCAL0
@ RPMLOG_LOCAL0
Definition: rpmlog.h:63
RPMLOG_NEWS
@ RPMLOG_NEWS
Definition: rpmlog.h:56
RPMLOG_AUTHPRIV
@ RPMLOG_AUTHPRIV
Definition: rpmlog.h:59
rpmlogOpen
void rpmlogOpen(const char *ident, int option, int facility)
RPMLOG_LPR
@ RPMLOG_LPR
Definition: rpmlog.h:55
rpmlogCallbackData
void * rpmlogCallbackData
Definition: rpmlog.h:123
rpmlogFac
enum rpmlogFac_e rpmlogFac
rpmlogRec
struct rpmlogRec_s * rpmlogRec
Definition: rpmlog.h:107
RPMLOG_MAIL
@ RPMLOG_MAIL
Definition: rpmlog.h:51
rpmlogSetCallback
rpmlogCallback rpmlogSetCallback(rpmlogCallback cb, rpmlogCallbackData data)
rpmlogLvl
enum rpmlogLvl_e rpmlogLvl
RPMLOG_LOCAL4
@ RPMLOG_LOCAL4
Definition: rpmlog.h:67
RPMLOG_CRIT
@ RPMLOG_CRIT
Definition: rpmlog.h:32
RPMLOG_LOCAL6
@ RPMLOG_LOCAL6
Definition: rpmlog.h:69
rpmlogRecPriority
rpmlogLvl rpmlogRecPriority(rpmlogRec rec)
rpmlogMessage
void const char * rpmlogMessage(void)
RPMLOG_DEBUG
@ RPMLOG_DEBUG
Definition: rpmlog.h:37
rpmlogGetNrecs
int rpmlogGetNrecs(void)
RPMLOG_NOTICE
@ RPMLOG_NOTICE
Definition: rpmlog.h:35
RPMLOG_EMERG
@ RPMLOG_EMERG
Definition: rpmlog.h:30
RPMLOG_UUCP
@ RPMLOG_UUCP
Definition: rpmlog.h:57
RPMLOG_AUTH
@ RPMLOG_AUTH
Definition: rpmlog.h:53
rpmlogPrint
void rpmlogPrint(FILE *f)
rpmlogLvl_e
rpmlogLvl_e
Definition: rpmlog.h:29