You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A simple interface for logging messages to a serial console with a printf like API to act as the complete bare minimum for logging. In future, something more advanced such as WPILog to facilitate namespaces and datalogging would be preferred.
Frontend
printf-like
// Get the primary logger singletonauto log = Logging::GetLog();
// The different functions are different log levels
log.Trace("Super verbose information which isn't very important during normal operation, only enabled in debug builds");
log.Debug("Slightly more important information which should not exist during normal operation, only enabled in debug builds");
log.Info("General details which do not imply there is an issue");
log.Warn("Something strange might be going on (eg. a secondary sensor is not connected), but all subsystems can continue to operate");
log.Error("A subsystem has failed");
log.Fatal("Core components cannot operate");
// Specify the level through an enum instead
log.LogMessage(Logging::Level::kWarn, "Can be used for variable log levels");
// Specify format arguments
log.Info("The meaning of life: {}", 42);
RAII Output Iterator
The printf like API will likely be written in terms of this.
{
// Create a new message handleauto msg = Logging::GetLog().MessageBuilder(Logging::Level::kWarn);
// Write a single character
*msg++ = 'F';
// Use formatstd::format_to(msg, "Hello {}", "World!");
// Message is committed at the end of the scope
}
Metadata
To the beginning of each message the following should be appended:
Timestamp (seconds since boot to the nearest microsecond)
Level
Current FreeRTOS task
At the end of the message a newline and a null character (acting as an end of message sentinal) should be appended.
For example Warn("foo {}", 42) could become something like [13.894662|WARN|MyTask] foo 42\n\0.
Backend
Messages should be written to an arbitrary number of OutputPort objects. An implementation for a USB VCOM port should be written.
Checkpoints
Freestanding Hello World via USB VCOM
Logging::GetLog() and temporary proof of concept function log.RawMessage(str) which directly sends the message with no metadata, formatting or use of OutputPort abstraction
Extract USB code into an OutputPort object, unit testing
MessageBuilder without log levels or metadata
Log levels (no other metadata) and all frontend functions
Timestamp and current task
The text was updated successfully, but these errors were encountered:
A simple interface for logging messages to a serial console with a
printf
like API to act as the complete bare minimum for logging. In future, something more advanced such as WPILog to facilitate namespaces and datalogging would be preferred.Frontend
printf
-likeRAII Output Iterator
The
printf
like API will likely be written in terms of this.Metadata
To the beginning of each message the following should be appended:
At the end of the message a newline and a null character (acting as an end of message sentinal) should be appended.
For example
Warn("foo {}", 42)
could become something like[13.894662|WARN|MyTask] foo 42\n\0
.Backend
Messages should be written to an arbitrary number of
OutputPort
objects. An implementation for a USB VCOM port should be written.Checkpoints
Logging::GetLog()
and temporary proof of concept functionlog.RawMessage(str)
which directly sends the message with no metadata, formatting or use ofOutputPort
abstractionOutputPort
object, unit testingMessageBuilder
without log levels or metadataThe text was updated successfully, but these errors were encountered: