[irqbalance] Re: [RFC][PATCH 4/5] log: sane version of systemd-journal loglevels

  • From: Neil Horman <nhorman@xxxxxxxxxxxxx>
  • To: irqbalance@xxxxxxxxxxxxx
  • Date: Tue, 3 Mar 2015 13:24:18 -0500

On Tue, Mar 03, 2015 at 01:06:10PM -0500, Andrej Manduch wrote:
> I dropped support of partial lines when logging but
> log macro now looks way mor nicier.
> 
> Signed-off-by: Andrej Manduch <amanduch@xxxxxxxxx>
This patch doesn't seem to apply against the upstream head.  Can you respin it
please?

Thanks!
Neil

> ---
>  cputree.c    |  9 ++++++---
>  irqbalance.c |  9 ---------
>  irqbalance.h | 12 ++----------
>  3 files changed, 8 insertions(+), 22 deletions(-)
> 
> diff --git a/cputree.c b/cputree.c
> index df40d1a..8b8cf5e 100644
> --- a/cputree.c
> +++ b/cputree.c
> @@ -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);
>  }
>  
> diff --git a/irqbalance.c b/irqbalance.c
> index 60f5411..f25e9a9 100644
> --- a/irqbalance.c
> +++ b/irqbalance.c
> @@ -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 */
> diff --git a/irqbalance.h b/irqbalance.h
> index c301427..98d2193 100644
> --- a/irqbalance.h
> +++ b/irqbalance.h
> @@ -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);                               
> \
> -- 
> 2.1.0
> 
> 
> 

Other related posts: