AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
|
A base class for a CAN logger, used to get diagnostic info from the CAN stack. More...
#include <can_stack_logger.hpp>
Public Types | |
enum class | LoggingLevel { Debug = 0 , Info , Warning , Error , Critical } |
Enumerates the various log message severities. More... | |
Public Member Functions | |
CANStackLogger ()=default | |
The constructor for a CANStackLogger. | |
~CANStackLogger ()=default | |
The destructor for a CANStackLogger. | |
virtual void | sink_CAN_stack_log (LoggingLevel level, const std::string &logText) |
Override this to make a log sink for your application. | |
Static Public Member Functions | |
static void | CAN_stack_log (LoggingLevel level, const std::string &logText) |
Gets called from the CAN stack to log information. Wraps sink_CAN_stack_log. | |
template<typename... Args> | |
static void | CAN_stack_log (LoggingLevel level, const std::string &format, Args... args) |
Gets called from the CAN stack to log information. Wraps sink_CAN_stack_log. | |
static void | debug (const std::string &logText) |
Logs a string to the log sink with Debug severity. Wraps sink_CAN_stack_log. | |
template<typename... Args> | |
static void | debug (const std::string &format, Args... args) |
Logs a printf formatted string to the log sink with Debug severity. Wraps sink_CAN_stack_log. | |
static void | info (const std::string &logText) |
Logs a string to the log sink with Info severity. Wraps sink_CAN_stack_log. | |
template<typename... Args> | |
static void | info (const std::string &format, Args... args) |
Logs a printf formatted string to the log sink with Info severity. Wraps sink_CAN_stack_log. | |
static void | warn (const std::string &logText) |
Logs a string to the log sink with Warning severity. Wraps sink_CAN_stack_log. | |
template<typename... Args> | |
static void | warn (const std::string &format, Args... args) |
Logs a printf formatted string to the log sink with Warning severity. Wraps sink_CAN_stack_log. | |
static void | error (const std::string &logText) |
Logs a string to the log sink with Error severity. Wraps sink_CAN_stack_log. | |
template<typename... Args> | |
static void | error (const std::string &format, Args... args) |
Logs a printf formatted string to the log sink with Error severity. Wraps sink_CAN_stack_log. | |
static void | critical (const std::string &logText) |
Logs a string to the log sink with Critical severity. Wraps sink_CAN_stack_log. | |
template<typename... Args> | |
static void | critical (const std::string &format, Args... args) |
Logs a printf formatted string to the log sink with Critical severity. Wraps sink_CAN_stack_log. | |
static void | set_can_stack_logger_sink (CANStackLogger *logSink) |
Assigns a derived logger class to be used as the log sink. | |
static LoggingLevel | get_log_level () |
Returns the current logging level. | |
static void | set_log_level (LoggingLevel newLogLevel) |
Sets the current logging level. | |
Static Private Member Functions | |
static bool | get_can_stack_logger (CANStackLogger *&canStackLogger) |
Provides a pointer to the static instance of the logger, and returns if the pointer is valid. | |
Static Private Attributes | |
static CANStackLogger * | logger = nullptr |
A static pointer to an instance of a logger. | |
static LoggingLevel | currentLogLevel = LoggingLevel::Info |
The current log level. Logs for levels below the current one will be dropped. | |
static Mutex | loggerMutex |
A mutex that protects the logger so it can be used from multiple threads. | |
A base class for a CAN logger, used to get diagnostic info from the CAN stack.
The CAN stack prints helpful text that may inform you of issues in either the stack or your application. You can override a function in this class to begin consuming this logging text.
Definition at line 28 of file can_stack_logger.hpp.
|
strong |
Enumerates the various log message severities.
Definition at line 32 of file can_stack_logger.hpp.
|
inlinestatic |
Gets called from the CAN stack to log information. Wraps sink_CAN_stack_log.
[in] | level | The log level for this text |
[in] | format | A format string of text to log, similar to printf |
[in] | args | A list of printf style arguments to use with the format string when logging |
Definition at line 59 of file can_stack_logger.hpp.
|
static |
Gets called from the CAN stack to log information. Wraps sink_CAN_stack_log.
[in] | level | The log level for this text |
[in] | logText | The text to be logged |
Definition at line 21 of file can_stack_logger.cpp.
|
inlinestatic |
Logs a printf formatted string to the log sink with Critical
severity. Wraps sink_CAN_stack_log.
[in] | format | The format string, similar to printf |
[in] | args | The variadic arguments to format, similar to printf |
Definition at line 135 of file can_stack_logger.hpp.
|
static |
Logs a string to the log sink with Critical
severity. Wraps sink_CAN_stack_log.
[in] | logText | The text to be logged at Critical severity |
Definition at line 53 of file can_stack_logger.cpp.
|
inlinestatic |
Logs a printf formatted string to the log sink with Debug
severity. Wraps sink_CAN_stack_log.
[in] | format | The format string, similar to printf |
[in] | args | The variadic arguments to format, similar to printf |
Definition at line 83 of file can_stack_logger.hpp.
|
static |
Logs a string to the log sink with Debug
severity. Wraps sink_CAN_stack_log.
[in] | logText | The text to be logged at Debug severity |
Definition at line 33 of file can_stack_logger.cpp.
|
inlinestatic |
Logs a printf formatted string to the log sink with Error
severity. Wraps sink_CAN_stack_log.
[in] | format | The format string, similar to printf |
[in] | args | The variadic arguments to format, similar to printf |
Definition at line 122 of file can_stack_logger.hpp.
|
static |
Logs a string to the log sink with Error
severity. Wraps sink_CAN_stack_log.
[in] | logText | The text to be logged at Error severity |
Definition at line 48 of file can_stack_logger.cpp.
|
staticprivate |
Provides a pointer to the static instance of the logger, and returns if the pointer is valid.
[out] | canStackLogger | The static logger instance |
nullptr
or false if it is nullptr
Definition at line 80 of file can_stack_logger.cpp.
|
static |
Returns the current logging level.
Log statements below the current level will be dropped and not passed to the log sink
Definition at line 65 of file can_stack_logger.cpp.
|
inlinestatic |
Logs a printf formatted string to the log sink with Info
severity. Wraps sink_CAN_stack_log.
[in] | format | The format string, similar to printf |
[in] | args | The variadic arguments to format, similar to printf |
Definition at line 96 of file can_stack_logger.hpp.
|
static |
Logs a string to the log sink with Info
severity. Wraps sink_CAN_stack_log.
[in] | logText | The text to be logged at Info severity |
Definition at line 38 of file can_stack_logger.cpp.
|
static |
Assigns a derived logger class to be used as the log sink.
[in] | logSink | A pointer to a derived CANStackLogger class |
Definition at line 60 of file can_stack_logger.cpp.
|
static |
Sets the current logging level.
Log statements below the new level will be dropped and not passed to the log sink
[in] | newLogLevel | The new logging level |
Definition at line 70 of file can_stack_logger.cpp.
|
virtual |
Override this to make a log sink for your application.
[in] | level | The severity level of the log text |
[in] | logText | The information being logged |
Definition at line 75 of file can_stack_logger.cpp.
|
inlinestatic |
Logs a printf formatted string to the log sink with Warning
severity. Wraps sink_CAN_stack_log.
[in] | format | The format string, similar to printf |
[in] | args | The variadic arguments to format, similar to printf |
Definition at line 109 of file can_stack_logger.hpp.
|
static |
Logs a string to the log sink with Warning
severity. Wraps sink_CAN_stack_log.
[in] | logText | The text to be logged at Warning severity |
Definition at line 43 of file can_stack_logger.cpp.
|
staticprivate |
The current log level. Logs for levels below the current one will be dropped.
Definition at line 170 of file can_stack_logger.hpp.
|
staticprivate |
A static pointer to an instance of a logger.
Definition at line 169 of file can_stack_logger.hpp.
|
staticprivate |
A mutex that protects the logger so it can be used from multiple threads.
Definition at line 171 of file can_stack_logger.hpp.