rpm  4.17.0
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 {
33  RPMLOG_ERR = 3,
37  RPMLOG_DEBUG = 7
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)
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
102 #define RPMLOG_DEFAULT 0x01
103 #define RPMLOG_EXIT 0x02
107 typedef struct rpmlogRec_s * rpmlogRec;
108 
114 const char * rpmlogRecMessage(rpmlogRec rec);
115 
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 
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 */
int rpmlogGetNrecs(void)
Return number of rpmError() ressages.
rpmlogFac_e
facility codes
Definition: rpmlog.h:48
int rpmlogSetMask(int mask)
Set the log mask level.
FILE * rpmlogSetFile(FILE *fp)
Set rpmlog file handle.
void rpmlogOpen(const char *ident, int option, int facility)
Open connection to system logger.
const char * rpmlogRecMessage(rpmlogRec rec)
Retrieve log message string from rpmlog record.
const char * rpmlogLevelPrefix(rpmlogLvl pri)
Return translated prefix string (if any) given log level.
void rpmlogPrint(FILE *f)
Print all rpmError() messages.
enum rpmlogLvl_e rpmlogLvl
RPM Log levels.
int(* rpmlogCallback)(rpmlogRec rec, rpmlogCallbackData data)
Definition: rpmlog.h:133
void rpmlog(int code, const char *fmt,...) RPM_GNUC_PRINTF(2
Generate a log message using FMT string and option arguments.
void const char * rpmlogMessage(void)
Return text of last rpmError() message.
rpmlogCallback rpmlogSetCallback(rpmlogCallback cb, rpmlogCallbackData data)
Set rpmlog callback function.
void rpmlogClose(void)
Close desriptor used to write to system logger.
struct rpmlogRec_s * rpmlogRec
Definition: rpmlog.h:107
rpmlogLvl rpmlogRecPriority(rpmlogRec rec)
Retrieve log priority from rpmlog record.
enum rpmlogFac_e rpmlogFac
facility codes
rpmlogLvl_e
RPM Log levels.
Definition: rpmlog.h:29
int rpmlogCode(void)
Return error code from last rpmError() message.
@ RPMLOG_CRON
Definition: rpmlog.h:58
@ RPMLOG_KERN
Definition: rpmlog.h:49
@ RPMLOG_NEWS
Definition: rpmlog.h:56
@ RPMLOG_AUTH
Definition: rpmlog.h:53
@ RPMLOG_LOCAL3
Definition: rpmlog.h:66
@ RPMLOG_LOCAL0
Definition: rpmlog.h:63
@ RPMLOG_SYSLOG
Definition: rpmlog.h:54
@ RPMLOG_LOCAL2
Definition: rpmlog.h:65
@ RPMLOG_LOCAL6
Definition: rpmlog.h:69
@ RPMLOG_LPR
Definition: rpmlog.h:55
@ RPMLOG_ERRMSG
Definition: rpmlog.h:73
@ RPMLOG_DAEMON
Definition: rpmlog.h:52
@ RPMLOG_UUCP
Definition: rpmlog.h:57
@ RPMLOG_LOCAL7
Definition: rpmlog.h:70
@ RPMLOG_LOCAL5
Definition: rpmlog.h:68
@ RPMLOG_FTP
Definition: rpmlog.h:60
@ RPMLOG_USER
Definition: rpmlog.h:50
@ RPMLOG_AUTHPRIV
Definition: rpmlog.h:59
@ RPMLOG_LOCAL4
Definition: rpmlog.h:67
@ RPMLOG_LOCAL1
Definition: rpmlog.h:64
@ RPMLOG_MAIL
Definition: rpmlog.h:51
@ RPMLOG_DEBUG
Definition: rpmlog.h:37
@ RPMLOG_ERR
Definition: rpmlog.h:33
@ RPMLOG_WARNING
Definition: rpmlog.h:34
@ RPMLOG_NOTICE
Definition: rpmlog.h:35
@ RPMLOG_INFO
Definition: rpmlog.h:36
@ RPMLOG_CRIT
Definition: rpmlog.h:32
@ RPMLOG_EMERG
Definition: rpmlog.h:30
@ RPMLOG_ALERT
Definition: rpmlog.h:31
#define RPMLOG_NFACILITIES
Definition: rpmlog.h:72
void * rpmlogCallbackData
Definition: rpmlog.h:123
#define RPM_GNUC_PRINTF(format_idx, arg_idx)
Definition: rpmutil.h:68