19#define MAX_CHAR_LOG_MESSAGE 1024
20#define TIMESTAMP_SIZE 32
21#define SEPARATORS_SIZE 5
22#define MAX_FINAL_MESSAGE_SIZE (MAX_CHAR_LOG_MESSAGE + TIMESTAMP_SIZE + SEPARATORS_SIZE)
24#define RMMLOG_DEBUG_MASK 1
25#define RMMLOG_INFO_MASK 2
26#define RMMLOG_WARN_MASK 4
27#define RMMLOG_ERROR_MASK 8
28#define RMMLOG_CRITICAL_MASK 16
52 void debug(
const char *sender,
const char *printer...);
53 void info(
const char *sender,
const char *printer...);
54 void warn(
const char *sender,
const char *printer...);
55 void error(
const char *sender,
const char *printer...);
56 void critical(
const char *sender,
const char *printer...);
57 void logRelay(std::string logLevel, FILE *out);
65 rmmStatus
putMsg(std::string msg);
66 rmmStatus
putInfo(
const char *sender, std::string msg);
67 rmmStatus
putMsg(
const char *message...);
68 rmmStatus
putInfo(
const char *sender,
const char *msg...);
69 rmmStatus
getMsg(std::string *msg);
72 rmmStatus
setLogFilePath(std::string filePath,
bool useName =
false);
77 void log(FILE *out,
const char *msg);
79 FILE *debug_log = NULL;
80 FILE *info_log = NULL;
81 FILE *warn_log = NULL;
83 FILE *crit_log = NULL;
84 std::string file_name;
88 std::atomic_uint failedFileWrites = {0};
89 std::atomic_uint failedLogs = {0};
90 std::ofstream logFile;
91 std::chrono::milliseconds max_log_timeout_ms = std::chrono::milliseconds(10);
92 std::chrono::milliseconds max_file_write_timeout_ms = std::chrono::milliseconds(10);
94 std::atomic_bool writeToFile = {
false};
rmmStatus putInfo(const char *sender, std::string msg)
Calls both putMsg and info methods.
Definition RMMLog.cpp:463
void logRelay(std::string logLevel, FILE *out)
Relays log output to a specified file for a given log level.
Definition RMMLog.cpp:137
rmmStatus setLogFilePath(std::string filePath, bool useName=false)
Sets the log file path for the log file.
Definition RMMLog.cpp:353
void error(const char *sender, const char *printer...)
Logs an error message.
Definition RMMLog.cpp:89
void setFileWriteTimeout(int milliseconds)
Sets the timeout for file write operations.
Definition RMMLog.cpp:256
rmmStatus getMsg(std::string *msg)
Get the message stored in object container.
Definition RMMLog.cpp:306
RMMLog(const char *name)
Constructs the RMMLog object with a name for the log.
Definition RMMLog.cpp:30
void critical(const char *sender, const char *printer...)
Logs a critical message.
Definition RMMLog.cpp:104
void info(const char *sender, const char *printer...)
Logs an info message.
Definition RMMLog.cpp:59
rmmStatus getLogFilePath(std::string *filePath)
Get filepath to log.
Definition RMMLog.cpp:317
rmmStatus setLogMask(int mask)
Sets the log mask to the given value.
Definition RMMLog.cpp:227
void debug(const char *sender, const char *printer...)
Logs a debug message.
Definition RMMLog.cpp:44
void getLogMask(int *mask)
Gets the current log mask.
Definition RMMLog.cpp:182
int getFailedWrites()
Gets the count of failed write attempts to the log file.
Definition RMMLog.cpp:242
rmmStatus setWriteToFile(bool option, char mode='w')
Enable/disable writing to log.
Definition RMMLog.cpp:408
void getTimestamp(char message[MAX_CHAR_LOG_MESSAGE])
Retrieves the current timestamp in a formatted string.
Definition RMMLog.cpp:159
~RMMLog()
Destructor for the RMMLog object.
Definition RMMLog.cpp:36
rmmStatus putMsg(std::string msg)
Store message in a buffer.
Definition RMMLog.cpp:290
void setLogTimeout(int milliseconds)
Sets the timeout for logging operations.
Definition RMMLog.cpp:249
void warn(const char *sender, const char *printer...)
Logs a warning message.
Definition RMMLog.cpp:74
Struct representing a log message with sender, message, and log mask.
Definition RMMLog.h:34
int mask
Log mask associated with the message.
Definition RMMLog.h:37
const char * sender
Sender of the log message.
Definition RMMLog.h:35
const char * message
The actual log message.
Definition RMMLog.h:36