libyang  2.1.30
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 
16 #ifndef LY_LOG_H_
17 #define LY_LOG_H_
18 
19 #include <stdint.h>
20 
21 #include "config.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* dummy context structure */
28 struct ly_ctx;
29 
35 typedef uint8_t ly_bool;
36 
88 typedef enum {
89  LY_LLERR = 0,
90  LY_LLWRN = 1,
91  LY_LLVRB = 2,
92  LY_LLDBG = 3
94 } LY_LOG_LEVEL;
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 
142 LIBYANG_API_DECL void ly_temp_log_options(uint32_t *opts);
143 
144 #ifndef NDEBUG
145 
157 #define LY_LDGDICT 0x01
158 #define LY_LDGXPATH 0x02
159 #define LY_LDGDEPSETS 0x04
173 uint32_t ly_log_dbg_groups(uint32_t dbg_groups);
174 
175 #endif
176 
188 typedef void (*ly_log_clb)(LY_LOG_LEVEL level, const char *msg, const char *path);
189 
200 LIBYANG_API_DECL void ly_set_log_clb(ly_log_clb clb, ly_bool path);
201 
206 LIBYANG_API_DECL ly_log_clb ly_get_log_clb(void);
207 
251 typedef enum {
252  LY_SUCCESS = 0,
253  LY_EMEM,
265  LY_ENOT,
270 } LY_ERR;
278 typedef enum {
279  LYVE_SUCCESS = 0,
280  LYVE_SYNTAX,
292 
296 struct ly_err_item {
298  LY_ERR no;
300  char *msg;
301  char *path;
302  char *apptag;
303  struct ly_err_item *next;
304  struct ly_err_item *prev; /* first item's prev points to the last item */
305 };
315 LIBYANG_API_DECL LY_VECODE ly_vecode(const struct ly_ctx *ctx);
316 
323 LIBYANG_API_DECL LY_ERR ly_errcode(const struct ly_ctx *ctx);
324 
335 LIBYANG_API_DECL const char *ly_errmsg(const struct ly_ctx *ctx);
336 
350 LIBYANG_API_DECL const char *ly_errpath(const struct ly_ctx *ctx);
351 
362 LIBYANG_API_DECL const char *ly_errapptag(const struct ly_ctx *ctx);
363 
370 LIBYANG_API_DECL struct ly_err_item *ly_err_first(const struct ly_ctx *ctx);
371 
378 LIBYANG_API_DECL struct ly_err_item *ly_err_last(const struct ly_ctx *ctx);
379 
386 LIBYANG_API_DECL void ly_err_print(const struct ly_ctx *ctx, struct ly_err_item *eitem);
387 
396 LIBYANG_API_DECL void ly_err_clean(struct ly_ctx *ctx, struct ly_err_item *eitem);
397 
400 #ifdef __cplusplus
401 }
402 #endif
403 
404 #endif /* LY_LOG_H_ */
LY_LOG_LEVEL level
Definition: log.h:300
LIBYANG_API_DECL LY_VECODE ly_vecode(const struct ly_ctx *ctx)
Get the last (thread, context-specific) validation error code.
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.
Definition: log.h:256
uint8_t ly_bool
Type to indicate boolean value.
Definition: log.h:28
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 ...
Definition: log.h:269
LIBYANG_API_DECL void ly_set_log_clb(ly_log_clb clb, ly_bool path)
Set logger callback.
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:281
char * apptag
Definition: log.h:305
LIBYANG_API_DECL void ly_temp_log_options(uint32_t *opts)
Set temporary thread-safe logger options overwriting those set by ly_log_options().
char * msg
Definition: log.h:303
LIBYANG_API_DECL LY_ERR ly_errcode(const struct ly_ctx *ctx)
Get the last (thread, context-specific) error code.
void(* ly_log_clb)(LY_LOG_LEVEL level, const char *msg, const char *path)
Logger callback.
Definition: log.h:191
Definition: log.h:261
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.
char * path
Definition: log.h:304
Definition: log.h:90
Libyang full error structure.
Definition: log.h:299
Definition: log.h:291
LY_LOG_LEVEL
Verbosity levels of the libyang logger.
Definition: log.h:88
Definition: log.h:262
LIBYANG_API_DECL ly_log_clb ly_get_log_clb(void)
Get logger callback.
Definition: log.h:91
struct ly_err_item * prev
Definition: log.h:307
Definition: log.h:92
Definition: log.h:89
LIBYANG_API_DECL LY_LOG_LEVEL ly_log_level(LY_LOG_LEVEL level)
Set logger verbosity level.
LIBYANG_API_DECL void ly_err_clean(struct ly_ctx *ctx, struct ly_err_item *eitem)
Free error structures from a context.
Definition: log.h:268
Definition: log.h:259
LY_VECODE vecode
Definition: log.h:302
LIBYANG_API_DECL struct ly_err_item * ly_err_last(const struct ly_ctx *ctx)
Get the latest (thread, context-specific) generated error structure.
struct ly_err_item * next
Definition: log.h:306
Definition: log.h:257
LY_ERR
libyang&#39;s error codes returned by the libyang functions.
Definition: log.h:254
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...
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 no
Definition: log.h:301
libyang context handler.
Definition: log.h:258