rpmlog.h
Go to the documentation of this file.
#ifndef H_RPMLOG
#define H_RPMLOG 1
#include <stdarg.h>
#include <stdio.h>
#include <rpm/rpmutil.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum rpmlogLvl_e {
RPMLOG_EMERG = 0,
RPMLOG_ALERT = 1,
RPMLOG_CRIT = 2,
RPMLOG_ERR = 3,
RPMLOG_WARNING = 4,
RPMLOG_NOTICE = 5,
RPMLOG_INFO = 6,
RPMLOG_DEBUG = 7
} rpmlogLvl;
#define RPMLOG_PRIMASK 0x07 /* mask to extract priority part (internal) */
/* extract priority */
#define RPMLOG_PRI(p) ((p) & RPMLOG_PRIMASK)
#define RPMLOG_MAKEPRI(fac, pri) ((((unsigned)(fac)) << 3) | (pri))
typedef enum rpmlogFac_e {
RPMLOG_KERN = (0<<3),
RPMLOG_USER = (1<<3),
RPMLOG_MAIL = (2<<3),
RPMLOG_DAEMON = (3<<3),
RPMLOG_AUTH = (4<<3),
RPMLOG_SYSLOG = (5<<3),
RPMLOG_LPR = (6<<3),
RPMLOG_NEWS = (7<<3),
RPMLOG_UUCP = (8<<3),
RPMLOG_CRON = (9<<3),
RPMLOG_AUTHPRIV = (10<<3),
RPMLOG_FTP = (11<<3),
/* other codes through 15 reserved for system use */
RPMLOG_LOCAL0 = (16<<3),
RPMLOG_LOCAL1 = (17<<3),
RPMLOG_LOCAL2 = (18<<3),
RPMLOG_LOCAL3 = (19<<3),
RPMLOG_LOCAL4 = (20<<3),
RPMLOG_LOCAL5 = (21<<3),
RPMLOG_LOCAL6 = (22<<3),
RPMLOG_LOCAL7 = (23<<3),
#define RPMLOG_NFACILITIES 24
RPMLOG_ERRMSG = (((unsigned)(RPMLOG_NFACILITIES+0))<<3)
} rpmlogFac;
#define RPMLOG_FACMASK 0x03f8
#define RPMLOG_FAC(p) (((p) & RPMLOG_FACMASK) >> 3)
/*
* arguments to setlogmask.
*/
#define RPMLOG_MASK(pri) (1 << ((unsigned)(pri)))
#define RPMLOG_UPTO(pri) ((1 << (((unsigned)(pri))+1)) - 1)
/*
* Option flags for openlog.
*
* RPMLOG_ODELAY no longer does anything.
* RPMLOG_NDELAY is the inverse of what it used to be.
*/
#define RPMLOG_PID 0x01
#define RPMLOG_CONS 0x02
#define RPMLOG_ODELAY 0x04
#define RPMLOG_NDELAY 0x08
#define RPMLOG_NOWAIT 0x10
#define RPMLOG_PERROR 0x20
/* \ingroup rpmlog
* Option flags for callback return value.
*/
#define RPMLOG_DEFAULT 0x01
#define RPMLOG_EXIT 0x02
typedef struct rpmlogRec_s * rpmlogRec;
const char * rpmlogRecMessage(rpmlogRec rec);
rpmlogLvl rpmlogRecPriority(rpmlogRec rec);
typedef void * rpmlogCallbackData;
typedef int (*rpmlogCallback) (rpmlogRec rec, rpmlogCallbackData data);
int rpmlogGetNrecs(void) ;
void rpmlogPrint(FILE *f);
void rpmlogClose (void);
void rpmlogOpen (const char * ident, int option, int facility);
int rpmlogSetMask (int mask);
void rpmlog (int code, const char *fmt, ...) RPM_GNUC_PRINTF(2, 3);
const char * rpmlogMessage(void);
int rpmlogCode(void);
const char * rpmlogLevelPrefix(rpmlogLvl pri);
rpmlogCallback rpmlogSetCallback(rpmlogCallback cb, rpmlogCallbackData data);
FILE * rpmlogSetFile(FILE * fp);
#define rpmSetVerbosity(_lvl) \
((void)rpmlogSetMask( RPMLOG_UPTO( RPMLOG_PRI(_lvl))))
#define rpmIncreaseVerbosity() \
((void)rpmlogSetMask(((((unsigned)(rpmlogSetMask(0) & 0xff)) << 1) | 1)))
#define rpmDecreaseVerbosity() \
((void)rpmlogSetMask((((int)(rpmlogSetMask(0) & 0xff)) >> 1)))
#define rpmIsNormal() \
(rpmlogSetMask(0) >= RPMLOG_MASK( RPMLOG_NOTICE ))
#define rpmIsVerbose() \
(rpmlogSetMask(0) >= RPMLOG_MASK( RPMLOG_INFO ))
#define rpmIsDebug() \
(rpmlogSetMask(0) >= RPMLOG_MASK( RPMLOG_DEBUG ))
#ifdef __cplusplus
}
#endif
#endif /* H_RPMLOG */
RPMLOG_LOCAL5
Definition: rpmlog.h:68
rpmlogLevelPrefix
const char * rpmlogLevelPrefix(rpmlogLvl pri)
Return translated prefix string (if any) given log level.
rpmlogSetFile
FILE * rpmlogSetFile(FILE *fp)
Set rpmlog file handle.
RPMLOG_KERN
Definition: rpmlog.h:49
RPMLOG_ERR
Definition: rpmlog.h:33
RPMLOG_CRIT
Definition: rpmlog.h:32
RPMLOG_LOCAL2
Definition: rpmlog.h:65
rpmlogCallbackData
void * rpmlogCallbackData
Definition: rpmlog.h:123
rpmlogFac
enum rpmlogFac_e rpmlogFac
facility codes
rpmlogRec
struct rpmlogRec_s * rpmlogRec
Definition: rpmlog.h:107
rpmlogClose
void rpmlogClose(void)
Close desriptor used to write to system logger.
rpmlogMessage
void const char * rpmlogMessage(void)
Return text of last rpmError() message.
RPMLOG_INFO
Definition: rpmlog.h:36
RPMLOG_LOCAL1
Definition: rpmlog.h:64
rpmlogCallback
int(* rpmlogCallback)(rpmlogRec rec, rpmlogCallbackData data)
Definition: rpmlog.h:133
RPMLOG_SYSLOG
Definition: rpmlog.h:54
RPMLOG_AUTHPRIV
Definition: rpmlog.h:59
rpmlogSetMask
int rpmlogSetMask(int mask)
Set the log mask level.
RPMLOG_LOCAL3
Definition: rpmlog.h:66
RPMLOG_DEBUG
Definition: rpmlog.h:37
rpmlogRecPriority
rpmlogLvl rpmlogRecPriority(rpmlogRec rec)
Retrieve log priority from rpmlog record.
RPMLOG_WARNING
Definition: rpmlog.h:34
RPMLOG_FTP
Definition: rpmlog.h:60
RPMLOG_LOCAL0
Definition: rpmlog.h:63
RPMLOG_NEWS
Definition: rpmlog.h:56
rpmlogOpen
void rpmlogOpen(const char *ident, int option, int facility)
Open connection to system logger.
RPMLOG_NOTICE
Definition: rpmlog.h:35
RPM_GNUC_PRINTF
#define RPM_GNUC_PRINTF(format_idx, arg_idx)
Definition: rpmutil.h:68
RPMLOG_UUCP
Definition: rpmlog.h:57
rpmlog
void rpmlog(int code, const char *fmt,...) RPM_GNUC_PRINTF(2
Generate a log message using FMT string and option arguments.
rpmlogSetCallback
rpmlogCallback rpmlogSetCallback(rpmlogCallback cb, rpmlogCallbackData data)
Set rpmlog callback function.
rpmlogCode
int rpmlogCode(void)
Return error code from last rpmError() message.
RPMLOG_LOCAL6
Definition: rpmlog.h:69
RPMLOG_USER
Definition: rpmlog.h:50
rpmlogLvl
enum rpmlogLvl_e rpmlogLvl
RPM Log levels.
RPMLOG_LOCAL7
Definition: rpmlog.h:70
rpmlogPrint
void rpmlogPrint(FILE *f)
Print all rpmError() messages.
RPMLOG_EMERG
Definition: rpmlog.h:30
RPMLOG_LPR
Definition: rpmlog.h:55
rpmlogFac_e
rpmlogFac_e
facility codes
Definition: rpmlog.h:48
rpmlogRecMessage
const char * rpmlogRecMessage(rpmlogRec rec)
Retrieve log message string from rpmlog record.
RPMLOG_MAIL
Definition: rpmlog.h:51
RPMLOG_ALERT
Definition: rpmlog.h:31
RPMLOG_CRON
Definition: rpmlog.h:58
RPMLOG_AUTH
Definition: rpmlog.h:53
RPMLOG_DAEMON
Definition: rpmlog.h:52
RPMLOG_LOCAL4
Definition: rpmlog.h:67
rpmlogLvl_e
rpmlogLvl_e
RPM Log levels.
Definition: rpmlog.h:29
rpmlogGetNrecs
int rpmlogGetNrecs(void)
Return number of rpmError() ressages.