MAKE LOG FUNCTIONS VARIADIC!!
This commit is contained in:
parent
1820286d8b
commit
e936a143d3
@ -7,17 +7,23 @@ enum class LogLevel
|
||||
ERROR
|
||||
};
|
||||
|
||||
#define PRINTF_LIKE(n, m) __attribute__((format(printf, n, m)))
|
||||
|
||||
namespace KernelLog
|
||||
{
|
||||
void log(const char* function, const char* message, LogLevel level);
|
||||
void logln(const char* function, const char* message, LogLevel level);
|
||||
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);
|
||||
}
|
||||
|
||||
#define kinternalcall(func, function, message, level) KernelLog::func(function, message, level)
|
||||
#ifndef MODULE
|
||||
#define kcommonlog(function, level, ...) KernelLog::function(__FUNCTION__, level, __VA_ARGS__)
|
||||
#else
|
||||
#define kcommonlog(function, level, ...) KernelLog::function(MODULE, level, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#define kinfo(message) kinternalcall(log, __FUNCTION__, message, LogLevel::INFO)
|
||||
#define kinfoln(message) kinternalcall(logln, __FUNCTION__, message, LogLevel::INFO)
|
||||
#define kwarn(message) kinternalcall(log, __FUNCTION__, message, LogLevel::WARN)
|
||||
#define kwarnln(message) kinternalcall(logln, __FUNCTION__, message, LogLevel::WARN)
|
||||
#define kerror(message) kinternalcall(log, __FUNCTION__, message, LogLevel::ERROR)
|
||||
#define kerrorln(message) kinternalcall(logln, __FUNCTION__, message, LogLevel::ERROR)
|
||||
#define kinfo(...) kcommonlog(log, LogLevel::INFO, __VA_ARGS__)
|
||||
#define kinfoln(...) kcommonlog(logln, LogLevel::INFO, __VA_ARGS__)
|
||||
#define kwarn(...) kcommonlog(log, LogLevel::WARN, __VA_ARGS__)
|
||||
#define kwarnln(...) kcommonlog(logln, LogLevel::WARN, __VA_ARGS__)
|
||||
#define kerror(...) kcommonlog(log, LogLevel::ERROR, __VA_ARGS__)
|
||||
#define kerrorln(...) kcommonlog(logln, LogLevel::ERROR, __VA_ARGS__)
|
@ -4,7 +4,7 @@
|
||||
|
||||
bool __call_assert_fail(const char* function, const char* message)
|
||||
{
|
||||
KernelLog::logln(function, message, LogLevel::ERROR);
|
||||
KernelLog::logln(function, LogLevel::ERROR, "%s", message);
|
||||
hang();
|
||||
return true;
|
||||
}
|
@ -1,9 +1,12 @@
|
||||
#include "log/Log.h"
|
||||
#include "io/Serial.h"
|
||||
#include "std/stdio.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
void KernelLog::log(const char* function, const char* message, LogLevel level)
|
||||
void KernelLog::log(const char* function, LogLevel level, const char* message, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, message);
|
||||
Serial::reset_color();
|
||||
Serial::print(function);
|
||||
Serial::print(": ");
|
||||
@ -13,12 +16,26 @@ void KernelLog::log(const char* function, const char* message, LogLevel level)
|
||||
case LogLevel::ERROR: Serial::set_color(Color::Red); break;
|
||||
default: break;
|
||||
}
|
||||
printf("%s", message);
|
||||
vprintf(message, ap);
|
||||
Serial::reset_color();
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void KernelLog::logln(const char* function, const char* message, LogLevel level)
|
||||
void KernelLog::logln(const char* function, LogLevel level, const char* message, ...)
|
||||
{
|
||||
log(function, message, level);
|
||||
va_list ap;
|
||||
va_start(ap, message);
|
||||
Serial::reset_color();
|
||||
Serial::print(function);
|
||||
Serial::print(": ");
|
||||
switch (level)
|
||||
{
|
||||
case LogLevel::WARN: Serial::set_color(Color::Yellow); break;
|
||||
case LogLevel::ERROR: Serial::set_color(Color::Red); break;
|
||||
default: break;
|
||||
}
|
||||
vprintf(message, ap);
|
||||
Serial::reset_color();
|
||||
Serial::print("\n");
|
||||
va_end(ap);
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
#define MODULE "main"
|
||||
|
||||
#include "acpi/RSDT.h"
|
||||
#include "assert.h"
|
||||
#include "bootboot.h"
|
||||
@ -92,7 +94,7 @@ extern "C" void _start()
|
||||
isXSDT = true;
|
||||
if (ACPI::ValidateSDTHeader(rootSDT))
|
||||
{
|
||||
kinfoln(isXSDT ? "XSDT is valid" : "RSDT is valid");
|
||||
kinfoln("%s: 0x%lx", isXSDT ? "XSDT is valid" : "RSDT is valid", (uint64_t)rootSDT);
|
||||
Debug::DebugStatus::the()->PassBootStage(Color{0x33, 0x33, 0x00, 0xFF});
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user