Add the ability to toggle loglevels in KernelLog
This commit is contained in:
parent
18140a55ec
commit
9d19765b0e
@ -14,6 +14,7 @@ namespace KernelLog
|
|||||||
{
|
{
|
||||||
void log(const char* function, LogLevel level, const char* message, ...) PRINTF_LIKE(3, 4);
|
void log(const char* function, LogLevel level, const char* message, ...) PRINTF_LIKE(3, 4);
|
||||||
void logln(const char* function, LogLevel level, const char* message, ...) PRINTF_LIKE(3, 4);
|
void logln(const char* function, LogLevel level, const char* message, ...) PRINTF_LIKE(3, 4);
|
||||||
|
void toggle_log_level(LogLevel level);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef MODULE
|
#ifndef MODULE
|
||||||
|
@ -4,8 +4,11 @@
|
|||||||
#include "std/stdio.h"
|
#include "std/stdio.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
static int level_mask = 15;
|
||||||
|
|
||||||
void KernelLog::log(const char* function, LogLevel level, const char* message, ...)
|
void KernelLog::log(const char* function, LogLevel level, const char* message, ...)
|
||||||
{
|
{
|
||||||
|
if (!(level_mask & (1 << (int)level))) return;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, message);
|
va_start(ap, message);
|
||||||
Serial::reset_color();
|
Serial::reset_color();
|
||||||
@ -25,6 +28,7 @@ void KernelLog::log(const char* function, LogLevel level, const char* message, .
|
|||||||
|
|
||||||
void KernelLog::logln(const char* function, LogLevel level, const char* message, ...)
|
void KernelLog::logln(const char* function, LogLevel level, const char* message, ...)
|
||||||
{
|
{
|
||||||
|
if (!(level_mask & (1 << (int)level))) return;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, message);
|
va_start(ap, message);
|
||||||
Serial::reset_color();
|
Serial::reset_color();
|
||||||
@ -41,4 +45,9 @@ void KernelLog::logln(const char* function, LogLevel level, const char* message,
|
|||||||
Serial::reset_color();
|
Serial::reset_color();
|
||||||
Serial::print("\n");
|
Serial::print("\n");
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KernelLog::toggle_log_level(LogLevel level)
|
||||||
|
{
|
||||||
|
level_mask ^= (1 << (int)level);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user