NNLogger
NNLogLevel
typedef enum NNLogLevel
{
NN_LOG_LEVEL_VERB = 0,
NN_LOG_LEVEL_DEBUG = 1,
NN_LOG_LEVEL_INFO = 2,
NN_LOG_LEVEL_WARN = 3,
NN_LOG_LEVEL_ERROR = 4,
NN_LOG_LEVEL_FATAL = 5,
NN_LOG_LEVEL_TIMING = 6,
} NNLogLevel;
Introduction to the Enum
Enumeration representing different logging levels.
Introduction to the Enum's items
NN_LOG_LEVEL_VERB: Verbose logging level, the most detailed logs.
NN_LOG_LEVEL_DEBUG:Informational logging level, for general informational messages.
NN_LOG_LEVEL_WARN: Warning logging level, for messages indicating potential issues.
NN_LOG_LEVEL_ERROR: Fatal logging level, for messages indicating severe errors that terminate the application.
NN_LOG_LEVEL_TIMING: Timing logging level, for messages related to performance timing.
NNLogger
class NNLogger
{
public:
virtual void setDebugMode(bool enable) = 0;
virtual void setFileLogPath(std::string logPath) = 0;
virtual void setFileLog(bool enable) = 0;
virtual void setSystemLog(bool enable) = 0;
virtual void setLevel(int level) = 0;
virtual void writeLog(int level, std::string tag, std::string content) = 0;
};
Introduction to the Class
Abstract base class for a logger that provides methods to configure logging behavior and write logs.
Introduction to the Class's Methods
void setDebugMode(bool enable)
brief: Enables or disables debug mode. When debug mode is enabled, logs are immediately output and no logs are lost, but this can result in longer execution times for the current task. Therefore, it is necessary to make appropriate trade-offs, and typically, debug mode is only turned on during debugging.
param
bool enable: to enable debug mode, false to disable
void setFileLogPath(std::string logPath)
brief: Sets the path for file logging. This method sets the directory where log files should be written.
param
std::string logPath: The path where log files should be stored.
void setFileLog(bool enable):
brief: Enables or disables file logging. When file logging is enabled, logs will be written to the specified file path.
param
bool enable: True to enable file logging, false to disable.
void setSystemLog(bool enable):
brief: Enables or disables system logging. When system logging is enabled, logs will be written to the console.
param
bool enable: True to enable system logging, false to disable.
void setLevel(int level):
brief: Sets the logging level. This method sets the minimum logging level that will be logged. Any log messages with a lower level will be ignored.
param
int level: The logging level to set (one of the NNLogLevel enumerations).
void writeLog(int level, std::string tag, std::string content) :
brief: Writes a log message. This method writes a log message with the specified level, tag, and content.
param
int level: The logging level to set (one of the NNLogLevel enumerations).
std::string tag: A tag or category for the log message.
std::string content: The actual content of the log message.