Add variable args to ll_sendp

change proto
delete state occurences
This commit is contained in:
milang 2020-01-03 19:31:35 +01:00
parent f930845f4f
commit 296ecb4a96
2 changed files with 17 additions and 6 deletions

View File

@ -197,10 +197,21 @@ void ll_send(const char * txt)
}
}
void ll_sendp(char const *s , log_level_t l)
void ll_sendp(log_level_t p, char const *format, ...)
{
if (l>=priority)
ll_send(s);
if (p>=priority)
{
char str[512];
va_list args;
va_start(args, format);
vsnprintf(str, 512, format, args);
va_end(args);
ll_send(str);
}
}
static void show_line(const log_line* l, int y)
@ -269,7 +280,7 @@ void ll_pause()
GNORETURN void ll_panic(uint32_t code)
{
char str[10];
sprintf(str, "\nException !\n>> LogState=%d\n>> ErrCode=%d", state, code);
sprintf(str, "\nException !\n>> ErrCode=%d", state, code);
ll_set_state(1);
ll_send(str);
while (1)

View File

@ -54,11 +54,11 @@ log_level_t ll_set_level(void);
It will be ignored only if the log is disabled or set to quiet (same thing) */
void ll_send(char const *);
/* ll_sendp(char const *, log_level_t):
/* ll_sendp(log_level_t priority, char const * format, ...):
Print text
This function sends the message with a custom priority
Note: A message sent with `LEVEL_QUIET` counts as a `LEVEL_MAX` log */
void ll_sendp(char const *, log_level_t);
void ll_sendp(log_level_t p, char const *format, ...);
/* ll_clear():
Reset log */