ModelSpace
All Classes Namespaces Functions Variables Enumerations Pages
clockwerk::EventLogger Class Reference

Class to handle event and debug logging. More...

#include <EventLogger.h>

Public Member Functions

 EventLogger (FILE *fp=stdout, unsigned int max_size=DEFAULT_MAX_MSG)
 Simple constructor for event logger.
 
void logLevel (log_level_e level)
 Function to set logging level for system.
 
log_level_e logLevel ()
 Function to get log level for system.
 
int logMessage (log_level_e level, const std::string &message, log_level_e local_msg=NONE)
 Function to write an event message.
 
int flushLogs ()
 Function to flush the file buffer.
 

Detailed Description

Class to handle event and debug logging.

The event logger is a simple, lightweight, static class for logging events as they occur. To minimize impact, the logger uses c-style file IO techniques and c-strings.

A configurable character limit, for now set to 140 characters, is enforced on logging. If you can't tweet it, you shouldn't be logging it in a simulation or embedded framework.

This logging framework derived (sort of) from the Dr. Dobbs simple logging framework presented here: https:/// drdobbs.com/cpp/logging-in-c/201804215

Constructor & Destructor Documentation

◆ EventLogger()

clockwerk::EventLogger::EventLogger ( FILE *  fp = stdout,
unsigned int  max_size = DEFAULT_MAX_MSG 
)
inline

Simple constructor for event logger.

Parameters
fpFile pointer to write to – set to stdout by default
max_sizeMax size of message, in characters. Set to 140 by default

Member Function Documentation

◆ flushLogs()

int clockwerk::EventLogger::flushLogs ( )

Function to flush the file buffer.

Note
Unless you're running real time, you probably don't need to call this
Returns
Error code corresponding to success/failure

◆ logLevel() [1/2]

log_level_e clockwerk::EventLogger::logLevel ( )
inline

Function to get log level for system.

Returns
Log level

◆ logLevel() [2/2]

void clockwerk::EventLogger::logLevel ( log_level_e  level)
inline

Function to set logging level for system.

Parameters
levelLevel to set logging to

◆ logMessage()

int clockwerk::EventLogger::logMessage ( log_level_e  level,
const std::string &  message,
log_level_e  local_msg = NONE 
)

Function to write an event message.

Parameters
levelThe log level of the referenced message
timeThe time, written out as a string
messageThe message to be written. Must be <MAX_MESSAGE_SIZE (140 char)
local_msgThe local level at which the message should be written out. Allows for higher local debugging
Returns
Error code corresponding to success/failure

The documentation for this class was generated from the following files: