|
Safeheron-SGX-Native-Development-Framework v1.2.0
|
Singleton class for managing logging within the SGX library. More...
#include <ssgx_log_u_logger.h>
Public Member Functions | |
| void | Init (const std::string &logger_name, const std::string &log_file, LogLevel log_level=ssgx::log_u::LogLevel::INFO, bool append_console=false) |
| Initializes the logger with specified settings. | |
| std::string | GetLoggerName () |
| Retrieves the singleton instance of SSGXLogger. | |
| void | SetTraceId (const std::string &trace_id) |
| Sets a trace ID for log messages. | |
| bool | IsInitialized () |
| int | WriteLog (ssgx::log_u::LogLevel log_level, const char *msg) |
| Logs a message with the specified log level. | |
| SSGXLogger (const SSGXLogger &)=delete | |
| SSGXLogger & | operator= (const SSGXLogger &)=delete |
Static Public Member Functions | |
| static SSGXLogger & | GetInstance () |
| Retrieves the singleton instance of SSGXLogger. | |
Singleton class for managing logging within the SGX library.
This class provides a centralized logging interface for the SGX library. It supports log level configuration, trace ID management, and the ability to initialize a logger with file and console appenders.
Usage:
|
delete |
|
static |
Retrieves the singleton instance of SSGXLogger.
This method provides thread-safe access to the single instance of the logger.
|
inline |
Retrieves the singleton instance of SSGXLogger.
This method provides thread-safe access to the single instance of the logger.
| void ssgx::log_u::SSGXLogger::Init | ( | const std::string & | logger_name, |
| const std::string & | log_file, | ||
| LogLevel | log_level = ssgx::log_u::LogLevel::INFO, | ||
| bool | append_console = false ) |
Initializes the logger with specified settings.
Configures the logger with a given name, log file, log level, and optional console appender. This method should be called before logging any messages.
| logger_name | Name of the logger (e.g., "AppLogger"). |
| log_file | Path to the log file. |
| log_level | Logging level to filter log messages. |
| append_console | Whether to output log messages to the console. Default is false. |
| bool ssgx::log_u::SSGXLogger::IsInitialized | ( | ) |
|
delete |
| void ssgx::log_u::SSGXLogger::SetTraceId | ( | const std::string & | trace_id | ) |
Sets a trace ID for log messages.
The trace ID is stored in the logging context and can be used to correlate log messages across different parts of the application. To include the trace ID in log messages, the log pattern must contain X{TraceId}.
Example:
| trace_id | The trace ID string to be included in subsequent log messages. |
| int ssgx::log_u::SSGXLogger::WriteLog | ( | ssgx::log_u::LogLevel | log_level, |
| const char * | msg ) |
Logs a message with the specified log level.
This function logs a message to the configured log system with the specified log level. It ensures that the logger has been properly initialized before attempting to log the message.
| level | The log level indicating the severity of the message. Possible values include INFO, WARNING, ERROR, DEBUG, FATAL, etc. |
| msg | The log message to be recorded. |