A custom logger sink designed to send formatted log messages over the RoveComm protocol. This class extends quill::Sink
and is tailored for use in the Autonomy system, where log messages need to be transmitted as packets over a network to a BaseStation via UDP.
More...
#include <AutonomyLogging.h>
|
| MRDTRoveCommSink (std::string const &szFormatPattern, std::string const &szTimeFormat, quill::Timezone qTimestampTimezone) |
| Constructs a new MRDTRoveCommSink object with the specified format pattern, time format, and optional timezone. This constructor initializes the sink with the necessary format settings for logging messages and prepares them to be transmitted over the RoveComm protocol.
|
|
| ~MRDTRoveCommSink () override=default |
| Destroy the MRDTRoveCommSink object.
|
|
void | write_log (const quill::MacroMetadata *qLogMetadata, uint64_t unLogTimestamp, std::string_view szThreadID, std::string_view szThreadName, const std::string &szProcessID, std::string_view szLoggerName, quill::LogLevel qLogLevel, std::string_view szLogLevelDescription, std::string_view szLogLevelShortCode, const std::vector< std::pair< std::string, std::string > > *vNamedArgs, std::string_view szLogMessage, std::string_view) override |
| Formats a log message and sends it as a RoveComm packet to the BaseStation. The log message is formatted using the provided metadata, thread, and process information, then packed and transmitted via RoveComm protocol to a specified IP address and port.
|
|
void | flush_sink () noexcept override |
| This method should never be called by this codebase, it is called internally by the quill library.
|
|
|
std::vector< char > | StringToVector (const std::string &szString) |
| A utility function to convert a string to a vector that is no longer than 255 characters long.
|
|
|
quill::PatternFormatter | qFormatter |
|
A custom logger sink designed to send formatted log messages over the RoveComm protocol. This class extends quill::Sink
and is tailored for use in the Autonomy system, where log messages need to be transmitted as packets over a network to a BaseStation via UDP.
The MRDTRoveCommSink
class formats log messages using a specified pattern and time format, and then transmits the formatted messages as RoveCommPacket
objects. It integrates with the Quill logging framework and is designed to handle both real-time and networked logging scenarios.
Key Features:
- Customizable log message formats using a pattern.
- Integration with the RoveComm protocol for network transmission of log messages.
- Handles the conversion of log messages to a format suitable for network transmission.
- Inherits from
quill::Sink
for seamless integration with Quill's logging framework.
- Note
- This class is intended for use in networked logging scenarios where logs are transmitted to a BaseStation using the RoveComm protocol. It should not be called directly but instead used as part of the Quill logging framework.
- See also
- quill::Sink
-
rovecomm::RoveCommPacket
- Author
- Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
- Date
- 2024-03-17
◆ MRDTRoveCommSink()
logging::MRDTRoveCommSink::MRDTRoveCommSink |
( |
std::string const & |
szFormatPattern, |
|
|
std::string const & |
szTimeFormat, |
|
|
quill::Timezone |
qTimestampTimezone |
|
) |
| |
|
inline |
Constructs a new MRDTRoveCommSink object with the specified format pattern, time format, and optional timezone. This constructor initializes the sink with the necessary format settings for logging messages and prepares them to be transmitted over the RoveComm protocol.
- Parameters
-
szFormatPattern | - The pattern used to format the log message. |
szTimeFormat | - The format of the timestamp in the log message. |
qTimestampTimezone | - The timezone used for the timestamp (default: LocalTime). |
- Note
- Ensure that the format pattern and time format are correctly set to match the expected format for the log messages. This is crucial for ensuring the proper transmission and interpretation of log data over the RoveComm protocol.
- Warning
- Misconfiguration of the format pattern or time format may lead to incorrect log formatting and potential issues with packet transmission.
- See also
- quill::Sink
-
rovecomm::RoveCommPacket
- Author
- Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
- Date
- 2024-03-17
455 :
456 qFormatter(quill::PatternFormatterOptions(szFormatPattern, szTimeFormat, qTimestampTimezone))
457 {}
◆ ~MRDTRoveCommSink()
logging::MRDTRoveCommSink::~MRDTRoveCommSink |
( |
| ) |
|
|
overridedefault |
◆ StringToVector()
std::vector< char > logging::MRDTRoveCommSink::StringToVector |
( |
const std::string & |
szString | ) |
|
|
inlineprivate |
A utility function to convert a string to a vector that is no longer than 255 characters long.
- Parameters
-
szString | - The string to convert |
- Returns
- std::vector<char> - The string shown as a vector of characters.
- Author
- Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
- Date
- 2024-03-17
418 {
419 std::vector<char> result;
420 int length = std::min(static_cast<int>(szString.length()), 255);
421 result.reserve(length);
422
423 for (int i = 0; i < length; ++i)
424 {
425 result.push_back(szString[i]);
426 }
427
428 return result;
429 }
◆ write_log()
void logging::MRDTRoveCommSink::write_log |
( |
const quill::MacroMetadata * |
qLogMetadata, |
|
|
uint64_t |
unLogTimestamp, |
|
|
std::string_view |
szThreadID, |
|
|
std::string_view |
szThreadName, |
|
|
const std::string & |
szProcessID, |
|
|
std::string_view |
szLoggerName, |
|
|
quill::LogLevel |
qLogLevel, |
|
|
std::string_view |
szLogLevelDescription, |
|
|
std::string_view |
szLogLevelShortCode, |
|
|
const std::vector< std::pair< std::string, std::string > > * |
vNamedArgs, |
|
|
std::string_view |
szLogMessage, |
|
|
std::string_view |
log_statement |
|
) |
| |
|
override |
Formats a log message and sends it as a RoveComm packet to the BaseStation. The log message is formatted using the provided metadata, thread, and process information, then packed and transmitted via RoveComm protocol to a specified IP address and port.
This function utilizes a custom formatter to combine metadata and log message content into a single formatted string, which is then converted into a RoveCommPacket
and sent to the BaseStation over UDP.
- Parameters
-
qLogMetadata | - Metadata about the log statement (e.g., file, line number). |
unLogTimestamp | - The timestamp of the log statement. |
szThreadID | - The ID of the thread that generated the log. |
szThreadName | - The name of the thread that generated the log. |
szProcessID | - The ID of the process that generated the log. |
szLoggerName | - The name of the logger that generated the log. |
qLogLevel | - The level/severity of the log statement (currently unused). |
szLogLevelDescription | - A description of the log level. |
szLogLevelShortCode | - A short code representing the log level. |
vNamedArgs | - Optional named arguments passed with the log statement. |
szLogMessage | - The actual log message content. |
log_statement | - The full log statement (currently unused). |
- Note
- This method formats the log message and sends it as a RoveComm packet to the BaseStation if both UDP and TCP statuses are active. The log level and log statement parameters are not currently used in the packet creation.
-
This method should not be called directly. It is meant to be invoked by the logging framework as part of the log handling process.
- See also
- quill::MacroMetadata
-
rovecomm::RoveCommPacket
-
network::SendUDPPacket
- Warning
- Ensure that the RoveComm protocol is correctly configured and that both UDP and TCP statuses are active before calling this method to avoid packet transmission failure.
- Attention
- The formatter must be properly configured to ensure the correct format of the log message before it is sent as a RoveComm packet.
- Author
- Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
- Date
- 2024-08-16
397 {
398
399 (void) qLogLevel;
400 (void) log_statement;
401
402
403 std::string_view szFormattedLogMessage = qFormatter.format(unLogTimestamp,
404 szThreadID,
405 szThreadName,
406 szProcessID,
407 szLoggerName,
408 szLogLevelDescription,
409 szLogLevelShortCode,
410 *qLogMetadata,
411 vNamedArgs,
412 szLogMessage
413 );
414
415
416 if (static_cast<int>(g_eRoveCommLogLevel) <= static_cast<int>(qLogLevel))
417 {
418
419 rovecomm::RoveCommPacket<char> stPacket;
420 stPacket.unDataId = manifest::Autonomy::TELEMETRY.find("CURRENTLOG")->second.DATA_ID;
421 stPacket.unDataCount = manifest::Autonomy::TELEMETRY.find("CURRENTLOG")->second.DATA_COUNT;
422 stPacket.eDataType = manifest::Autonomy::TELEMETRY.find("CURRENTLOG")->second.DATA_TYPE;
423 stPacket.vData =
StringToVector({szFormattedLogMessage.data(), szFormattedLogMessage.size()});
424
425
426 if (network::g_bRoveCommUDPStatus && network::g_bRoveCommTCPStatus)
427 {
428 network::g_pRoveCommUDPNode->SendUDPPacket(stPacket, "0.0.0.0", constants::ROVECOMM_OUTGOING_UDP_PORT);
429 }
430 }
431 }
std::vector< char > StringToVector(const std::string &szString)
A utility function to convert a string to a vector that is no longer than 255 characters long.
Definition AutonomyLogging.h:417
◆ flush_sink()
void logging::MRDTRoveCommSink::flush_sink |
( |
| ) |
|
|
inlineoverridenoexcept |
This method should never be called by this codebase, it is called internally by the quill library.
- Author
- Eli Byrd (edbgk.nosp@m.k@ms.nosp@m.t.edu)
- Date
- 2024-03-17
The documentation for this class was generated from the following files: