log: sane version of systemd-journal loglevels

I dropped support of partial lines when logging but
log macro now looks way mor nicier.

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:45 -05:00 committed by Neil Horman
parent 03701f91bc
commit 032b8c814f
3 changed files with 8 additions and 22 deletions

View File

@ -294,10 +294,13 @@ static void dump_irq(struct irq_info *info, void *data)
{
int spaces = (long int)data;
int i;
char indent_char[2] = {log_indent[0], '\0'};
char * indent = malloc (sizeof(char) * (spaces + 1));
for (i=0; i<spaces; i++) log(TO_CONSOLE, LOG_INFO, indent_char);
log(TO_CONSOLE, LOG_INFO, "Interrupt %i node_num is %d (%s/%u) \n",
for ( i = 0; i < spaces; i++ )
indent[i] = log_indent[0];
indent[i] = '\0';
log(TO_CONSOLE, LOG_INFO, "%sInterrupt %i node_num is %d (%s/%u) \n", indent,
info->irq, irq_numa_node(info)->number, classes[info->class], (unsigned int)info->load);
}

View File

@ -59,11 +59,6 @@ char *banscript = NULL;
char *polscript = NULL;
long HZ;
#ifdef HAVE_SYSTEMD
char *line_buffer_7ee22e61_f183;
char *log_buffer_4c93_8665;
#endif /* HAVE_SYSTEMD */
static void sleep_approx(int seconds)
{
struct timespec ts;
@ -264,10 +259,6 @@ int main(int argc, char** argv)
sigaddset(&sigset,SIGUSR1);
sigaddset(&sigset,SIGUSR2);
sigprocmask(SIG_BLOCK, &sigset, &old_sigset);
#ifdef HAVE_SYSTEMD
line_buffer_7ee22e61_f183 = malloc(sizeof(char) * 2048);
log_buffer_4c93_8665 = malloc(sizeof(char) * 2048);
#endif /* HAVE_SYSTEMD */
#ifdef HAVE_GETOPT_LONG
parse_command_line(argc, argv);
#else /* ! HAVE_GETOPT_LONG */

View File

@ -138,18 +138,10 @@ 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
extern char *line_buffer_7ee22e61_f183;
extern char *log_buffer_4c93_8665;
#define log(mask, lvl, fmt, args...) do { \
if (journal_logging) { \
sprintf(log_buffer_4c93_8665,fmt, ##args); \
strcat(line_buffer_7ee22e61_f183, log_buffer_4c93_8665); \
if (line_buffer_7ee22e61_f183[strlen(line_buffer_7ee22e61_f183)-1]\
== '\n' || strlen(line_buffer_7ee22e61_f183) > 256 ) { \
printf("<%d>%s", lvl, line_buffer_7ee22e61_f183); \
line_buffer_7ee22e61_f183[0] = '\0'; \
line_buffer_7ee22e61_f183[0] = '\0'; \
} \
printf("<%d>", lvl); \
printf(fmt, ##args); \
} else { \
if (log_mask & mask & TO_SYSLOG) \
syslog(lvl, fmt, ##args); \