documentation for UcxLogger

Wed, 24 Jul 2013 14:26:17 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 24 Jul 2013 14:26:17 +0200
changeset 129
61edec666928
parent 128
b79b1ce438dd
child 130
633f15ce2ee4

documentation for UcxLogger

ucx/list.h file | annotate | diff | comparison | revisions
ucx/logging.h file | annotate | diff | comparison | revisions
--- a/ucx/list.h	Tue Jul 23 14:43:45 2013 +0200
+++ b/ucx/list.h	Wed Jul 24 14:26:17 2013 +0200
@@ -60,10 +60,13 @@
         for (UcxList* elem = list ; elem != NULL ; elem = elem->next)
 
 /**
- * UCX list type
+ * UCX list type.
  * @see UcxList
  */
 typedef struct UcxList UcxList;
+/**
+ * UCX list structure.
+ */
 struct UcxList {
     /**
      * List element payload.
@@ -105,6 +108,7 @@
  * argument for the <code>data</code> parameter, if you want the copy_func() to
  * make use of the allocator.
  * 
+ * @param allocator the allocator to use
  * @param list the list to copy
  * @param cpyfnc a pointer to the function that shall copy an element (may be
  * <code>NULL</code>)
--- a/ucx/logging.h	Tue Jul 23 14:43:45 2013 +0200
+++ b/ucx/logging.h	Wed Jul 24 14:26:17 2013 +0200
@@ -25,7 +25,12 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-
+/**
+ * Logging API.
+ * 
+ * @file   logging.h
+ * @author Mike Becker, Olaf Wintermann
+ */
 #ifndef UCX_LOGGING_H
 #define UCX_LOGGING_H
 
@@ -39,37 +44,169 @@
 #endif
 
 /* leave enough space for custom log levels */
+/** Log level for error messages. */
 #define UCX_LOGGER_ERROR        0x00
+/** Log level for warning messages. */
 #define UCX_LOGGER_WARN         0x10
+/** Log level for information messages. */
 #define UCX_LOGGER_INFO         0x20
-#define UCX_LOGGER_TRACE        0x30
+/** Log level for debug messages. */
+#define UCX_LOGGER_DEBUG        0x30
+/** Log level for trace messages. */
+#define UCX_LOGGER_TRACE        0x40
 
+/**
+ * Output flag for the log level. 
+ * If this flag is set, the log message will contain the log level.
+ * @see UcxLogger.mask
+ */
 #define UCX_LOGGER_LEVEL        0x01
+/**
+ * Output flag for the timestmap.
+ * If this flag is set, the log message will contain the timestmap.
+ * @see UcxLogger.mask
+ */
 #define UCX_LOGGER_TIMESTAMP    0x02
+/**
+ * Output flag for the source.
+ * If this flag is set, the log message will contain the source file and line
+ * number.
+ * @see UcxLogger.mask
+ */
 #define UCX_LOGGER_SOURCE       0x04
 
+/**
+ * The UCX Logger object.
+ */
 typedef struct {
+    /** The stream this logger writes its messages to.*/
     void *stream;
+    /**
+     * The write function that shall be used.
+     * For standard file or stdout loggers this might be standard fwrite
+     * (default).
+     */
     write_func writer;
+    /**
+     * The date format for timestamp outputs
+     * (default: <code>"%F %T %z "</code>).
+     * @see UCX_LOGGER_TIMESTAMP
+     */
     char *dateformat;
+    /**
+     * The level, this logger operates on.
+     * If a log command is issued, the message will only be logged, if the log
+     * level of the message is less or equal than the log level of the logger.
+     */
     unsigned int level;
+    /**
+     * A configuration mask for automatic output. 
+     * For each flag that is set, the logger automatically outputs some extra
+     * information like the timestamp or the source file and line number.
+     * See the documentation for the flags for details.
+     */
     unsigned int mask;
+    /**
+     * A map of valid log levels for this logger.
+     * 
+     * The keys represent all valid log levels and the values provide string
+     * representations, that are used, if the UCX_LOGGER_LEVEL flag is set.
+     * 
+     * The exact data types are <code>unsigned int</code> for the key and
+     * <code>const char*</code> for the value.
+     * 
+     * @see UCX_LOGGER_LEVEL
+     */
     UcxMap* levels;
 } UcxLogger;
 
+/**
+ * Creates a new logger.
+ * @param stream the stream, which the logger shall write to
+ * @param level the level on which the logger shall operate
+ * @param mask configuration mask (cf. UcxLogger.mask)
+ * @return a new logger object
+ */
 UcxLogger *ucx_logger_new(void *stream, unsigned int level, unsigned int mask);
+/**
+ * Destroys the logger.
+ * 
+ * The map containing the valid log levels is also automatically destroyed.
+ * 
+ * @param logger the logger to destroy
+ */
 void ucx_logger_free(UcxLogger* logger);
 
+/**
+ * Internal log function - use macros instead.
+ * 
+ * This function uses the <code>format</code> and variadic arguments for a
+ * printf()-style output of the log message.
+ * 
+ * Dependent on the UcxLogger.mask some information is prepended. The complete
+ * format is:
+ * 
+ * <code>[LEVEL] [TIMESTAMP] [SOURCEFILE]:[LINENO] message</code>
+ * 
+ * @param logger the logger to use
+ * @param level the level to log on
+ * @param file information about the source file
+ * @param line information about the source line number
+ * @param format format string
+ * @param ... arguments
+ * @see ucx_logger_log()
+ */
 void ucx_logger_logf(UcxLogger *logger, unsigned int level, const char* file,
         const unsigned int line, const char* format, ...);
+
+/**
+ * Logs a message at the specified level.
+ * @param logger the logger to use
+ * @param level the level to log the message on
+ * @param ... format string and arguments
+ * @see ucx_logger_logf()
+ */
 #define ucx_logger_log(logger, level, ...) \
     ucx_logger_logf(logger, level, __FILE__, __LINE__, __VA_ARGS__)
+
+/**
+ * Shortcut for logging an error message.
+ * @param logger the logger to use
+ * @param ... format string and arguments
+ * @see ucx_logger_logf()
+ */
 #define ucx_logger_error(logger, ...) \
     ucx_logger_log(logger, UCX_LOGGER_ERROR, __VA_ARGS__)
+/**
+ * Shortcut for logging an information message.
+ * @param logger the logger to use
+ * @param ... format string and arguments
+ * @see ucx_logger_logf()
+ */
 #define ucx_logger_info(logger, ...) \
     ucx_logger_log(logger, UCX_LOGGER_INFO, __VA_ARGS__)
+/**
+ * Shortcut for logging a warning message.
+ * @param logger the logger to use
+ * @param ... format string and arguments
+ * @see ucx_logger_logf()
+ */
 #define ucx_logger_warn(logger, ...) \
     ucx_logger_log(logger, UCX_LOGGER_WARN, __VA_ARGS__)
+/**
+ * Shortcut for logging a debug message.
+ * @param logger the logger to use
+ * @param ... format string and arguments
+ * @see ucx_logger_logf()
+ */
+#define ucx_logger_debug(logger, ...) \
+    ucx_logger_log(logger, UCX_LOGGER_DEBUG, __VA_ARGS__)
+/**
+ * Shortcut for logging a trace message.
+ * @param logger the logger to use
+ * @param ... format string and arguments
+ * @see ucx_logger_logf()
+ */
 #define ucx_logger_trace(logger, ...) \
     ucx_logger_log(logger, UCX_LOGGER_TRACE, __VA_ARGS__)
 

mercurial