![]() |
MaCh3
2.4.2
Reference Guide
|
MaCh3 Logging utilities built on top of SPDLOG. More...
#include <iostream>#include <sstream>#include <functional>#include <string>#include <exception>#include "Manager/Core.h"#include "spdlog/spdlog.h"Go to the source code of this file.
Macros | |
| #define | MACH3LOG_TRACE SPDLOG_TRACE |
| #define | MACH3LOG_DEBUG SPDLOG_DEBUG |
| #define | MACH3LOG_INFO SPDLOG_INFO |
| #define | MACH3LOG_WARN SPDLOG_WARN |
| #define | MACH3LOG_ERROR SPDLOG_ERROR |
| #define | MACH3LOG_CRITICAL SPDLOG_CRITICAL |
| #define | MACH3LOG_OFF SPDLOG_OFF |
Functions | |
| spdlog::level::level_enum | get_default_log_level () |
| KS: Map string macro to spdlog::level enum. More... | |
| void | SetMaCh3LoggerFormat () |
| Set messaging format of the logger. More... | |
| template<typename Func , typename LogFunc , typename... Args> | |
| void | LoggerPrint (const std::string &LibName, LogFunc logFunction, Func &&func, Args &&... args) |
| KS: This is bit convoluted but this is to allow redirecting cout and errors from external library into MaCh3 logger format. More... | |
MaCh3 Logging utilities built on top of SPDLOG.
KS: MaCh3 uses SPDLOG as its core logging backend, and this file serves as a wrapper around it. The MaCh3 logging system uses compile-time log level definitions to control which log statements are compiled. This ensures that, in default builds, MACH3LOG_DEBUG and lower levels are completely removed at compile time for maximal performance.
The available compile-time log level definitions can be found here.
Definition in file MaCh3Logger.h.
| #define MACH3LOG_CRITICAL SPDLOG_CRITICAL |
Definition at line 38 of file MaCh3Logger.h.
| #define MACH3LOG_DEBUG SPDLOG_DEBUG |
Definition at line 34 of file MaCh3Logger.h.
| #define MACH3LOG_ERROR SPDLOG_ERROR |
Definition at line 37 of file MaCh3Logger.h.
| #define MACH3LOG_INFO SPDLOG_INFO |
Definition at line 35 of file MaCh3Logger.h.
| #define MACH3LOG_OFF SPDLOG_OFF |
Definition at line 39 of file MaCh3Logger.h.
| #define MACH3LOG_TRACE SPDLOG_TRACE |
Definition at line 33 of file MaCh3Logger.h.
| #define MACH3LOG_WARN SPDLOG_WARN |
Definition at line 36 of file MaCh3Logger.h.
|
inline |
KS: Map string macro to spdlog::level enum.
Definition at line 43 of file MaCh3Logger.h.
| void LoggerPrint | ( | const std::string & | LibName, |
| LogFunc | logFunction, | ||
| Func && | func, | ||
| Args &&... | args | ||
| ) |
KS: This is bit convoluted but this is to allow redirecting cout and errors from external library into MaCh3 logger format.
| Func | The type of the function to be called, which outputs to stdout and stderr. |
| LogFunc | The type of the logging function, typically a lambda that formats and logs messages. |
| Args | The types of the arguments to be passed to func. |
| LibName | The name of the library or component from which the log message originates. |
| logFunction | The lambda function responsible for formatting and logging messages. It should accept a single const std::string& parameter. |
| func | The function to be called, whose output needs to be captured and logged. |
| args | The arguments to be passed to func. void ExampleFunc(int x, const std::string& str) {
std::cout << "Output from exampleFunc: " << x << ", " << str << "\n";
std::cerr << "Error from exampleFunc: " << x << ", " << str << "\n";
}
int main() {
static_cast<void(*)(int, const std::string&)>(ExampleFunc), 666, "Number of the BEAST");
return 0;
}
void LoggerPrint(const std::string &LibName, LogFunc logFunction, Func &&func, Args &&... args) KS: This is bit convoluted but this is to allow redirecting cout and errors from external library int... Definition: MaCh3Logger.h:100 |
func into an existing logging mechanism without modifying func itself Definition at line 100 of file MaCh3Logger.h.
|
inline |
Set messaging format of the logger.
Definition at line 61 of file MaCh3Logger.h.