libyang  5.5.3
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 "ly_config.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 struct ly_ctx;
28 struct lyd_node;
29 struct lysc_node;
30 
36 typedef uint8_t ly_bool;
37 
89 typedef enum {
90  LY_LLERR = 0,
91  LY_LLWRN = 1,
92  LY_LLVRB = 2,
93  LY_LLDBG = 3
95 } LY_LOG_LEVEL;
96 
107 LIBYANG_API_DECL LY_LOG_LEVEL ly_log_level(LY_LOG_LEVEL level);
108 
119 #define LY_LOLOG 0x01
121 #define LY_LOSTORE 0x02
123 #define LY_LOSTORE_LAST 0x06
138 LIBYANG_API_DECL uint32_t ly_log_options(uint32_t opts);
139 
146 LIBYANG_API_DECL uint32_t *ly_temp_log_options(uint32_t *opts);
147 
159 #define LY_LDGDICT 0x01
160 #define LY_LDGXPATH 0x02
161 #define LY_LDGDEPSETS 0x04
176 LIBYANG_API_DECL uint32_t ly_log_dbg_groups(uint32_t dbg_groups);
177 
187 typedef void (*ly_log_clb)(LY_LOG_LEVEL level, const char *msg, const char *data_path, const char *schema_path,
188  uint64_t line);
189 
197 LIBYANG_API_DECL void ly_set_log_clb(ly_log_clb clb);
198 
204 LIBYANG_API_DECL ly_log_clb ly_get_log_clb(void);
205 
214 LIBYANG_API_DECL ly_log_clb ly_temp_log_clb(ly_log_clb clb);
215 
252 typedef enum {
253  LY_SUCCESS = 0,
254  LY_EMEM,
266  LY_ENOT,
271 } LY_ERR;
279 typedef enum {
280  LYVE_SUCCESS = 0,
281  LYVE_SYNTAX,
293 
297 struct ly_err_item {
299  LY_ERR err;
301  char *msg;
302  char *data_path;
303  char *schema_path;
304  uint64_t line;
305  char *apptag;
306  struct ly_err_item *next;
307  struct ly_err_item *prev;
308 };
316 LIBYANG_API_DECL const char *ly_strerr(LY_ERR err);
317 
324 LIBYANG_API_DECL const char *ly_strvecode(LY_VECODE vecode);
325 
334 LIBYANG_API_DECL const char *ly_last_logmsg(void);
335 
342 LIBYANG_API_DECL const struct ly_err_item *ly_err_first(const struct ly_ctx *ctx);
343 
350 LIBYANG_API_DECL const struct ly_err_item *ly_err_last(const struct ly_ctx *ctx);
351 
360 LIBYANG_API_DECL void ly_err_print(const struct ly_ctx *ctx, const struct ly_err_item *eitem,
361  const struct lyd_node *lnode, const struct lysc_node *snode);
362 
371 LIBYANG_API_DECL void ly_err_clean(const struct ly_ctx *ctx, struct ly_err_item *eitem);
372 
375 #ifdef __cplusplus
376 }
377 #endif
378 
379 #endif /* LY_LOG_H_ */
LY_LOG_LEVEL level
Definition: log.h:301
Compiled YANG data node.
Definition: tree_schema.h:1431
char * schema_path
Definition: log.h:306
Generic structure for a data node.
Definition: tree_data.h:783
LIBYANG_API_DECL void ly_err_clean(const struct ly_ctx *ctx, struct ly_err_item *eitem)
Free error structures from a context.
LIBYANG_API_DECL uint32_t * ly_temp_log_options(uint32_t *opts)
Set temporary thread-safe (thread-specific) logger options overwriting those set by ly_log_options()...
LY_ERR
libyang&#39;s error codes returned by the libyang functions.
Definition: log.h:255
uint8_t ly_bool
Type to indicate boolean value.
Definition: log.h:29
LY_ERR err
Definition: log.h:302
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:282
Definition: log.h:269
char * apptag
Definition: log.h:308
Definition: log.h:258
char * msg
Definition: log.h:304
LIBYANG_API_DECL void ly_err_print(const struct ly_ctx *ctx, const struct ly_err_item *eitem, const struct lyd_node *lnode, const struct lysc_node *snode)
Print the error structure as if just generated.
Definition: log.h:259
LIBYANG_API_DECL const char * ly_strvecode(LY_VECODE vecode)
Get human-readable error message for a validation error code.
Definition: log.h:257
Definition: log.h:262
LIBYANG_API_DECL void ly_set_log_clb(ly_log_clb clb)
Set global logger callback.
Definition: log.h:91
Libyang full error structure.
Definition: log.h:300
Definition: log.h:292
LY_LOG_LEVEL
Verbosity levels of the libyang logger.
Definition: log.h:89
LIBYANG_API_DECL ly_log_clb ly_get_log_clb(void)
Get global logger callback.
LIBYANG_API_DECL const char * ly_strerr(LY_ERR err)
Get human-readable error message for an error code.
Definition: log.h:92
struct ly_err_item * prev
Definition: log.h:310
Definition: log.h:93
Definition: log.h:260
Definition: log.h:90
Definition: log.h:263
LIBYANG_API_DECL LY_LOG_LEVEL ly_log_level(LY_LOG_LEVEL level)
Set logger verbosity level.
LY_VECODE vecode
Definition: log.h:303
LIBYANG_API_DECL struct ly_err_item * ly_err_last(const struct ly_ctx *ctx)
Get the latest (thread, context-specific) generated error structure.
LIBYANG_API_DECL const char * ly_last_logmsg(void)
Get the last (thread-specific) full logged error message.
struct ly_err_item * next
Definition: log.h:309
void(* ly_log_clb)(LY_LOG_LEVEL level, const char *msg, const char *data_path, const char *schema_path, uint64_t line)
Logger callback.
Definition: log.h:190
Definition: log.h:270
uint64_t line
Definition: log.h:307
LIBYANG_API_DECL struct ly_err_item * ly_err_first(const struct ly_ctx *ctx)
Get the first (thread, context-specific) generated error structure.
LIBYANG_API_DECL ly_log_clb ly_temp_log_clb(ly_log_clb clb)
Set temporary thread-safe (thread-specific) logger callback ovewriting that set by ly_set_log_clb...
libyang context handler.
char * data_path
Definition: log.h:305