libyang  2.0.112
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
log.h
Go to the documentation of this file.
1 
15 #ifndef LY_LOG_H_
16 #define LY_LOG_H_
17 
18 #include <stdint.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 /* dummy context structure */
25 struct ly_ctx;
26 
32 typedef uint8_t ly_bool;
33 
85 typedef enum
86 {
87  LY_LLERR = 0,
88  LY_LLWRN = 1,
89  LY_LLVRB = 2,
90  LY_LLDBG = 3
92 } LY_LOG_LEVEL;
93 
103 
114 #define LY_LOLOG 0x01
116 #define LY_LOSTORE 0x02
118 #define LY_LOSTORE_LAST 0x06
133 uint32_t ly_log_options(uint32_t opts);
134 
135 #ifndef NDEBUG
136 
148 #define LY_LDGDICT 0x01
149 #define LY_LDGXPATH 0x02
150 #define LY_LDGDEPSETS 0x04
164 uint32_t ly_log_dbg_groups(uint32_t dbg_groups);
165 
166 #endif
167 
179 typedef void (*ly_log_clb)(LY_LOG_LEVEL level, const char *msg, const char *path);
180 
191 void ly_set_log_clb(ly_log_clb clb, ly_bool path);
192 
198 
242 typedef enum
243 {
244  LY_SUCCESS = 0,
246  LY_ESYS,
257  LY_ENOT,
262 } LY_ERR;
270 typedef enum {
271  LYVE_SUCCESS = 0,
272  LYVE_SYNTAX,
284 
288 struct ly_err_item {
290  LY_ERR no;
292  char *msg;
293  char *path;
294  char *apptag;
295  struct ly_err_item *next;
296  struct ly_err_item *prev; /* first item's prev points to the last item */
297 };
307 LY_VECODE ly_vecode(const struct ly_ctx *ctx);
308 
315 LY_ERR ly_errcode(const struct ly_ctx *ctx);
316 
327 const char *ly_errmsg(const struct ly_ctx *ctx);
328 
342 const char *ly_errpath(const struct ly_ctx *ctx);
343 
354 const char *ly_errapptag(const struct ly_ctx *ctx);
355 
362 struct ly_err_item *ly_err_first(const struct ly_ctx *ctx);
363 
370 struct ly_err_item *ly_err_last(const struct ly_ctx *ctx);
371 
378 void ly_err_print(const struct ly_ctx *ctx, struct ly_err_item *eitem);
379 
388 void ly_err_clean(struct ly_ctx *ctx, struct ly_err_item *eitem);
389 
392 #ifdef __cplusplus
393 }
394 #endif
395 
396 #endif /* LY_LOG_H_ */
LY_LOG_LEVEL level
Definition: log.h:292
void ly_err_clean(struct ly_ctx *ctx, struct ly_err_item *eitem)
Free error structures from a context.
Definition: log.h:248
uint8_t ly_bool
Type to indicate boolean value.
Definition: log.h:25
Definition: log.h:261
const char * ly_errapptag(const struct ly_ctx *ctx)
Get the last (thread, context-specific) error-app-tag if there was a specific one defined in the modu...
LY_VECODE
libyang&#39;s codes of validation error. Whenever ly_errno is set to LY_EVALID, the ly_vecode is also set...
Definition: log.h:273
char * apptag
Definition: log.h:297
char * msg
Definition: log.h:295
void(* ly_log_clb)(LY_LOG_LEVEL level, const char *msg, const char *path)
Logger callback.
Definition: log.h:182
Definition: log.h:253
const char * ly_errpath(const struct ly_ctx *ctx)
Get the last (thread, context-specific) path of the element where was an error.
LY_LOG_LEVEL ly_log_level(LY_LOG_LEVEL level)
Set logger verbosity level.
char * path
Definition: log.h:296
Definition: log.h:88
Libyang full error structure.
Definition: log.h:291
Definition: log.h:283
LY_LOG_LEVEL
Verbosity levels of the libyang logger.
Definition: log.h:85
void ly_set_log_clb(ly_log_clb clb, ly_bool path)
Set logger callback.
Definition: log.h:254
Definition: log.h:89
struct ly_err_item * prev
Definition: log.h:299
ly_log_clb ly_get_log_clb(void)
Get logger callback.
Definition: log.h:90
Definition: log.h:87
struct ly_err_item * ly_err_first(const struct ly_ctx *ctx)
Get the first (thread, context-specific) generated error structure.
Definition: log.h:260
LY_ERR ly_errcode(const struct ly_ctx *ctx)
Get the last (thread, context-specific) error code.
Definition: log.h:251
LY_VECODE vecode
Definition: log.h:294
struct ly_err_item * next
Definition: log.h:298
Definition: log.h:249
LY_ERR
libyang&#39;s error codes returned by the libyang functions.
Definition: log.h:245
struct ly_err_item * ly_err_last(const struct ly_ctx *ctx)
Get the latest (thread, context-specific) generated error structure.
const char * ly_errmsg(const struct ly_ctx *ctx)
Get the last (thread, context-specific) error message. If the coresponding module defined a specific ...
LY_ERR no
Definition: log.h:293
LY_VECODE ly_vecode(const struct ly_ctx *ctx)
Get the last (thread, context-specific) validation error code.
void ly_err_print(const struct ly_ctx *ctx, struct ly_err_item *eitem)
Print the error structure as if just generated.
libyang context handler.
Definition: log.h:250