![]() |
SatNOGS-COMMS
4.1.0
A COMMS subsystem for CubeSats
|
A centralized, thread-safe logging utility for the SatNOGS-COMMS MCU software. More...
#include <logger.hpp>
Classes | |
| class | ring_buf_msg |
Public Types | |
| enum class | target { RTT = 0 , UART = 1 , RING_BUFFER = 2 , STORAGE = 3 } |
| Enumeration for targets to send logs to. More... | |
Public Member Functions | |
| logger (logger const &)=delete | |
| Disabled copy constructor to enforce singleton. | |
| void | operator= (logger const &)=delete |
| Disabled assignment operator to enforce singleton. | |
| void | boot () |
| Logs system initialization details to multiple targets (RTT, UART, and RING_BUFFER). | |
| void | log (std::initializer_list< target > list, const lib::exception &e) |
| Logs a satnogs::comms::lib::exception to a specified set of targets. | |
| void | log (std::initializer_list< target > list, const std::exception &e) |
| Logs a std::exception to specified targets. | |
| void | log (std::initializer_list< target > list, const etl::exception &e) |
| Logs an etl::exception to specified targets. | |
| void | log (std::initializer_list< target > list, const char *msg) |
| Logs a C-string message to specified targets. | |
| void | log (const lib::exception &e) |
| Logs a SatNOGS-COMMS exception to all default targets (RTT, UART, RING_BUFFER, EMMC). Additionally, the exceptions are saved to BACKUP_SRAM for retention based on the severity level defined by CONFIG_BACKUP_SRAM_EXCEPTION_LOG_LEVEL. | |
| void | log (const std::exception &e) |
| Logs a std::exception to all default targets (RTT, UART, RING_BUFFER, EMMC). Additionally, the std::exceptions are saved to BACKUP_SRAM for retention. | |
| void | log (const etl::exception &e) |
| Logs an etl::exception to all default targets (RTT, UART, RING_BUFFER, EMMC). Additionally, the exceptions are saved to BACKUP_SRAM for retention based on the severity level defined by CONFIG_BACKUP_SRAM_EXCEPTION_LOG_LEVEL. | |
| void | log (const char *msg) |
| Logs a C-string message to all default targets (RTT, UART, RING_BUFFER, EMMC). | |
| void | log (const etl::istring &msg) |
| Logs an ETL istring message to all default targets. | |
| etl::string< CONFIG_LOG_MAX_MSG_LEN > | get_latest_exception () const |
| Retrieves the latest exception message stored in BACKUP_SRAM. | |
| void | delete_storage_logs (struct tm &start, struct tm &end) |
| void | get_ring_buffer_log (ring_buf_msg &data, size_t index) |
| size_t | get_ring_buffer_size () |
Static Public Member Functions | |
| static logger & | get_instance () |
| Singleton access to the logger subsystem. | |
Static Public Attributes | |
| static constexpr const char * | mcu_log_dir = "/SD" CONFIG_STORAGE_LOG_MCU_PATH |
A centralized, thread-safe logging utility for the SatNOGS-COMMS MCU software.
The logger class is designed to facilitate a consistent approach to logging within the SatNOGS-COMMS system. It supports multiple log targets:
The logger class is a singleton, ensuring that all system components share the same logging interface. It can log messages and exceptions, including those derived from the satnogs::comms::lib::exception class and standard exceptions.
Usage involves obtaining the singleton instance via logger::get_instance() and calling the appropriate log() method for the data type at hand.
The logs that are stored in the eMMC storage are stored in the /SD/CONFIG_STORAGE_LOG_MCU_PATH directory, which is defined by the KConfig option CONFIG_STORAGE_LOG_MCU_PATH. The logs are stored in a file named YYYY-MM-DD.log, where DD is the day, MM is the month, and YYYY is the year. In case no date infomation is available, the file is named (e.g. no RTC or no GNSS) the file naming scheme that is used is the boot-<boot_counter>-<day>.log. The day starts from 0 and increments every 24 hours based on the uptime.
Definition at line 67 of file logger.hpp.
|
strong |
Enumeration for targets to send logs to.
| Enumerator | |
|---|---|
| RTT | Real-Time Transfer logging (Segger RTT). |
| UART | UART logging output. |
| RING_BUFFER | In-memory ring buffer for storing recent log messages. |
| STORAGE | eMMC logging for persistent storage |
Definition at line 75 of file logger.hpp.
|
delete |
Disabled copy constructor to enforce singleton.
| void satnogs::comms::logger::boot | ( | ) |
Logs system initialization details to multiple targets (RTT, UART, and RING_BUFFER).
Gathers firmware, library, and hardware version information, constructs a descriptive message, and logs it. This method is typically called once at system startup.
Definition at line 93 of file logger.cpp.
| void satnogs::comms::logger::delete_storage_logs | ( | struct tm & | start, |
| struct tm & | end ) |
Definition at line 682 of file logger.cpp.
|
inlinestatic |
| etl::string< CONFIG_LOG_MAX_MSG_LEN > satnogs::comms::logger::get_latest_exception | ( | ) | const |
Retrieves the latest exception message stored in BACKUP_SRAM.
Definition at line 791 of file logger.cpp.
| void satnogs::comms::logger::get_ring_buffer_log | ( | ring_buf_msg & | data, |
| size_t | index ) |
Definition at line 780 of file logger.cpp.
| size_t satnogs::comms::logger::get_ring_buffer_size | ( | ) |
Definition at line 774 of file logger.cpp.
| void satnogs::comms::logger::log | ( | const char * | msg | ) |
Logs a C-string message to all default targets (RTT, UART, RING_BUFFER, EMMC).
| msg | The null-terminated string to be logged. |
Definition at line 157 of file logger.cpp.
| void satnogs::comms::logger::log | ( | const etl::exception & | e | ) |
Logs an etl::exception to all default targets (RTT, UART, RING_BUFFER, EMMC). Additionally, the exceptions are saved to BACKUP_SRAM for retention based on the severity level defined by CONFIG_BACKUP_SRAM_EXCEPTION_LOG_LEVEL.
| e | The etl::exception object containing error details. |
Definition at line 132 of file logger.cpp.
| void satnogs::comms::logger::log | ( | const etl::istring & | msg | ) |
Logs an ETL istring message to all default targets.
| msg | The etl::istring object whose contents will be logged. |
Definition at line 168 of file logger.cpp.
| void satnogs::comms::logger::log | ( | const lib::exception & | e | ) |
Logs a SatNOGS-COMMS exception to all default targets (RTT, UART, RING_BUFFER, EMMC). Additionally, the exceptions are saved to BACKUP_SRAM for retention based on the severity level defined by CONFIG_BACKUP_SRAM_EXCEPTION_LOG_LEVEL.
| e | The lib::exception object containing error details. |
Definition at line 117 of file logger.cpp.
| void satnogs::comms::logger::log | ( | const std::exception & | e | ) |
Logs a std::exception to all default targets (RTT, UART, RING_BUFFER, EMMC). Additionally, the std::exceptions are saved to BACKUP_SRAM for retention.
| e | The standard exception object containing error details. |
Definition at line 145 of file logger.cpp.
| void satnogs::comms::logger::log | ( | std::initializer_list< target > | list, |
| const char * | msg ) |
Logs a C-string message to specified targets.
This method provides control over which outputs receive the log message.
| list | An initializer list specifying the desired logging targets. |
| msg | The null-terminated string to be logged. |
Definition at line 235 of file logger.cpp.
| void satnogs::comms::logger::log | ( | std::initializer_list< target > | list, |
| const etl::exception & | e ) |
Logs an etl::exception to specified targets.
This method provides control over which outputs receive the log message.
| list | An initializer list specifying the desired logging targets. |
| e | The standard exception object containing error details. |
Definition at line 218 of file logger.cpp.
| void satnogs::comms::logger::log | ( | std::initializer_list< target > | list, |
| const lib::exception & | e ) |
Logs a satnogs::comms::lib::exception to a specified set of targets.
This method provides control over which outputs receive the log message.
| list | An initializer list specifying the desired logging targets. |
| e | The satnogs::comms::lib::exception object to be logged. |
Definition at line 184 of file logger.cpp.
| void satnogs::comms::logger::log | ( | std::initializer_list< target > | list, |
| const std::exception & | e ) |
Logs a std::exception to specified targets.
This method provides control over which outputs receive the log message.
| list | An initializer list specifying the desired logging targets. |
| e | The standard exception object containing error details. |
Definition at line 201 of file logger.cpp.
|
delete |
Disabled assignment operator to enforce singleton.
|
staticconstexpr |
Definition at line 70 of file logger.hpp.