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