summaryrefslogtreecommitdiffstats
path: root/src/log.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:23:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 04:23:18 +0000
commitb90161ccd3b318f3314a23cb10c387651ad35831 (patch)
treea47dc087160299ce02d728cbf031d84af6281537 /src/log.h
parentAdding upstream version 2.1.30. (diff)
downloadlibyang2-b90161ccd3b318f3314a23cb10c387651ad35831.tar.xz
libyang2-b90161ccd3b318f3314a23cb10c387651ad35831.zip
Adding upstream version 2.1.148.upstream/2.1.148upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/log.h')
-rw-r--r--src/log.h57
1 files changed, 40 insertions, 17 deletions
diff --git a/src/log.h b/src/log.h
index 2144668..c6c1851 100644
--- a/src/log.h
+++ b/src/log.h
@@ -141,8 +141,6 @@ LIBYANG_API_DECL uint32_t ly_log_options(uint32_t opts);
*/
LIBYANG_API_DECL void ly_temp_log_options(uint32_t *opts);
-#ifndef NDEBUG
-
/**
* @ingroup log
* @defgroup dbggroup Debug messages groups
@@ -166,13 +164,12 @@ LIBYANG_API_DECL void ly_temp_log_options(uint32_t *opts);
* @brief Enable specific debugging messages (independent of log level).
*
* To get the current value, the function must be called twice resetting the level by the received value.
+ * Note: does not have any effect on non-debug (Release) builds
*
* @param[in] dbg_groups Bitfield of enabled debug message groups (see @ref dbggroup).
* @return Previous options bitfield.
*/
-uint32_t ly_log_dbg_groups(uint32_t dbg_groups);
-
-#endif
+LIBYANG_API_DECL uint32_t ly_log_dbg_groups(uint32_t dbg_groups);
/**
* @brief Logger callback.
@@ -294,17 +291,33 @@ typedef enum {
* @brief Libyang full error structure.
*/
struct ly_err_item {
- LY_LOG_LEVEL level;
- LY_ERR no;
- LY_VECODE vecode;
- char *msg;
- char *path;
- char *apptag;
- struct ly_err_item *next;
- struct ly_err_item *prev; /* first item's prev points to the last item */
+ LY_LOG_LEVEL level; /**< error (message) log level */
+ LY_ERR no; /**< error code */
+ LY_VECODE vecode; /**< validation error code, if any */
+ char *msg; /**< error message */
+ char *path; /**< error path that caused the error, if any */
+ char *apptag; /**< error-app-tag, if any */
+ struct ly_err_item *next; /**< next error item */
+ struct ly_err_item *prev; /**< previous error item, points to the last item for the ifrst item */
};
/**
+ * @brief Get the last (thread, context-specific) error code.
+ *
+ * @param[in] ctx Relative context.
+ * @return LY_ERR value of the last error code.
+ */
+LIBYANG_API_DECL LY_ERR ly_errcode(const struct ly_ctx *ctx);
+
+/**
+ * @brief Get human-readable error message for an error code.
+ *
+ * @param[in] err Error code.
+ * @return String error message.
+ */
+LIBYANG_API_DECL const char *ly_strerrcode(LY_ERR err);
+
+/**
* @brief Get the last (thread, context-specific) validation error code.
*
* This value is set only if ly_errno is #LY_EVALID.
@@ -315,12 +328,12 @@ struct ly_err_item {
LIBYANG_API_DECL LY_VECODE ly_vecode(const struct ly_ctx *ctx);
/**
- * @brief Get the last (thread, context-specific) error code.
+ * @brief Get human-readable error message for a validation error code.
*
- * @param[in] ctx Relative context.
- * @return LY_ERR value of the last error code.
+ * @param[in] vecode Validation error code.
+ * @return String error message.
*/
-LIBYANG_API_DECL LY_ERR ly_errcode(const struct ly_ctx *ctx);
+LIBYANG_API_DECL const char *ly_strvecode(LY_VECODE vecode);
/**
* @brief Get the last (thread, context-specific) error message. If the coresponding module defined
@@ -335,6 +348,16 @@ LIBYANG_API_DECL LY_ERR ly_errcode(const struct ly_ctx *ctx);
LIBYANG_API_DECL const char *ly_errmsg(const struct ly_ctx *ctx);
/**
+ * @brief Get the last (thread-specific) error message.
+ *
+ * ::ly_errmsg() should be used instead of this function but this one is useful for getting
+ * errors from functions that do not have any context accessible. Or as a simple unified logging API.
+ *
+ * @return Last generated error message.
+ */
+LIBYANG_API_DECL const char *ly_last_errmsg(void);
+
+/**
* @brief Get the last (thread, context-specific) path of the element where was an error.
*
* The path always corresponds to the error message available via ::ly_errmsg(), so