12#include <common/version.h>
17using namespace MaxOS::common;
18using namespace MaxOS::drivers::console;
19using namespace MaxOS::processes;
20using namespace MaxOS::system;
29 s_active_logger =
this;
32 s_progress_total = 22;
37Logger::~Logger() =
default;
51 m_log_writers[m_log_writer_count] =
log_writer;
52 m_log_writers_enabled[m_log_writer_count] =
true;
56 *
this << LogLevel::INFO <<
"Logger setup: " << m_log_writer_count <<
"\n";
69 if (m_log_writer_count == 0)
73 for (
int i = 0; i < m_log_writer_count; i++)
75 m_log_writers_enabled[i] =
false;
97 case LogLevel::HEADER:
98 *
this <<
ANSI_COLOURS[ANSIColour::FG_Blue] <<
"[ BOOT ] ";
109 case LogLevel::DEBUG:
113 case LogLevel::WARNING:
117 case LogLevel::ERROR:
138 for (
int i = 0; i < m_log_writer_count; i++)
139 if (m_log_writers_enabled[i])
161 s_active_logger->set_log_level(LogLevel::HEADER);
173 s_active_logger->set_log_level(LogLevel::INFO);
184 s_active_logger->set_log_level(LogLevel::TEST);
195 s_active_logger->set_log_level(LogLevel::DEBUG);
207 s_active_logger->set_log_level(LogLevel::WARNING);
218 s_active_logger->set_log_level(LogLevel::ERROR);
229 return s_active_logger;
A class that handles logging messages to the console and files.
static Logger TEST()
Gets active logger set to test level.
static Logger DEBUG()
Gets active logger set to DEBUG level.
static Logger & Out()
Gets the active logger.
void printf(const char *format,...)
Prints a formatted string to the logger.
static Logger * active_logger()
Gets the active logger (to be used to modify the logger)
void disable_log_writer(OutputStream *log_writer)
Removes an output stream from the logger.
static Logger WARNING()
Gets active logger set to WARNING level.
void add_log_writer(OutputStream *log_writer)
Adds an output stream to the logger.
static Logger INFO()
Gets active logger set to info level.
void write_char(char c) final
Writes a character to the logger.
static Logger ERROR()
Gets active logger set to ERROR level.
Logger()
Constructs a Logger object and sets it as the active logger.
void set_log_level(LogLevel log_level)
Sets the log level of the logger.
static Logger HEADER()
Gets active logger set to task level.
static void ASSERT(bool condition, const char *message,...)
Puts the system into a panic state if the condition is false, printing the message first.
Logger & operator<<(LogLevel log_level)
Sets the log level of the logger.
static String formatted(char const *format,...)
Creates a formated string. s = string, x = hex, d = decimal.
A stream that strings can be written to.
void write(string string_to_write) override
Writes a string to the output stream.
virtual void write_char(char char_to_write)
Writes a character to the output stream.
Stores the left, top, width and height of a rectangle.
static void update_progress_bar(uint8_t percentage)
Updates the progress bar.
static void print_running_header()
Print the header for the running processes in the form ({name}:t{tid}c{core})
static void PANIC(const char *message, cpu_status_t *status=nullptr)
Puts the CPU into a panic state and halts it. Dumps the stack trace and registers.
const char *const ANSI_COLOURS[]
ANSI Colour Codes.
Defines Central Processing Unit (CPU) structures and functions for managing CPU state and features.
Defines a Logger class for logging messages with different severity levels to multiple output streams...
LogLevel
Priority levels for logging messages. Different levels may be used to filter messages based on their ...
constexpr LogLevel MAX_LOG_LEVEL
The maximum log level for this build (messages above this level will not be logged)
constexpr uint8_t MAX_LOG_WRITERS
The maximum number of log writers that can be added to the logger.
Defines a GlobalScheduler and Scheduler for managing processes and threads.
Defines the VESABootConsole driver for handling console output during boot using an VESA framebuffer.