libyang  2.0.7
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
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
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
163 uint32_t ly_log_dbg_groups(uint32_t dbg_groups);
164 
165 #endif
166 
178 typedef void (*ly_log_clb)(LY_LOG_LEVEL level, const char *msg, const char *path);
179 
191 
197 
241 typedef enum
242 {
254  LY_ERECOMPILE,
259  LY_EPLUGIN = 128
262 
269 typedef enum {
281  LYVE_OTHER
283 
287 struct ly_err_item {
291  char *msg;
292  char *path;
293  char *apptag;
294  struct ly_err_item *next;
295  struct ly_err_item *prev; /* first item's prev points to the last item */
296 };
297 
306 LY_VECODE ly_vecode(const struct ly_ctx *ctx);
307 
314 LY_ERR ly_errcode(const struct ly_ctx *ctx);
315 
326 const char *ly_errmsg(const struct ly_ctx *ctx);
327 
341 const char *ly_errpath(const struct ly_ctx *ctx);
342 
353 const char *ly_errapptag(const struct ly_ctx *ctx);
354 
361 struct ly_err_item *ly_err_first(const struct ly_ctx *ctx);
362 
369 struct ly_err_item *ly_err_last(const struct ly_ctx *ctx);
370 
377 void ly_err_print(const struct ly_ctx *ctx, struct ly_err_item *eitem);
378 
387 void ly_err_clean(struct ly_ctx *ctx, struct ly_err_item *eitem);
388 
391 #ifdef __cplusplus
392 }
393 #endif
394 
395 #endif /* LY_LOG_H_ */
libyang context handler.
struct ly_err_item * prev
Definition: log.h:295
LY_VECODE vecode
Definition: log.h:290
char * apptag
Definition: log.h:293
char * msg
Definition: log.h:291
struct ly_err_item * next
Definition: log.h:294
LY_ERR no
Definition: log.h:289
LY_LOG_LEVEL level
Definition: log.h:288
char * path
Definition: log.h:292
struct ly_err_item * ly_err_first(const struct ly_ctx *ctx)
Get the first (thread, context-specific) generated error structure.
void ly_err_clean(struct ly_ctx *ctx, struct ly_err_item *eitem)
Free error structures from a context.
LY_ERR ly_errcode(const struct ly_ctx *ctx)
Get the last (thread, context-specific) error code.
struct ly_err_item * ly_err_last(const struct ly_ctx *ctx)
Get the latest (thread, context-specific) generated error structure.
LY_VECODE
libyang's codes of validation error. Whenever ly_errno is set to LY_EVALID, the ly_vecode is also set...
Definition: log.h:269
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...
void ly_err_print(const struct ly_ctx *ctx, struct ly_err_item *eitem)
Print the error structure as if just generated.
const char * ly_errpath(const struct ly_ctx *ctx)
Get the last (thread, context-specific) path of the element where was an error.
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
libyang's error codes returned by the libyang functions.
Definition: log.h:242
LY_VECODE ly_vecode(const struct ly_ctx *ctx)
Get the last (thread, context-specific) validation error code.
@ LYVE_OTHER
Definition: log.h:281
@ LYVE_SYNTAX_JSON
Definition: log.h:278
@ LYVE_SYNTAX
Definition: log.h:271
@ LYVE_SYNTAX_XML
Definition: log.h:277
@ LYVE_DATA
Definition: log.h:279
@ LYVE_XPATH
Definition: log.h:275
@ LYVE_SEMANTICS
Definition: log.h:276
@ LYVE_SYNTAX_YANG
Definition: log.h:272
@ LYVE_SUCCESS
Definition: log.h:270
@ LYVE_REFERENCE
Definition: log.h:274
@ LYVE_SYNTAX_YIN
Definition: log.h:273
@ LY_EOTHER
Definition: log.h:257
@ LY_EDENIED
Definition: log.h:251
@ LY_EINVAL
Definition: log.h:246
@ LY_ESYS
Definition: log.h:245
@ LY_EMEM
Definition: log.h:244
@ LY_EEXIST
Definition: log.h:247
@ LY_ENOT
Definition: log.h:256
@ LY_EVALID
Definition: log.h:250
@ LY_EINT
Definition: log.h:249
@ LY_ENOTFOUND
Definition: log.h:248
@ LY_SUCCESS
Definition: log.h:243
@ LY_EPLUGIN
Definition: log.h:259
@ LY_ERECOMPILE
Definition: log.h:254
@ LY_EINCOMPLETE
Definition: log.h:252
Libyang full error structure.
Definition: log.h:287
uint32_t ly_log_dbg_groups(uint32_t dbg_groups)
Enable specific debugging messages (independent of log level).
LY_LOG_LEVEL ly_log_level(LY_LOG_LEVEL level)
Set logger verbosity level.
uint32_t ly_log_options(uint32_t opts)
Set logger options. Default is LY_LOLOG | LY_LOSTORE_LAST.
ly_log_clb ly_get_log_clb(void)
Get logger callback.
LY_LOG_LEVEL
Verbosity levels of the libyang logger.
Definition: log.h:86
void(* ly_log_clb)(LY_LOG_LEVEL level, const char *msg, const char *path)
Logger callback.
Definition: log.h:178
void ly_set_log_clb(ly_log_clb clb, ly_bool path)
Set logger callback.
@ LY_LLERR
Definition: log.h:87
@ LY_LLVRB
Definition: log.h:89
@ LY_LLWRN
Definition: log.h:88
@ LY_LLDBG
Definition: log.h:90
uint8_t ly_bool
Type to indicate boolean value.
Definition: log.h:25