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:
parent
032b8c814f
commit
f498717bd8
11
configure.ac
11
configure.ac
|
@ -31,12 +31,15 @@ AC_C_INLINE
|
|||
AM_PROG_CC_C_O
|
||||
|
||||
AC_ARG_WITH([systemd],
|
||||
[ AS_HELP_STRING([--with-systemd],[Add systemd logging support])],
|
||||
[ AS_HELP_STRING([--with-systemd],[Add systemd-lib support])]
|
||||
)
|
||||
AS_IF(
|
||||
[test "x$with_systemd" = xyes],
|
||||
[AC_DEFINE(HAVE_SYSTEMD, 1, [systemd support])]
|
||||
)
|
||||
[test "x$with_systemd" = xyes], [
|
||||
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],
|
||||
[AS_HELP_STRING([--without-glib2],
|
||||
|
|
|
@ -85,9 +85,7 @@ struct option lopts[] = {
|
|||
{"deepestcache", 1, NULL, 'c'},
|
||||
{"policyscript", 1, NULL, 'l'},
|
||||
{"pid", 1, NULL, 's'},
|
||||
#ifdef HAVE_SYSTEMD
|
||||
{"journal", 0, NULL, 'j'},
|
||||
#endif /* HAVE_SYSTEMD */
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
@ -178,13 +176,10 @@ static void parse_command_line(int argc, char **argv)
|
|||
case 's':
|
||||
pidfile = optarg;
|
||||
break;
|
||||
#ifdef HAVE_SYSTEMD
|
||||
case 'j':
|
||||
journal_logging=1;
|
||||
foreground_mode=1;
|
||||
debug_mode=1;
|
||||
break;
|
||||
#endif /* HAVE_SYSTEMD */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -270,13 +265,10 @@ int main(int argc, char** argv)
|
|||
foreground_mode=1;
|
||||
if (argc>1 && strstr(argv[1],"--oneshot"))
|
||||
one_shot_mode=1;
|
||||
# ifdef HAVE_SYSTEMD
|
||||
if (argc>1 && strstr(argv[1],"--journal")) {
|
||||
journal_logging=1;
|
||||
foreground_mode=1;
|
||||
debug_mode=1;
|
||||
}
|
||||
# endif /* HAVE_SYSTEMD */
|
||||
#endif /* HAVE_GETOPT_LONG */
|
||||
|
||||
/*
|
||||
|
|
29
irqbalance.h
29
irqbalance.h
|
@ -12,12 +12,17 @@
|
|||
#include <limits.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "config.h"
|
||||
#ifdef HAVE_NUMA_H
|
||||
#include <numa.h>
|
||||
#else
|
||||
#define numa_available() -1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBSYSTEMD
|
||||
#include <systemd/sd-journal.h>
|
||||
#endif
|
||||
|
||||
extern int package_count;
|
||||
extern int cache_domain_count;
|
||||
extern int core_count;
|
||||
|
@ -137,7 +142,20 @@ static inline void for_each_object(GList *list, void (*cb)(struct topo_obj *obj,
|
|||
|
||||
extern char * log_indent;
|
||||
extern unsigned int log_mask;
|
||||
#ifdef HAVE_SYSTEMD
|
||||
#ifdef HAVE_LIBSYSTEMD
|
||||
#define log(mask, lvl, fmt, args...) do { \
|
||||
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); \
|
||||
|
@ -149,14 +167,7 @@ extern unsigned int log_mask;
|
|||
printf(fmt, ##args); \
|
||||
} \
|
||||
}while(0)
|
||||
#else /* ! HAVE_SYSTEMD */
|
||||
#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 /* HAVE_LIBSYSTEMD */
|
||||
|
||||
#endif /* __INCLUDE_GUARD_IRQBALANCE_H_ */
|
||||
|
||||
|
|
Loading…
Reference in a new issue