libyang  1.0.130
YANG data modeling language library
Logger

There are 4 verbosity levels defined as LY_LOG_LEVEL. The level can be changed by the ly_verb() function. By default, the verbosity level is set to LY_LLERR value.

All the logging operations are tied to the specific thread and context. The default behaviour is that the last message (error or warning, verbose and debug messages are never stored) is always stored and can be accessed using ly_errmsg(). On error, ly_errno is set. If that was a validation error (ly_errno is set to LY_EVALID), also validation error code (via ly_vecode()) and path to the error node (via ly_errpath()) are available.

For some specific cases, a YANG schema can define error message and/or error tag (mainly for use in NETCONF). If a message is set, it is provided via ly_errmsg(). If a tag is set in schema, it is available via ly_errapptag() (if not set, the returned string is empty).

By default, all libyang messages are printed to stderr. However, the caller is able to set their own logging callback function. In that case, instead of printing messages, libyang passes error level, message and path (if any) to the caller's callback function. In case of error level, the message and path are still automatically stored and available via the functions and macros described above.

This is the basic way of working with errors but another, more sophisticated is also available. With ly_log_options() you can modify what is done with all the messages. Default flags are LY_LOLOG and LY_LOSTORE_LAST so that messages are logged and the last one is stored. If you set the flag LY_LOSTORE, all the messages will be stored. Be careful because unless you regularly clean them, the error list will grow indefinitely. With ly_err_first() you can retrieve the first generated error structure ly_err_item. It is a linked-list so you can get next errors using the next pointer. Being processed (for instance printed with ly_err_print()), you can then free them with ly_err_clean().

Note
API for this group of functions is described in the logger module.

Functions List