log: systemd-style logs are handled by systemd-lib

* dropped support for irqbalance without -j option

* ./configure --with-systemd is now for choosing if you
  want compile irqbalance with systemd-lib oe without

Signed-off-by: Andrej Manduch <amanduch@gmail.com>
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
This commit is contained in:
Andrej Manduch 2015-03-03 12:51:46 -05:00 committed by Neil Horman
parent 032b8c814f
commit f498717bd8
3 changed files with 28 additions and 22 deletions

View file

@ -31,12 +31,15 @@ AC_C_INLINE
AM_PROG_CC_C_O AM_PROG_CC_C_O
AC_ARG_WITH([systemd], AC_ARG_WITH([systemd],
[ AS_HELP_STRING([--with-systemd],[Add systemd logging support])], [ AS_HELP_STRING([--with-systemd],[Add systemd-lib support])]
) )
AS_IF( AS_IF(
[test "x$with_systemd" = xyes], [test "x$with_systemd" = xyes], [
[AC_DEFINE(HAVE_SYSTEMD, 1, [systemd support])] PKG_CHECK_MODULES([SYSTEMD], [libsystemd-journal], [journal_lib=yes])
) AC_DEFINE(HAVE_LIBSYSTEMD, 1, [systemd support])
AC_CHECK_LIB([systemd], [sd_journal_print_with_location])
AC_CHECK_LIB([systemd], [sd_journal_print])
])
AC_ARG_WITH([glib2], AC_ARG_WITH([glib2],
[AS_HELP_STRING([--without-glib2], [AS_HELP_STRING([--without-glib2],

View file

@ -85,9 +85,7 @@ struct option lopts[] = {
{"deepestcache", 1, NULL, 'c'}, {"deepestcache", 1, NULL, 'c'},
{"policyscript", 1, NULL, 'l'}, {"policyscript", 1, NULL, 'l'},
{"pid", 1, NULL, 's'}, {"pid", 1, NULL, 's'},
#ifdef HAVE_SYSTEMD
{"journal", 0, NULL, 'j'}, {"journal", 0, NULL, 'j'},
#endif /* HAVE_SYSTEMD */
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
@ -178,13 +176,10 @@ static void parse_command_line(int argc, char **argv)
case 's': case 's':
pidfile = optarg; pidfile = optarg;
break; break;
#ifdef HAVE_SYSTEMD
case 'j': case 'j':
journal_logging=1; journal_logging=1;
foreground_mode=1; foreground_mode=1;
debug_mode=1;
break; break;
#endif /* HAVE_SYSTEMD */
} }
} }
} }
@ -270,13 +265,10 @@ int main(int argc, char** argv)
foreground_mode=1; foreground_mode=1;
if (argc>1 && strstr(argv[1],"--oneshot")) if (argc>1 && strstr(argv[1],"--oneshot"))
one_shot_mode=1; one_shot_mode=1;
# ifdef HAVE_SYSTEMD
if (argc>1 && strstr(argv[1],"--journal")) { if (argc>1 && strstr(argv[1],"--journal")) {
journal_logging=1; journal_logging=1;
foreground_mode=1; foreground_mode=1;
debug_mode=1;
} }
# endif /* HAVE_SYSTEMD */
#endif /* HAVE_GETOPT_LONG */ #endif /* HAVE_GETOPT_LONG */
/* /*

View file

@ -12,12 +12,17 @@
#include <limits.h> #include <limits.h>
#include "types.h" #include "types.h"
#include "config.h"
#ifdef HAVE_NUMA_H #ifdef HAVE_NUMA_H
#include <numa.h> #include <numa.h>
#else #else
#define numa_available() -1 #define numa_available() -1
#endif #endif
#ifdef HAVE_LIBSYSTEMD
#include <systemd/sd-journal.h>
#endif
extern int package_count; extern int package_count;
extern int cache_domain_count; extern int cache_domain_count;
extern int core_count; extern int core_count;
@ -137,9 +142,22 @@ static inline void for_each_object(GList *list, void (*cb)(struct topo_obj *obj,
extern char * log_indent; extern char * log_indent;
extern unsigned int log_mask; extern unsigned int log_mask;
#ifdef HAVE_SYSTEMD #ifdef HAVE_LIBSYSTEMD
#define log(mask, lvl, fmt, args...) do { \ #define log(mask, lvl, fmt, args...) do { \
if (journal_logging) { \ if (journal_logging) { \
sd_journal_print(lvl, fmt, ##args); \
if (log_mask & mask & TO_CONSOLE) \
printf(fmt, ##args); \
} else { \
if (log_mask & mask & TO_SYSLOG) \
syslog(lvl, fmt, ##args); \
if (log_mask & mask & TO_CONSOLE) \
printf(fmt, ##args); \
} \
}while(0)
#else /* ! HAVE_LIBSYSTEMD */
#define log(mask, lvl, fmt, args...) do { \
if (journal_logging) { \
printf("<%d>", lvl); \ printf("<%d>", lvl); \
printf(fmt, ##args); \ printf(fmt, ##args); \
} else { \ } else { \
@ -149,14 +167,7 @@ extern unsigned int log_mask;
printf(fmt, ##args); \ printf(fmt, ##args); \
} \ } \
}while(0) }while(0)
#else /* ! HAVE_SYSTEMD */ #endif /* HAVE_LIBSYSTEMD */
#define log(mask, lvl, fmt, args...) do {\
if (log_mask & mask & TO_SYSLOG)\
syslog(lvl, fmt, ##args);\
if (log_mask & mask & TO_CONSOLE)\
printf(fmt, ##args);\
}while(0)
#endif /* HAVE_SYSTEMD */
#endif /* __INCLUDE_GUARD_IRQBALANCE_H_ */ #endif /* __INCLUDE_GUARD_IRQBALANCE_H_ */