Skip to content

Commit

Permalink
log: Add logbuff_printf function
Browse files Browse the repository at this point in the history
Provide a general printf style function for log messages

Signed-off-by: Sean Hudson <sean_hudson@mentor.com>
  • Loading branch information
Sean Hudson committed Nov 11, 2015
1 parent c5e6444 commit dadc805
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions common/cmd_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static void logbuff_puts(struct stdio_dev *dev, const char *s);
static int logbuff_printk(const char *line);

static char buf[1024];
static char buf2[1024];

/* This combination will not print messages with the default loglevel */
static unsigned console_loglevel = 3;
Expand Down Expand Up @@ -300,3 +301,13 @@ static int logbuff_printk(const char *line)
}
return i;
}

void logbuff_printf(const char *fmt, ...)
{
va_list args;

va_start(args, fmt);
vsnprintf(buf2, sizeof(buf2), fmt, args);
va_end(args);
logbuff_printk(buf2);
}
1 change: 1 addition & 0 deletions include/logbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ void logbuff_init_ptrs(void);
void logbuff_log(char *msg);
void logbuff_reset(void);
unsigned long logbuffer_base(void);
void logbuff_printf(const char *fmt, ...);

#endif /* CONFIG_LOGBUFFER */

Expand Down

0 comments on commit dadc805

Please sign in to comment.