Browse Source

Add variable args to ll_sendp

change proto
delete state occurences
dev
milang 2 years ago
parent
commit
296ecb4a96
  1. 19
      liblog.c
  2. 4
      liblog.h

19
liblog.c

@ -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)

4
liblog.h

@ -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 */

Loading…
Cancel
Save