Try make logging more stable

This commit is contained in:
Vincent Barrilliot 2023-11-12 18:30:11 +01:00
parent b3f6e1e89e
commit 8952c193c3
3 changed files with 14 additions and 28 deletions

View file

@ -293,32 +293,19 @@ static void log_to_channel_A_low_level(const char *message) {
* Caveat:
* The total length should not exceed 512 chars.
*/
#if DEFAULT_LOG_LEVEL >= 0
static char logbuf[200]; // Should hopefully be long enough ! It's here so we don't require more stack space
#endif
void logmsg(short level, const char * message, ...) {
if (level > log_level)
return;
char buf[80]; // Should hopefully be long enough !
va_list args;
va_start(args, message);
vsprintf(buf, message, args);
vsnprintf(logbuf, sizeof(logbuf), message, args);
va_end(args);
do_log(buf);
}
void trace(const char * message, ...) {
if (LOG_TRACE > log_level)
return;
char buf[80]; // Should hopefully be long enough !
va_list args;
va_start(args, message);
vsprintf(buf, message, args);
va_end(args);
(*do_log)(buf);
do_log(logbuf);
}
/*

View file

@ -81,7 +81,7 @@ extern void log_setlevel(short level);
* message = the message to log
*/
extern void logmsg(short level, const char * message, ...);
extern void trace(const char * message, ...);
/*
* Log a message to the console
*
@ -176,14 +176,14 @@ extern void log_c(short log_level, char c);
#endif
#if DEFAULT_LOG_LEVEL >= LOG_TRACE
# define TRACE(m) trace(m)
# define TRACE1(a,b) trace(a, b)
# define TRACE2(a,b,c) trace(a, b, c)
# define TRACE3(a,b,c,d) trace(a, b, c, d)
# define TRACE4(a,b,c,d,e) trace(a, b, c, d, e)
# define TRACE5(a,b,c,d,e,f) trace(a, b, c, d, e, f)
# define TRACE6(a,b,c,d,e,f,g) trace(a, b, c, d, e, f, g)
# define TRACE7(a,b,c,d,e,f,g,h) trace(a, b, c, d, e, f, g, h)
# define TRACE(m) logmsg(LOG_TRACE, m)
# define TRACE1(a,b) logmsg(LOG_TRACE, a, b)
# define TRACE2(a,b,c) logmsg(LOG_TRACE, a, b, c)
# define TRACE3(a,b,c,d) logmsg(LOG_TRACE, a, b, c, d)
# define TRACE4(a,b,c,d,e) logmsg(LOG_TRACE, a, b, c, d, e)
# define TRACE5(a,b,c,d,e,f) logmsg(LOG_TRACE, a, b, c, d, e, f)
# define TRACE6(a,b,c,d,e,f,g) logmsg(LOG_TRACE, a, b, c, d, e, f, g)
# define TRACE7(a,b,c,d,e,f,g,h) logmsg(LOG_TRACE, a, b, c, d, e, f, g, h)
#else
# define TRACE(m)
# define TRACE1(a,b)

View file

@ -238,7 +238,6 @@ unsigned long syscall_dispatch(int32_t function, int32_t param0, int32_t param1,
/* Misc functions */
switch (function) {
case KFN_TIME_JIFFIES:
TRACE("KFN_TIME_JIFFIES");
return rtc_get_jiffies();
case KFN_TIME_SETRTC: