![]() |
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) |
| Removes an output stream from the logger. | |
| 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. | |
| Logger & | operator<< (LogLevel log_level) |
| Sets the log level of the logger. | |
Public Member Functions inherited from MaxOS::common::OutputStream | |
| OutputStream () | |
| Constructs an OutputStream object that uses strings as the underlying data type. | |
| virtual void | line_feed () |
| Writes a newline to the output stream. | |
| virtual void | carriage_return () |
| Writes a carriage return to the output stream. | |
| virtual void | clear () |
| Clears the output stream. | |
| void | write (string string_to_write) override |
| Writes a string to the output stream. | |
| void | write (const char *string_to_write) |
| Writes a string to the output stream. | |
| virtual void | write_int (int int_to_write) |
| Writes an integer to the output stream. | |
| virtual void | write_hex (uint64_t hex_to_write) |
| Writes a hex to the output stream. | |
| OutputStream & | operator<< (string string_to_write) override |
| Writes a string to the output stream. | |
| OutputStream & | operator<< (const char *string_to_write) |
| Writes a string to the output stream. | |
| OutputStream & | operator<< (int int_to_write) |
| Writes a integer to the output stream. | |
| OutputStream & | operator<< (uint64_t hex_to_write) |
| Writes a hexadecimal to the output stream. | |
| OutputStream & | operator<< (char char_to_write) |
| Writes a character to the output stream. | |
Public Member Functions inherited from MaxOS::common::GenericOutputStream< string > | |
| GenericOutputStream () | |
| __________________________________________Templates__________________________________________________/// | |
| ~GenericOutputStream () | |
| Destructor of the GenericOutputStream class. | |
| void | on_stream_read (string) override |
| Writes the date that was read from the input stream to the output stream. | |
| void | on_end_of_stream (GenericInputStream< string > *) override |
| Close the stream and remove it from the list of streams when the end of the stream is reached. | |
| virtual void | write (string) |
| write an element to the stream. | |
| virtual void | close () |
| Close the stream. | |
| virtual GenericOutputStream< string > & | operator<< (string) |
| Overload the << operator to write an element to the stream. | |
Public Member Functions inherited from MaxOS::common::InputStreamProcessor< Type, ProcessorType > | |
| InputStreamProcessor () | |
| Creates a new InputStreamProcessor. | |
| InputStreamProcessor (InputStreamEventHandler< ProcessorType > *generic_stream_event_handler) | |
| Creates a new InputStreamProcessor. | |
| ~InputStreamProcessor () | |
| Destroys the InputStreamProcessor. | |
| void | on_end_of_stream (GenericInputStream< Type > *stream) override |
| Called when a stream has finished. Passes the event on to the handlers and then removes the stream from the array of streams. | |
Public Member Functions inherited from MaxOS::common::InputStreamEventHandler< Type > | |
| InputStreamEventHandler () | |
| _______________________________________________TEMPLATES_________________________________________________________________/// | |
| ~InputStreamEventHandler () | |
| Destroys the InputStreamProcessor and disconnects it from all streams. | |
Public Member Functions inherited from MaxOS::common::GenericInputStream< ProcessorType > | |
| GenericInputStream () | |
| Creates a new GenericInputStream. | |
| GenericInputStream (InputStreamEventHandler< ProcessorType > *) | |
| Creates a new GenericInputStream and connects it to the handler. | |
| ~GenericInputStream () | |
| Destroys the GenericInputStream and disconnects all handlers. | |
| void | connect_input_stream_event_handler (InputStreamEventHandler< ProcessorType > *) |
| Adds a inputStreamEventHandler to the list of internetProtocolHandlers. | |
| void | disconnect_input_stream_event_handler (InputStreamEventHandler< ProcessorType > *) |
| Removes a handler from the list of handlers. | |
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 Logger & | Out () |
| Gets the active logger. | |
| static Logger | ERROR () |
| Gets active logger set to ERROR level. | |
| static Logger | WARNING () |
| Gets active logger set to WARNING level. | |
| static Logger | HEADER () |
| Gets active logger set to task level. | |
| static Logger | INFO () |
| Gets active logger set to info level. | |
| static Logger | TEST () |
| Gets active logger set to test level. | |
| static Logger | DEBUG () |
| Gets active logger set to DEBUG level. | |
Additional Inherited Members | |
Protected Attributes inherited from MaxOS::common::InputStreamEventHandler< Type > | |
| common::Vector< GenericInputStream< Type > * > | m_generic_input_streams |
| List of streams being observed by this handler. | |
Protected Attributes inherited from MaxOS::common::GenericInputStream< ProcessorType > | |
| common::Vector< InputStreamEventHandler< ProcessorType > * > | m_input_stream_event_handlers |
| List of streams being observed by this handler. | |
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 228 of file logger.cpp.
Referenced by MaxOS::drivers::console::VESABootConsole::finish(), Out(), and MaxOS::drivers::console::VESABootConsole::VESABootConsole().
| 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::drivers::SerialConsole::SerialConsole().
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 |
Definition at line 253 of file logger.cpp.
References MaxOS::String::formatted(), and MaxOS::system::CPU::PANIC().
|
static |
Gets active logger set to DEBUG level.
Definition at line 193 of file logger.cpp.
References Out().
Referenced by MaxOS::processes::GlobalScheduler::add_process(), MaxOS::processes::GlobalScheduler::add_thread(), MaxOS::hardwarecommunication::AdvancedConfigurationAndPowerInterface::AdvancedConfigurationAndPowerInterface(), MaxOS::hardwarecommunication::AdvancedProgrammableInterruptController::AdvancedProgrammableInterruptController(), MaxOS::drivers::clock::Clock::calibrate(), MaxOS::system::CPU::check_nx(), MaxOS::system::Core::Core(), core_main(), MaxOS::system::GlobalDescriptorTable::GlobalDescriptorTable(), MaxOS::system::Core::init_sse(), MaxOS::system::Core::init_tss(), MaxOS::drivers::disk::IntegratedDriveElectronicsController::initialise(), MaxOS::hardwarecommunication::IOAPIC::IOAPIC(), MaxOS::system::GlobalDescriptorTable::load(), MaxOS::processes::GlobalScheduler::load_multiboot_elfs(), MaxOS::hardwarecommunication::LocalAPIC::LocalAPIC(), MaxOS::filesystem::partition::MSDOSPartition::mount_partitions(), MaxOS::system::Multiboot::Multiboot(), MaxOS::memory::PhysicalMemoryManager::PhysicalMemoryManager(), MaxOS::memory::PhysicalMemoryManager::reserve(), MaxOS::hardwarecommunication::PCIController::select_drivers(), MaxOS::drivers::video::VideoElectronicsStandardsAssociation::VideoElectronicsStandardsAssociation(), MaxOS::memory::VirtualMemoryManager::VirtualMemoryManager(), MaxOS::system::Core::wake_up(), and MaxOS::processes::Process::~Process().
| void Logger::disable_log_writer | ( | OutputStream * | log_writer | ) |
Removes an output stream from the logger.
| log_writer | The output stream to remove |
Definition at line 66 of file logger.cpp.
|
static |
Gets active logger set to ERROR level.
Definition at line 216 of file logger.cpp.
References Out().
Referenced by MaxOS::filesystem::format::Fat32Volume::Fat32Volume(), MaxOS::system::SyscallManager::handle_interrupt(), MaxOS::system::CPU::PANIC(), MaxOS::system::CPU::prepare_for_panic(), MaxOS::system::CPU::print_registers(), MaxOS::tests::Test::run(), and MaxOS::system::CPU::stack_trace().
|
static |
Gets active logger set to task level.
Definition at line 159 of file logger.cpp.
References Out().
Referenced by MaxOS::drivers::console::VESABootConsole::finish(), and kernel_main().
|
static |
Gets active logger set to info level.
Definition at line 171 of file logger.cpp.
References Out().
Referenced by MaxOS::hardwarecommunication::InterruptManager::activate(), MaxOS::drivers::DriverManager::activate_drivers(), MaxOS::hardwarecommunication::AdvancedConfigurationAndPowerInterface::AdvancedConfigurationAndPowerInterface(), MaxOS::hardwarecommunication::AdvancedProgrammableInterruptController::AdvancedProgrammableInterruptController(), MaxOS::drivers::clock::Clock::calibrate(), MaxOS::drivers::clock::Clock::Clock(), MaxOS::system::CPU::CPU(), MaxOS::drivers::DriverManager::DriverManager(), MaxOS::drivers::DriverManager::find_drivers(), MaxOS::processes::GlobalScheduler::GlobalScheduler(), MaxOS::system::CPU::init_cores(), MaxOS::drivers::DriverManager::initialise_drivers(), MaxOS::hardwarecommunication::InterruptManager::InterruptManager(), kernel_main(), MaxOS::memory::PhysicalMemoryManager::PhysicalMemoryManager(), MaxOS::drivers::DriverManager::reset_devices(), MaxOS::system::SyscallManager::syscall_klog(), MaxOS::system::SyscallManager::SyscallManager(), MaxOS::drivers::console::VESABootConsole::VESABootConsole(), and MaxOS::drivers::video::VideoElectronicsStandardsAssociation::VideoElectronicsStandardsAssociation().
Sets the log level of the logger.
| log_level | The log level to set |
Definition at line 272 of file logger.cpp.
References set_log_level().
|
static |
Gets the active logger.
Definition at line 149 of file logger.cpp.
References active_logger().
Referenced by DEBUG(), ERROR(), HEADER(), INFO(), MaxOS::hardwarecommunication::PCIController::list_known_device(), MaxOS::filesystem::partition::MSDOSPartition::mount_partitions(), MaxOS::processes::GlobalScheduler::print_running_header(), MaxOS::hardwarecommunication::PCIController::select_drivers(), MaxOS::system::SyscallManager::syscall_klog(), TEST(), and WARNING().
Prints a formatted string to the logger.
| format | The format string |
| ... | The arguments to format |
Definition at line 238 of file logger.cpp.
References MaxOS::String::formatted(), and MaxOS::common::OutputStream::write().
Sets the log level of the logger.
| log_level | The log level to set |
Definition at line 83 of file logger.cpp.
References MaxOS::common::ANSI_COLOURS, MaxOS::processes::GlobalScheduler::print_running_header(), and MaxOS::drivers::console::VESABootConsole::update_progress_bar().
Referenced by operator<<().
|
static |
Gets active logger set to test level.
Definition at line 182 of file logger.cpp.
References Out().
Referenced by MaxOS::tests::Test::run(), and MaxOS::tests::TestRunner::run_all_tests().
|
static |
Gets active logger set to WARNING level.
Definition at line 205 of file logger.cpp.
References Out().
Referenced by MaxOS::tests::compare(), MaxOS::drivers::ethernet::AMD_AM79C973::handle_interrupt(), MaxOS::hardwarecommunication::InterruptManager::handle_interrupt_request(), MaxOS::drivers::disk::AdvancedTechnologyAttachment::identify(), MaxOS::hardwarecommunication::LocalAPIC::LocalAPIC(), MaxOS::filesystem::VirtualFileSystem::mount_filesystem(), MaxOS::filesystem::VirtualFileSystem::mount_filesystem(), MaxOS::filesystem::partition::MSDOSPartition::mount_partitions(), MaxOS::filesystem::VirtualFileSystem::unmount_filesystem(), and MaxOS::system::Core::wake_up().
Writes a character to the logger.
| c | The character to write |
Reimplemented from MaxOS::common::OutputStream.
Definition at line 131 of file logger.cpp.
References MaxOS::MAX_LOG_LEVEL, and MaxOS::common::OutputStream::write_char().