debug.h (1551B)
1 #ifndef MORGEL_H_ 2 #define MORGEL_H_ 3 4 /** 5 * \brief Data type indicator for the structured log. 6 * 7 * \see debug_dbg_x 8 */ 9 enum debug_typ_e { 10 MORGEL_TYP_BIN, ///< Binary content type. 11 MORGEL_TYP_NUM, ///< Numeric content type. 12 MORGEL_TYP_STR, 13 }; 14 15 /** 16 * \brief Log a literal message with the given namespace. 17 * 18 * \param[in] Namespace string. If NULL, will use the default namespace. 19 * \param[in] Literal message to log. 20 */ 21 void debug(enum lloglvl_e lvl, const char *ns, const char *msg); 22 23 /** 24 * \brief Log a structured message with the given namespace. 25 * 26 * Each structured parameter consist of four arguments: 27 * 1. An enum debug_typ_e specifying the type of value (and thus how to format it) 28 * 2. An int value specifying the length of the value behind the pointer, in bytes. Currently only used with MORGEL_TYPE_BIN 29 * 3. Pointer to key string. 30 * 4. Pointer to value. 31 * 32 * \param[in] The log level. 33 * \param[in] Namespace string. If NULL, will use the default namespace. 34 * \param[in] Main message to log. 35 * \param[in] Number of structured values. 36 * \param[in] Key/value list (see above) 37 */ 38 void debug_x(enum lloglvl_e lvl, const char *ns, const char *msg, int argc, ...); 39 40 /** 41 * \brief Convenience function to log a single error, using rerr for error code to string resolution. 42 * 43 * \param[in] Log level to use for the log line. 44 * \param[in] Error code to log. 45 * \param[in] Supporting message to include in log line. 46 * \return The error code. 47 */ 48 int debug_logerr(enum lloglvl_e lvl, int err, char *msg); 49 50 #endif // MORGEL_H_