Move kernel over to new logger

This commit is contained in:
Justin C. Miller
2019-03-17 15:03:30 -07:00
parent c592f5f537
commit 39524b2b9f
4 changed files with 34 additions and 152 deletions

View File

@@ -1,52 +1,16 @@
#pragma once
#include <stdarg.h>
#include <stdint.h>
class console;
#include "kutil/logger.h"
namespace log = kutil::log;
enum class logs
{
boot,
memory,
apic,
device,
driver,
fs,
task,
paging,
namespace logs {
max
};
#define LOG(name, lvl) extern log::area_t name;
#include "log_areas.inc"
#undef LOG
void init();
class log
{
public:
enum class level {debug, info, warn, error, fatal, max};
} // namespace logs
static void init(console *cons);
static void enable(logs type, level at_level);
template <level L>
static void trylog(logs area, const char *fmt, ...);
using trylog_p = void (*)(logs area, const char *fmt, ...);
static const trylog_p debug;
static const trylog_p info;
static const trylog_p warn;
static const trylog_p error;
static const trylog_p fatal;
private:
void output(level severity, logs area, const char *fmt, va_list args);
/// Bitmasks for what categories are enabled. fatal is
/// always enabled, so leave it out.
uint64_t m_enabled[static_cast<uint64_t>(level::max) - 1];
console *m_cons;
log();
log(console *cons);
static log s_log;
};