|
RMM API 2.0.0
|
Class for managing and writing log messages to different log levels and files. More...
#include <RMMLog.h>

Public Member Functions | |
| RMMLog (const char *name) | |
| Constructs the RMMLog object with a name for the log. | |
| ~RMMLog () | |
| Destructor for the RMMLog object. | |
| void | debug (const char *sender, const char *printer...) |
| Logs a debug message. | |
| void | info (const char *sender, const char *printer...) |
| Logs an info message. | |
| void | warn (const char *sender, const char *printer...) |
| Logs a warning message. | |
| void | error (const char *sender, const char *printer...) |
| Logs an error message. | |
| void | critical (const char *sender, const char *printer...) |
| Logs a critical message. | |
| void | logRelay (std::string logLevel, FILE *out) |
| Relays log output to a specified file for a given log level. | |
| void | getTimestamp (char message[MAX_CHAR_LOG_MESSAGE]) |
| Retrieves the current timestamp in a formatted string. | |
| void | getLogMask (int *mask) |
| Gets the current log mask. | |
| void | getLogMask (char *mask) |
| Gets the current log mask as a string. | |
| rmmStatus | setLogMask (int mask) |
| Sets the log mask to the given value. | |
| void | setLogTimeout (int milliseconds) |
| Sets the timeout for logging operations. | |
| void | setFileWriteTimeout (int milliseconds) |
| Sets the timeout for file write operations. | |
| int | getFailedWrites () |
| Gets the count of failed write attempts to the log file. | |
| rmmStatus | putMsg (std::string msg) |
| Store message in a buffer. | |
| rmmStatus | putInfo (const char *sender, std::string msg) |
| Calls both putMsg and info methods. | |
| rmmStatus | putMsg (const char *message...) |
| Store message in a buffer. | |
| rmmStatus | putInfo (const char *sender, const char *msg...) |
| Calls both putMsg and info methods. | |
| rmmStatus | getMsg (std::string *msg) |
| Get the message stored in object container. | |
| rmmStatus | getLogFilePath (std::string *filePath) |
| Get filepath to log. | |
| rmmStatus | getLogFilePath (std::string *path, std::string *name) |
| Retrieves the directory and filename of the log file. | |
| rmmStatus | setLogFilePath (std::string filePath, bool useName=false) |
| Sets the log file path for the log file. | |
| rmmStatus | setLogFilePath (std::string path, std::string name) |
| Sets the log file path using a directory and a custom file name. | |
| rmmStatus | setWriteToFile (bool option, char mode='w') |
| Enable/disable writing to log. | |
Class for managing and writing log messages to different log levels and files.
This class provides functionality for logging messages of different severities (debug, info, warning, error, and critical) to both the console and to a file. It includes timestamp handling, log masking, and support for different log levels.
| RMMLog::RMMLog | ( | const char * | name | ) |
Constructs the RMMLog object with a name for the log.
| name | The name to be used for the log. |
| void RMMLog::critical | ( | const char * | sender, |
| const char * | printer... ) |
Logs a critical message.
| [in] | sender | The sender of the log message. |
| [in] | printer | The message to log, can accept formatted arguments. |
| void RMMLog::debug | ( | const char * | sender, |
| const char * | printer... ) |
Logs a debug message.
| [in] | sender | The sender of the log message. |
| [in] | printer | The message to log, can accept formatted arguments. |
| void RMMLog::error | ( | const char * | sender, |
| const char * | printer... ) |
Logs an error message.
| [in] | sender | The sender of the log message. |
| [in] | printer | The message to log, can accept formatted arguments. |
| int RMMLog::getFailedWrites | ( | ) |
Gets the count of failed write attempts to the log file.
| rmmStatus RMMLog::getLogFilePath | ( | std::string * | filePath | ) |
Get filepath to log.
| filePath | Pointer to string to store filepath |
| rmmStatus RMMLog::getLogFilePath | ( | std::string * | path, |
| std::string * | name ) |
Retrieves the directory and filename of the log file.
| [out] | path | Pointer to store the directory path. |
| [out] | name | Pointer to store the log file name. |
| void RMMLog::getLogMask | ( | char * | mask | ) |
Gets the current log mask as a string.
| [out] | mask | Pointer to a character array where the log mask will be stored. |
| void RMMLog::getLogMask | ( | int * | mask | ) |
Gets the current log mask.
| [out] | mask | Pointer to store the current log mask. |
| rmmStatus RMMLog::getMsg | ( | std::string * | msg | ) |
Get the message stored in object container.
| msg | Pointer to string to store message |
| void RMMLog::getTimestamp | ( | char | message[MAX_CHAR_LOG_MESSAGE] | ) |
Retrieves the current timestamp in a formatted string.
| [in] | message | The timestamp string to fill. |
| void RMMLog::info | ( | const char * | sender, |
| const char * | printer... ) |
Logs an info message.
| [in] | sender | The sender of the log message. |
| [in] | printer | The message to log, can accept formatted arguments. |
| void RMMLog::logRelay | ( | std::string | logLevel, |
| FILE * | out ) |
Relays log output to a specified file for a given log level.
| [in] | logLevel | The level of log (debug, info, warn, error, critical). |
| [in] | out | The file pointer to output the log messages. |
| rmmStatus RMMLog::putInfo | ( | const char * | sender, |
| const char * | msg... ) |
Calls both putMsg and info methods.
| sender | name of function calling this. |
| msg | message to be put into container and printed. |
| ... | arguments to format message just like printf would. |
| rmmStatus RMMLog::putInfo | ( | const char * | sender, |
| std::string | msg ) |
Calls both putMsg and info methods.
| sender | name of function calling this. |
| msg | message to be put into container and printed. |
| rmmStatus RMMLog::putMsg | ( | const char * | message... | ) |
Store message in a buffer.
| message | Char array to treat as message |
| ... | Args to format message similar to printf. |
| rmmStatus RMMLog::putMsg | ( | std::string | msg | ) |
Store message in a buffer.
| msg | String to store message |
| void RMMLog::setFileWriteTimeout | ( | int | milliseconds | ) |
Sets the timeout for file write operations.
| [in] | milliseconds | Timeout in milliseconds. |
| rmmStatus RMMLog::setLogFilePath | ( | std::string | filePath, |
| bool | useName = false ) |
Sets the log file path for the log file.
This method sets the log file path based on the provided directory and file name. It can either use the default component name or a custom file name.
If useName is true, the component's name is appended with .log to form the file name. If useName is false, the method expects a complete file path (directory and name) to set as the log file path.
| [in] | filePath | The directory path where the log file will be stored. |
| [in] | useName | A flag to decide if the default name should be used (true) or if a custom name should be provided (false). |
rmmSuccess if the log file path is set correctly, or rmmError if the directory is invalid or another error occurs. | rmmStatus RMMLog::setLogFilePath | ( | std::string | path, |
| std::string | name ) |
Sets the log file path using a directory and a custom file name.
This method sets the log file path for the log file by using the specified directory (path) and custom file name (name). If the provided directory is valid, it combines the directory and name to form the full log file path.
| [in] | path | The directory path where the log file will be stored. |
| [in] | name | The custom name for the log file. |
rmmSuccess if the log file path is set successfully, or rmmError if the directory is invalid or another error occurs.RMMLog::setLogFilePath(std::string, bool) that explicitly accepts a directory and a custom file name. | rmmStatus RMMLog::setLogMask | ( | int | mask | ) |
Sets the log mask to the given value.
| [in] | mask | The log mask to set. |
| void RMMLog::setLogTimeout | ( | int | milliseconds | ) |
Sets the timeout for logging operations.
| [in] | milliseconds | Timeout in milliseconds. |
| rmmStatus RMMLog::setWriteToFile | ( | bool | option, |
| char | mode = 'w' ) |
Enable/disable writing to log.
| option | bool for enabling/disabling writing to log. |
| mode | write mode. 'w' for creating new file, 'a' for appending log to existing file. |
| void RMMLog::warn | ( | const char * | sender, |
| const char * | printer... ) |
Logs a warning message.
| [in] | sender | The sender of the log message. |
| [in] | printer | The message to log, can accept formatted arguments. |