![]() |
Max OS 0.3
|
A class that handles logging messages to the console and files. More...
#include <logger.h>
Public Member Functions | |
| Logger () | |
| Constructs a Logger object and sets it as the active logger. | |
| void | add_log_writer (OutputStream *log_writer) |
| Adds an output stream to the logger. | |
| void | disable_log_writer (OutputStream *log_writer) |
| Prevents an output stream from being used. | |
| void | enable_log_writer (OutputStream *log_writer) |
| Lets an output stream from be used. | |
| void | enable_all_log_writers () |
| Mark all log writes as allowed to output to. | |
| void | set_log_level (LogLevel log_level) |
| Sets the log level of the logger. | |
| void | write_char (char c) final |
| Writes a character to the logger. | |
| void | printf (const char *format,...) |
| Prints a formatted string to the logger (thread safe) | |
| Logger & | operator<< (LogLevel log_level) |
| Sets the log level of the logger. | |
Static Public Member Functions | |
| static void | assert (bool condition, const char *message,...) |
| Puts the system into a panic state if the condition is false, printing the message first. | |
| static Logger * | active_logger () |
| Gets the active logger (to be used to modify the logger) | |
| static LogRecord | Out () |
| Gets the active logger. | |
| static LogRecord | ERROR () |
| Gets the active logger for error logs. | |
| static LogRecord | WARNING () |
| Gets the active logger for warnings. | |
| static LogRecord | HEADER () |
| Gets the active logger for headers. | |
| static LogRecord | INFO () |
| Gets the active logger for info logs. | |
| static LogRecord | TEST () |
| Gets the active logger for testing logs. | |
| static LogRecord | DEBUG () |
| Gets the active logger for debug logs. | |
Friends | |
| class | LogRecord |
A class that handles logging messages to the console and files.
| Logger::Logger | ( | ) |
Constructs a Logger object and sets it as the active logger.
Definition at line 25 of file logger.cpp.
|
static |
Gets the active logger (to be used to modify the logger)
Definition at line 240 of file logger.cpp.
Referenced by MaxOS::console::FramebufferConsole::finish(), MaxOS::console::FramebufferConsole::FramebufferConsole(), MaxOS::system::CPU::prepare_for_panic(), and MaxOS::processes::GlobalScheduler::print_running_header().
| void Logger::add_log_writer | ( | OutputStream * | log_writer | ) |
Adds an output stream to the logger.
| log_writer | The output stream to add |
Definition at line 44 of file logger.cpp.
References MaxOS::MAX_LOG_WRITERS.
Referenced by MaxOS::console::FramebufferConsole::FramebufferConsole(), and MaxOS::console::SerialConsole::SerialConsole().
|
static |
Puts the system into a panic state if the condition is false, printing the message first.
| condition | The condition to check if is met |
| message | The message to print if the condition fails |
| ... | The arguments to format into the string |
Definition at line 267 of file logger.cpp.
References MaxOS::system::CPU::PANIC().
|
static |
Gets the active logger for debug logs.
Definition at line 204 of file logger.cpp.
Referenced by MaxOS::processes::GlobalScheduler::add_process(), MaxOS::processes::GlobalScheduler::add_thread(), MaxOS::hardwarecommunication::AdvancedConfigurationAndPowerInterface::AdvancedConfigurationAndPowerInterface(), MaxOS::hardwarecommunication::AdvancedProgrammableInterruptController::AdvancedProgrammableInterruptController(), MaxOS::hardwarecommunication::Clock::calibrate(), MaxOS::system::CPU::check_nx(), MaxOS::system::Core::Core(), core_main(), MaxOS::console::FramebufferConsole::FramebufferConsole(), MaxOS::system::GlobalDescriptorTable::GlobalDescriptorTable(), MaxOS::system::Core::init_sse(), MaxOS::system::Core::init_tss(), MaxOS::hardwarecommunication::IOAPIC::IOAPIC(), MaxOS::system::GlobalDescriptorTable::load(), MaxOS::processes::GlobalScheduler::load_multiboot_elfs(), MaxOS::hardwarecommunication::LocalAPIC::LocalAPIC(), MaxOS::system::Multiboot::Multiboot(), MaxOS::memory::PhysicalMemoryManager::PhysicalMemoryManager(), MaxOS::memory::PhysicalMemoryManager::reserve(), MaxOS::system::Core::wake_up(), and MaxOS::processes::Process::~Process().
| void Logger::disable_log_writer | ( | OutputStream * | log_writer | ) |
Prevents an output stream from being used.
| log_writer | The output stream to stop using |
Definition at line 66 of file logger.cpp.
Referenced by MaxOS::console::FramebufferConsole::finish().
| void Logger::enable_all_log_writers | ( | ) |
Mark all log writes as allowed to output to.
Definition at line 99 of file logger.cpp.
| void Logger::enable_log_writer | ( | OutputStream * | log_writer | ) |
Lets an output stream from be used.
| log_writer | The output stream to use |
Definition at line 83 of file logger.cpp.
|
static |
Gets the active logger for error logs.
Definition at line 222 of file logger.cpp.
Referenced by MaxOS::system::SyscallManager::handle_interrupt(), MaxOS::system::CPU::PANIC(), MaxOS::system::CPU::prepare_for_panic(), MaxOS::system::CPU::print_registers(), and MaxOS::system::CPU::stack_trace().
|
static |
Gets the active logger for headers.
Definition at line 231 of file logger.cpp.
Referenced by MaxOS::console::FramebufferConsole::finish(), and kernel_main().
|
static |
Gets the active logger for info logs.
Definition at line 195 of file logger.cpp.
Referenced by MaxOS::hardwarecommunication::InterruptManager::activate(), MaxOS::hardwarecommunication::AdvancedConfigurationAndPowerInterface::AdvancedConfigurationAndPowerInterface(), MaxOS::hardwarecommunication::AdvancedProgrammableInterruptController::AdvancedProgrammableInterruptController(), MaxOS::hardwarecommunication::Clock::calibrate(), MaxOS::hardwarecommunication::Clock::Clock(), MaxOS::system::CPU::CPU(), MaxOS::console::FramebufferConsole::FramebufferConsole(), MaxOS::processes::GlobalScheduler::GlobalScheduler(), MaxOS::system::CPU::init_cores(), MaxOS::hardwarecommunication::InterruptManager::InterruptManager(), kernel_main(), MaxOS::memory::PhysicalMemoryManager::PhysicalMemoryManager(), MaxOS::system::SyscallManager::syscall_klog(), and MaxOS::system::SyscallManager::SyscallManager().
Sets the log level of the logger.
| log_level | The log level to set |
Definition at line 286 of file logger.cpp.
References set_log_level().
|
static |
Gets the active logger.
Definition at line 176 of file logger.cpp.
Referenced by MaxOS::system::CPU::PANIC(), MaxOS::system::CPU::prepare_for_panic(), and MaxOS::system::SyscallManager::syscall_klog().
| void Logger::printf | ( | const char * | format, |
| ... | |||
| ) |
Prints a formatted string to the logger (thread safe)
| format | The format string |
| ... | The arguments to format |
Definition at line 250 of file logger.cpp.
Referenced by MaxOS::processes::GlobalScheduler::print_running_header().
| void Logger::set_log_level | ( | LogLevel | log_level | ) |
Sets the log level of the logger.
| log_level | The log level to set |
Definition at line 110 of file logger.cpp.
References MaxOS::processes::GlobalScheduler::print_running_header(), and MaxOS::console::FramebufferConsole::update_progress_bar().
Referenced by MaxOS::LogRecord::LogRecord(), and operator<<().
|
static |
Gets the active logger for testing logs.
Definition at line 186 of file logger.cpp.
|
static |
Gets the active logger for warnings.
Definition at line 213 of file logger.cpp.
Referenced by MaxOS::hardwarecommunication::LocalAPIC::LocalAPIC(), and MaxOS::system::Core::wake_up().
|
final |
Writes a character to the logger.
| c | The character to write |
Definition at line 158 of file logger.cpp.
References MaxOS::MAX_LOG_LEVEL.
Referenced by MaxOS::LogRecord::operator<<().