Export flog() function and define new log macros ERR(), WARN(), etc.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2019-11-11 18:52:00 +01:00
parent 90fb520c06
commit 53c2d0e3d9
2 changed files with 10 additions and 2 deletions

View File

@ -159,7 +159,6 @@ void wallmsg(struct filed *f, struct iovec *iov, int iovcnt);
void reapchild();
const char *cvtaddr(struct sockaddr_storage *f, int len);
const char *cvthname(struct sockaddr_storage *f, int len);
static void flog(int pri, char *fmt, ...);
void domark();
void debug_switch();
void logerror(const char *type);
@ -2008,7 +2007,7 @@ const char *cvthname(struct sockaddr_storage *f, int len)
/*
* Base function for domark(), logerror(), etc.
*/
static void flog(int pri, char *fmt, ...)
void flog(int pri, char *fmt, ...)
{
struct buf_msg buffer;
va_list ap;

View File

@ -112,6 +112,13 @@
#define NELEMS(array) (sizeof(array) / sizeof(array[0]))
#endif
/* Helper internal log macros */
#define ERR(fmt, args...) flog(LOG_SYSLOG | LOG_ERR, fmt ": %m", ##args)
#define ERRX(fmt, args...) flog(LOG_SYSLOG | LOG_ERR, fmt, ##args)
#define WARN(fmt, args...) flog(LOG_SYSLOG | LOG_WARN, fmt, ##args)
#define NOTE(fmt, args...) flog(LOG_SYSLOG | LOG_NOTICE, fmt, ##args)
#define INFO(fmt, args...) flog(LOG_SYSLOG | LOG_INFO, fmt, ##args)
/*
* Flags to logmsg().
*/
@ -215,4 +222,6 @@ struct filed {
int f_rotatesz;
};
void flog(int pri, char *fmt, ...);
#endif /* SYSKLOGD_SYSLOGD_H_ */