Luna/kernel/include/log/Log.h

29 lines
966 B
C
Raw Normal View History

2022-09-05 14:13:51 +00:00
#pragma once
enum class LogLevel
{
INFO,
WARN,
ERROR
};
2022-09-07 13:02:23 +00:00
#define PRINTF_LIKE(n, m) __attribute__((format(printf, n, m)))
2022-09-05 14:13:51 +00:00
namespace KernelLog
{
2022-09-07 13:02:23 +00:00
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);
2022-09-05 14:13:51 +00:00
}
2022-09-07 13:02:23 +00:00
#ifndef MODULE
#define kcommonlog(function, level, ...) KernelLog::function(__FUNCTION__, level, __VA_ARGS__)
#else
#define kcommonlog(function, level, ...) KernelLog::function(MODULE, level, __VA_ARGS__)
#endif
2022-09-05 14:13:51 +00:00
2022-09-07 13:02:23 +00:00
#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__)