Commit 00b7c44e authored by Stratos Psomadakis's avatar Stratos Psomadakis

Replace printf with XSEGLOG2

parent 88fd78df
......@@ -42,7 +42,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define FMTARG(fmt, arg, format, ...) fmt format "%s", arg, ## __VA_ARGS__
#define XSEGLOG2(__ctx, __level, ...) \
#define XSEGLOG2(__level, ...) \
do { \
__xseg_log2(__level, FMTARG("%s: ", __func__, ## __VA_ARGS__ ,"")); \
} while(0)
......
......@@ -64,7 +64,7 @@ static long posix_allocate(const char *name, uint64_t size)
if (r != 1) {
err_no = errno;
close(fd);
XSEGLOG2(w, "Failed to set segment size: %s\n",
XSEGLOG2(W, "Failed to set segment size: %s\n",
strerror_r(errno, errbuf, ERRSIZE));
ret = r;
goto exit;
......@@ -126,7 +126,8 @@ static void posix_unmap(void *ptr, uint64_t size)
static void handler(int signum)
{
static unsigned long counter;
printf("%lu: signal %d: this shouldn't have happened.\n", counter, signum);
XSEGLOG2(E, "%lu: signal %d: this shouldn't have happened.\n", counter,
signum);
counter ++;
}
......
......@@ -115,7 +115,8 @@ static void pthread_unmap(void *ptr, uint64_t size)
static void handler(int signum)
{
static unsigned long counter;
printf("%lu: signal %d: this shouldn't have happened.\n", counter, signum);
XSEGLOG2(E, "%lu: signal %d: this shouldn't have happened.\n", counter,
signum);
counter ++;
}
......
......@@ -100,11 +100,11 @@ void __get_current_time(struct timeval *tv) {
gettimeofday(tv, NULL);
}
static inline int syslog_level(enum log_level level) {
static inline int get_syslog_level(enum log_level level) {
int syslog_level;
switch (level) {
case E: syslog_level = LOG_ERROR; break;
case E: syslog_level = LOG_ERR; break;
case W: syslog_level = LOG_WARNING; break;
case I: syslog_level = LOG_INFO; break;
case D: syslog_level = LOG_DEBUG; break;
......@@ -116,12 +116,10 @@ static inline int syslog_level(enum log_level level) {
static void __init_logctx(char *peer_name, enum log_level level)
{
int syslog_level;
openlog(peer_name, LOG_PID | LOG_CONS, LOG_LOCAL0);
/* FIXME: LOG_UPTO portability */
setlogmask(LOG_UPTO(syslog_level(level)));
setlogmask(LOG_UPTO(get_syslog_level(level)));
return;
}
......@@ -133,7 +131,7 @@ void __xseg_log2(enum log_level level, char *fmt, ...)
va_list ap;
va_start(ap, fmt);
vsyslog(syslog_level(level), fmt, ap);
vsyslog(get_syslog_level(level), fmt, ap);
va_end(ap);
return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment