![]() |
FIMS
v0.9.2
|
Singleton logger for FIMS. More...
#include <def.hpp>
Public Member Functions | |
| FIMSLog () | |
| ~FIMSLog () | |
| std::filesystem::path | getAbsolutePathWithoutDotDot (const std::filesystem::path &relativePath) |
| Get the absolute path without dot dot notation. | |
| void | set_path (std::string path) |
| Set the destination file path for writing logs to disk. | |
| std::string | get_path () |
| Get the current output path for on-disk logs. | |
| void | info_message (std::string str, int line, const char *file, const char *func) |
| void | error_message (std::string str, int line, const char *file, const char *func) |
| void | warning_message (std::string str, int line, const char *file, const char *func) |
| std::string | get_log () |
| Return all stored log entries as a JSON array string. | |
| std::string | get_errors () |
| Return only error-level log entries as a JSON array string. | |
| std::string | get_warnings () |
| Return only warning-level log entries as a JSON array string. | |
| std::string | get_info () |
| Return only info-level log entries as a JSON array string. | |
| size_t | get_error_count () const |
| Return the number of error-log entries currently stored. | |
| size_t | get_warning_count () const |
| Return the number of warning-log entries currently stored. | |
| void | clear () |
| Clear in-memory logging state. | |
Public Attributes | |
| bool | write_on_exit = true |
| A boolean specifying if the log file is written when the session is terminated. The default is TRUE. | |
| bool | throw_on_error = false |
| A boolean specifying if the program is stopped upon the first error, where the default is FALSE. This allows you go through an entire program to collect all error messages. | |
Static Public Attributes | |
| static std::shared_ptr< FIMSLog > | fims_log = std::make_shared<FIMSLog>() |
| A singleton instance of the log, i.e., where there is only one log. The object is created when the .dll is loaded and it will never be recreated while the .dll is loaded. | |
Singleton logger for FIMS.
FIMSLog accumulates log entries in memory and provides JSON-formatted accessors for all entries and severity-specific subsets.
Runtime behavior:
write_on_exit = true writes the current log buffer to disk in the destructor.throw_on_error = true throws a std::runtime_error after recording an error-level entry.
|
inline |
Default constructor for FIMSLog.
|
inline |
Destructor. If write_on_exit is set to true, the log will be written to the disk in JSON format.
|
inline |
Clear in-memory logging state.
Clears the raw entry cache and structured entries, resets error, warning, and entry counters, and preserves configured output path and throw_on_error behavior.
|
inline |
Add a error-level message to the log.
| str | Log message text. |
| line | Source line number where the message originated. |
| file | Source file where the message originated. |
| func | Function or method name where the message originated. |
|
inline |
Return the number of error-log entries currently stored.
This counter is incremented whenever an error-level log entry is added and is reset to zero when clear() is called.
|
inline |
Return only error-level log entries as a JSON array string.
This method filters the in-memory log buffer and includes only entries where level == "error".
If no error entries exist, this method returns an empty JSON array ([]).
level == "error".
|
inline |
Return only info-level log entries as a JSON array string.
This method filters the in-memory log buffer and includes only entries where level == "info".
If no info entries exist, this method returns an empty JSON array ([]).
level == "info".
|
inline |
Return all stored log entries as a JSON array string.
The returned value is a JSON array of serialized LogEntry objects in the same order they were recorded.
If no entries are stored, this method returns an empty JSON array ([]).
LogEntry.
|
inline |
Get the current output path for on-disk logs.
|
inline |
Return the number of warning-log entries currently stored.
This counter is incremented whenever a warning-level log entry is added and is reset to zero when clear() is called.
|
inline |
Return only warning-level log entries as a JSON array string.
This method filters the in-memory log buffer and includes only entries where level == "warning".
If no warning entries exist, this method returns an empty JSON array ([]).
level == "warning".
|
inline |
Get the absolute path without dot dot notation.
Dot dot notation is for relative paths, where this function replaces all dot dots with the actual full path.
| relativePath | A path in your file system. |
|
inline |
Add a info-level message to the log.
| str | Log message text. |
| line | Source line number where the message originated. |
| file | Source file where the message originated. |
| func | Function or method name where the message originated. |
|
inline |
Set the destination file path for writing logs to disk.
The configured path is used whenever the logger writes to disk, including destructor-time writes (when write_on_exit is true) and signal-triggered writes in WriteAtExit().
This method updates only the output location and does not clear or modify the in-memory log buffer.
| path | Relative or absolute path to the output log file (for example, "fims.log" or "logs/fims_run_01.json"). |
|
inline |
Add a warning-level message to the log.
| str | Log message text. |
| line | Source line number where the message originated. |
| file | Source file where the message originated. |
| func | Function or method name where the message originated. |