libyang  2.0.164
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 #include "config.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 /* dummy context structure */
27 struct ly_ctx;
28 
34 typedef uint8_t ly_bool;
35 
87 typedef enum
88 {
89  LY_LLERR = 0,
90  LY_LLWRN = 1,
91  LY_LLVRB = 2,
92  LY_LLDBG = 3
95 
104 LIBYANG_API_DECL LY_LOG_LEVEL ly_log_level(LY_LOG_LEVEL level);
105 
116 #define LY_LOLOG 0x01
118 #define LY_LOSTORE 0x02
120 #define LY_LOSTORE_LAST 0x06
135 LIBYANG_API_DECL uint32_t ly_log_options(uint32_t opts);
136 
137 #ifndef NDEBUG
138 
150 #define LY_LDGDICT 0x01
151 #define LY_LDGXPATH 0x02
152 #define LY_LDGDEPSETS 0x04
166 uint32_t ly_log_dbg_groups(uint32_t dbg_groups);
167 
168 #endif
169 
181 typedef void (*ly_log_clb)(LY_LOG_LEVEL level, const char *msg, const char *path);
182 
193 LIBYANG_API_DECL void ly_set_log_clb(ly_log_clb clb, ly_bool path);
194 
199 LIBYANG_API_DECL ly_log_clb ly_get_log_clb(void);
200 
244 typedef enum {
256  LY_ERECOMPILE,
261  LY_EPLUGIN = 128
264 
271 typedef enum {
283  LYVE_OTHER
285 
289 struct ly_err_item {
293  char *msg;
294  char *path;
295  char *apptag;
296  struct ly_err_item *next;
297  struct ly_err_item *prev; /* first item's prev points to the last item */
298 };
299 
308 LIBYANG_API_DECL LY_VECODE ly_vecode(const struct ly_ctx *ctx);
309 
316 LIBYANG_API_DECL LY_ERR ly_errcode(const struct ly_ctx *ctx);
317 
328 LIBYANG_API_DECL const char *ly_errmsg(const struct ly_ctx *ctx);
329 
343 LIBYANG_API_DECL const char *ly_errpath(const struct ly_ctx *ctx);
344 
355 LIBYANG_API_DECL const char *ly_errapptag(const struct ly_ctx *ctx);
356 
363 LIBYANG_API_DECL struct ly_err_item *ly_err_first(const struct ly_ctx *ctx);
364 
371 LIBYANG_API_DECL struct ly_err_item *ly_err_last(const struct ly_ctx *ctx);
372 
379 LIBYANG_API_DECL void ly_err_print(const struct ly_ctx *ctx, struct ly_err_item *eitem);
380 
389 LIBYANG_API_DECL void ly_err_clean(struct ly_ctx *ctx, struct ly_err_item *eitem);
390 
393 #ifdef __cplusplus
394 }
395 #endif
396 
397 #endif /* LY_LOG_H_ */
LYVE_SEMANTICS
@ LYVE_SEMANTICS
Definition: log.h:278
LY_LLERR
@ LY_LLERR
Definition: log.h:89
LY_ENOT
@ LY_ENOT
Definition: log.h:258
LYVE_OTHER
@ LYVE_OTHER
Definition: log.h:283
LY_EINT
@ LY_EINT
Definition: log.h:251
LY_EEXIST
@ LY_EEXIST
Definition: log.h:249
LY_EOTHER
@ LY_EOTHER
Definition: log.h:259
LY_LLVRB
@ LY_LLVRB
Definition: log.h:91
LYVE_SUCCESS
@ LYVE_SUCCESS
Definition: log.h:272
LYVE_REFERENCE
@ LYVE_REFERENCE
Definition: log.h:276
ly_err_item::apptag
char * apptag
Definition: log.h:295
LY_SUCCESS
@ LY_SUCCESS
Definition: log.h:245
LY_EPLUGIN
@ LY_EPLUGIN
Definition: log.h:261
LY_LOG_LEVEL
LY_LOG_LEVEL
Verbosity levels of the libyang logger.
Definition: log.h:88
LYVE_DATA
@ LYVE_DATA
Definition: log.h:281
LY_EINCOMPLETE
@ LY_EINCOMPLETE
Definition: log.h:254
ly_bool
uint8_t ly_bool
Type to indicate boolean value.
Definition: log.h:27
LYVE_SYNTAX_YIN
@ LYVE_SYNTAX_YIN
Definition: log.h:275
LYVE_SYNTAX
@ LYVE_SYNTAX
Definition: log.h:273
ly_errmsg
LIBYANG_API_DECL 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_errpath
LIBYANG_API_DECL const char * ly_errpath(const struct ly_ctx *ctx)
Get the last (thread, context-specific) path of the element where was an error.
LY_EINVAL
@ LY_EINVAL
Definition: log.h:248
ly_err_item::msg
char * msg
Definition: log.h:293
ly_err_item::prev
struct ly_err_item * prev
Definition: log.h:297
LYVE_XPATH
@ LYVE_XPATH
Definition: log.h:277
ly_err_item
Libyang full error structure.
Definition: log.h:289
LY_EDENIED
@ LY_EDENIED
Definition: log.h:253
LY_ERECOMPILE
@ LY_ERECOMPILE
Definition: log.h:256
ly_errcode
LIBYANG_API_DECL LY_ERR ly_errcode(const struct ly_ctx *ctx)
Get the last (thread, context-specific) error code.
ly_get_log_clb
LIBYANG_API_DECL ly_log_clb ly_get_log_clb(void)
Get logger callback.
ly_set_log_clb
LIBYANG_API_DECL void ly_set_log_clb(ly_log_clb clb, ly_bool path)
Set logger callback.
ly_errapptag
LIBYANG_API_DECL 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...
LYVE_SYNTAX_XML
@ LYVE_SYNTAX_XML
Definition: log.h:279
ly_ctx
libyang context handler.
ly_err_item::path
char * path
Definition: log.h:294
LYVE_SYNTAX_YANG
@ LYVE_SYNTAX_YANG
Definition: log.h:274
LY_ESYS
@ LY_ESYS
Definition: log.h:247
LY_VECODE
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:271
ly_err_first
LIBYANG_API_DECL struct ly_err_item * ly_err_first(const struct ly_ctx *ctx)
Get the first (thread, context-specific) generated error structure.
ly_err_clean
LIBYANG_API_DECL void ly_err_clean(struct ly_ctx *ctx, struct ly_err_item *eitem)
Free error structures from a context.
LY_EVALID
@ LY_EVALID
Definition: log.h:252
LY_LLWRN
@ LY_LLWRN
Definition: log.h:90
LY_EMEM
@ LY_EMEM
Definition: log.h:246
LYVE_SYNTAX_JSON
@ LYVE_SYNTAX_JSON
Definition: log.h:280
ly_vecode
LIBYANG_API_DECL LY_VECODE ly_vecode(const struct ly_ctx *ctx)
Get the last (thread, context-specific) validation error code.
ly_err_item::level
LY_LOG_LEVEL level
Definition: log.h:290
LY_ERR
LY_ERR
libyang's error codes returned by the libyang functions.
Definition: log.h:244
ly_log_level
LIBYANG_API_DECL LY_LOG_LEVEL ly_log_level(LY_LOG_LEVEL level)
Set logger verbosity level.
ly_err_item::vecode
LY_VECODE vecode
Definition: log.h:292
LY_LLDBG
@ LY_LLDBG
Definition: log.h:92
ly_log_clb
void(* ly_log_clb)(LY_LOG_LEVEL level, const char *msg, const char *path)
Logger callback.
Definition: log.h:181
ly_err_last
LIBYANG_API_DECL struct ly_err_item * ly_err_last(const struct ly_ctx *ctx)
Get the latest (thread, context-specific) generated error structure.
ly_err_item::next
struct ly_err_item * next
Definition: log.h:296
ly_err_item::no
LY_ERR no
Definition: log.h:291
LY_ENOTFOUND
@ LY_ENOTFOUND
Definition: log.h:250
ly_err_print
LIBYANG_API_DECL void ly_err_print(const struct ly_ctx *ctx, struct ly_err_item *eitem)
Print the error structure as if just generated.