From c60cc4ce6f8cf4745da28a8111768942b74a65e9 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 19 Apr 2022 09:45:31 +0200 Subject: [PATCH] added documentation --- src/log.h | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+), 0 deletions(-) diff --git a/src/log.h b/src/log.h index 47b2b81..897fe55 100644 --- a/src/log.h +++ b/src/log.h @@ -77,6 +77,11 @@ namespace log { osdev::components::log::Log::debug(__FILE__, __LINE__, context, text); \ } +/*! + * \brief The LogLevel enum + * Enumeration class dealing with LogLevels. + * Used to convert to syslog macro's. + */ enum class LogLevel { Emergency = 0, @@ -89,6 +94,11 @@ enum class LogLevel Debug }; +/*! + * \brief The LogMask enum + * Enumeration class dealing with LogMask. + * Used to convert to syslog macro's. + */ enum class LogMask { Mask = 0, @@ -102,21 +112,90 @@ enum class LogMask class Log { public: + /** + * @brief Initialize the logging mechanism + * @param context - The main context + * @param logFile - Logfile if available + * @param logDepth - Initial log-depth + */ static void init( const std::string& context, const std::string& logFile = std::string(), LogLevel logDepth = LogLevel::Info ); + //! Shutdown the logging mechanism static void terminate(); + /*! + * \brief Write to syslog + * \param priority - priority level [from debug up to emergency] + * \param message - The string to print + * \param context - The context name. default name is the name of the executable. + */ static void write( const int &priority, const std::string &message, const std::string &context = std::string() ); + /** + * @brief Log an emergency message in a category. + * @param file - Name of the source-file + * @param line - The line number in the source-file + * @param category - The category of the message. + * @param message - The string to print + */ static void emergency( const char* file, int line, const std::string& category, const std::string& message ); + /** + * @brief Log an alert message in a category. + * @param file - Name of the source-file + * @param line - The line number in the source-file + * @param category - The category of the message. + * @param message - The string to print + */ static void alert ( const char* file, int line, const std::string& category, const std::string& message ); + /** + * @brief Log a critical message in a category. + * @param file - Name of the source-file + * @param line - The line number in the source-file + * @param category - The category of the message. + * @param message - The string to print + */ static void critical ( const char* file, int line, const std::string& category, const std::string& message ); + /** + * @brief Log an error message in a category. + * @param file - Name of the source-file + * @param line - The line number in the source-file + * @param category - The category of the message. + * @param message - The string to print + */ static void error ( const char* file, int line, const std::string& category, const std::string& message ); + /** + * @brief Log a warning message in a category. + * @param file - Name of the source-file + * @param line - The line number in the source-file + * @param category - The category of the message. + * @param message - The string to print + */ static void warning ( const char* file, int line, const std::string& category, const std::string& message ); + /** + * @brief Log a notice message in a category. + * @param file - Name of the source-file + * @param line - The line number in the source-file + * @param category - The category of the message. + * @param message - The string to print + */ static void notice ( const char* file, int line, const std::string& category, const std::string& message ); + /** + * @brief Log an info message in a category. + * @param file - Name of the source-file + * @param line - The line number in the source-file + * @param category - The category of the message. + * @param message - The string to print + */ static void info ( const char* file, int line, const std::string& category, const std::string& message ); + /** + * @brief Log a debug message in a category. + * @param file - Name of the source-file + * @param line - The line number in the source-file + * @param category - The category of the message. + * @param message - The string to print + */ static void debug ( const char* file, int line, const std::string& category, const std::string& message ); /** @@ -131,18 +210,70 @@ public: return s_logLevel; } + /*! + * \brief setMask update the current logMask + * \param logMask - Enum defining the logmask used. + */ static void setMask ( LogMask logMask ) { s_logMask = logMask; } + /*! + * \brief setLogLevel update the current logLevel + * \param logLevel - Enum defining the logLevel used, in combination with Mask. + */ static void setLogLevel( LogLevel logLevel ) { s_logLevel = logLevel; } + /*! + * \brief setContext update the current context + * \param context - String containing the new context name. + */ static void setContext ( std::string context ) { s_context = context; } protected: + /** + * @brief Log an emergency message in a category. + * @param category The category of the message. + * @param message The string to print. + */ static void emergency( const std::string& category, const std::string& message ); + /** + * @brief Log an alert message in a category. + * @param category The category of the message. + * @param message The string to print. + */ static void alert ( const std::string& category, const std::string& message ); + /** + * @brief Log a critical message in a category. + * @param category The category of the message. + * @param message The string to print. + */ static void critical ( const std::string& category, const std::string& message ); + /** + * @brief Log an error message in a category. + * @param category The category of the message. + * @param message The string to print. + */ static void error ( const std::string& category, const std::string& message ); + /** + * @brief Log a warning message in a category. + * @param category The category of the message. + * @param message The string to print. + */ static void warning ( const std::string& category, const std::string& message ); + /** + * @brief Log a notice message in a category. + * @param category The category of the message. + * @param message The string to print. + */ static void notice ( const std::string& category, const std::string& message ); + /** + * @brief Log an info message in a category. + * @param category The category of the message. + * @param message The string to print. + */ static void info ( const std::string& category, const std::string& message ); + /** + * @brief Log an debug message in a category. + * @param category The category of the message. + * @param message The string to print. + */ static void debug ( const std::string& category, const std::string& message ); /** -- libgit2 0.21.4