Commit feb5ed39 authored by Alessandro Rubini's avatar Alessandro Rubini

diag.c: honor DIAG_PUTS if provided

if the user passes "-DDIAG_PUTS=sth~ in USER_CFLAGS at build time, al
diagnostic messages are directed to this special puts (through sprintf
to a local buffer) instead of going to the normal printf (and thus the
default puts).

This is going to be used by wrpc-sw, to leave the default output channel
clean for the user shell.

Unfortunately, frame dumps cannot go to this special puts, as
lib/dump-funcs.c just call printf and I don't know how to fix that
without a massive change in the code.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 26ade897
......@@ -22,10 +22,32 @@ void __pp_diag(struct pp_instance *ppi, enum pp_diag_things th,
if (!__PP_DIAG_ALLOW(ppi, th, level))
return;
#ifdef DIAG_PUTS
/*
* We allow to divert diagnostic messages to a different
* channel. This is done in wrpc-sw, for example. There, we
* have a FIFO buffer to this aim. This allows running the
* wrpc shell on the only physical uart we have.
*/
{
static char buf[128];
extern int DIAG_PUTS(const char *s);
pp_sprintf(buf, "%s-%i-%s: ",
thing_name[th], level, ppi->iface_name);
DIAG_PUTS(buf);
va_start(args, fmt);
pp_vsprintf(buf, fmt, args);
va_end(args);
DIAG_PUTS(buf);
}
#else
/* Use the normal output channel for diagnostics */
pp_printf("%s-%i-%s: ", thing_name[th], level, ppi->iface_name);
va_start(args, fmt);
pp_vprintf(fmt, args);
va_end(args);
#endif
}
unsigned long pp_diag_parse(char *diaglevel)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment