libyang  1.0.184
YANG data modeling language library
Logger
Collaboration diagram for Logger:

Modules

 Logging options
 
 Debug message groups
 

Data Structures

struct  ly_err_item
 Libyang full error structure. More...
 

Macros

#define ly_errno   (*ly_errno_glob_address())
 libyang specific (thread-safe) errno (see LY_ERR for the list of possible values and their meaning). More...
 

Enumerations

enum  LY_LOG_LEVEL { LY_LLERR = 0, LY_LLWRN = 1, LY_LLVRB = 2, LY_LLDBG = 3 }
 Verbosity levels of the libyang logger. More...
 
enum  LY_ERR {
  LY_SUCCESS = 0, LY_EMEM, LY_ESYS, LY_EINVAL,
  LY_EINT, LY_EVALID, LY_EPLUGIN
}
 libyang's error codes available via ly_errno extern variable. More...
 
enum  LY_VECODE {
  LYVE_SUCCESS = 0, LYVE_XML_MISS, LYVE_XML_INVAL, LYVE_XML_INCHAR,
  LYVE_EOF, LYVE_INSTMT, LYVE_INPAR, LYVE_INID,
  LYVE_INDATE, LYVE_INARG, LYVE_MISSSTMT, LYVE_MISSARG,
  LYVE_TOOMANY, LYVE_DUPID, LYVE_DUPLEAFLIST, LYVE_DUPLIST,
  LYVE_NOUNIQ, LYVE_ENUM_INVAL, LYVE_ENUM_INNAME, LYVE_ENUM_WS,
  LYVE_BITS_INVAL, LYVE_BITS_INNAME, LYVE_INMOD, LYVE_KEY_NLEAF,
  LYVE_KEY_TYPE, LYVE_KEY_CONFIG, LYVE_KEY_MISS, LYVE_KEY_DUP,
  LYVE_INREGEX, LYVE_INRESOLV, LYVE_INSTATUS, LYVE_CIRC_LEAFREFS,
  LYVE_CIRC_FEATURES, LYVE_CIRC_IMPORTS, LYVE_CIRC_INCLUDES, LYVE_INVER,
  LYVE_SUBMODULE, LYVE_OBSDATA, LYVE_NORESOLV, LYVE_INELEM,
  LYVE_MISSELEM, LYVE_INVAL, LYVE_INMETA, LYVE_INATTR,
  LYVE_MISSATTR, LYVE_NOCONSTR, LYVE_INCHAR, LYVE_INPRED,
  LYVE_MCASEDATA, LYVE_NOMUST, LYVE_NOWHEN, LYVE_INORDER,
  LYVE_INWHEN, LYVE_NOMIN, LYVE_NOMAX, LYVE_NOREQINS,
  LYVE_NOLEAFREF, LYVE_NOMANDCHOICE, LYVE_XPATH_INTOK, LYVE_XPATH_EOF,
  LYVE_XPATH_INOP, LYVE_XPATH_INCTX, LYVE_XPATH_INMOD, LYVE_XPATH_INFUNC,
  LYVE_XPATH_INARGCOUNT, LYVE_XPATH_INARGTYPE, LYVE_XPATH_DUMMY, LYVE_XPATH_NOEND,
  LYVE_PATH_INCHAR, LYVE_PATH_INMOD, LYVE_PATH_MISSMOD, LYVE_PATH_INNODE,
  LYVE_PATH_INKEY, LYVE_PATH_MISSKEY, LYVE_PATH_INIDENTREF, LYVE_PATH_EXISTS,
  LYVE_PATH_MISSPAR, LYVE_PATH_PREDTOOMANY
}
 libyang's codes of validation error. Whenever ly_errno is set to LY_EVALID, the ly_vecode is also set to the appropriate LY_VECODE value. More...
 

Functions

LY_LOG_LEVEL ly_verb (LY_LOG_LEVEL level)
 Set logger verbosity level. More...
 
int ly_log_options (int opts)
 Set additional logger options. Default is LY_LOLOG | LY_LOSTORE_LAST. More...
 
void ly_verb_dbg (int dbg_groups)
 Enable specific debugging messages (independent of log level). More...
 
void ly_set_log_clb (void(*clb)(LY_LOG_LEVEL level, const char *msg, const char *path), int path)
 Set logger callback. More...
 
LY_VECODE ly_vecode (const struct ly_ctx *ctx)
 Get the last (thread, context-specific) validation error code. More...
 
const char * ly_errmsg (const struct ly_ctx *ctx)
 Get the last (thread, context-specific) error message. If the corresponding module defined a specific error message, it will be used instead the default one. More...
 
const char * ly_errpath (const struct ly_ctx *ctx)
 Get the last (thread, context-specific) path of the element where was an error. More...
 
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 module for the last error. More...
 
struct ly_err_itemly_err_first (const struct ly_ctx *ctx)
 Get the first (thread, context-specific) generated error structure. More...
 
void ly_err_print (struct ly_err_item *eitem)
 Print the error structure as if just generated. More...
 
void ly_err_clean (struct ly_ctx *ctx, struct ly_err_item *eitem)
 Free error structures from a context. More...
 

Variables

void(*)(LY_LOG_LEVEL, const char *, const char *) ly_get_log_clb (void)
 Get logger callback. More...
 

Detailed Description

Publicly visible functions and values of the libyang logger. For more information, see Logger.


Data Structure Documentation

◆ ly_err_item

struct ly_err_item

Libyang full error structure.

Definition at line 2163 of file libyang.h.

Data Fields
LY_LOG_LEVEL level
LY_ERR no
LY_VECODE vecode
char * msg
char * path
char * apptag
struct ly_err_item * next
struct ly_err_item * prev

Macro Definition Documentation

◆ ly_errno

#define ly_errno   (*ly_errno_glob_address())

libyang specific (thread-safe) errno (see LY_ERR for the list of possible values and their meaning).

INTERNAL

Definition at line 2109 of file libyang.h.

Enumeration Type Documentation

◆ LY_LOG_LEVEL

Verbosity levels of the libyang logger.

Enumerator
LY_LLERR 

Print only error messages, default value.

LY_LLWRN 

Print error and warning messages.

LY_LLVRB 

Besides errors and warnings, print some other verbose messages.

LY_LLDBG 

Print all messages including some development debug messages (be careful, without subsequently calling ly_verb_dbg() no debug messages will be printed!).

Definition at line 1884 of file libyang.h.

◆ LY_ERR

enum LY_ERR

libyang's error codes available via ly_errno extern variable.

Enumerator
LY_SUCCESS 

no error, not set by functions, included just to complete LY_ERR enumeration

LY_EMEM 

Memory allocation failure

LY_ESYS 

System call failure

LY_EINVAL 

Invalid value

LY_EINT 

Internal error

LY_EVALID 

Validation failure

LY_EPLUGIN 

Error reported by a plugin

Definition at line 1987 of file libyang.h.

◆ LY_VECODE

enum LY_VECODE

libyang's codes of validation error. Whenever ly_errno is set to LY_EVALID, the ly_vecode is also set to the appropriate LY_VECODE value.

Enumerator
LYVE_SUCCESS 

no error

LYVE_XML_MISS 

missing XML object

LYVE_XML_INVAL 

invalid XML object

LYVE_XML_INCHAR 

invalid XML character

LYVE_EOF 

unexpected end of input data

LYVE_INSTMT 

invalid statement (schema)

LYVE_INPAR 

invalid (in)direct parent (schema)

LYVE_INID 

invalid identifier (schema)

LYVE_INDATE 

invalid date format

LYVE_INARG 

invalid value of a statement argument (schema)

LYVE_MISSSTMT 

missing required statement (schema)

LYVE_MISSARG 

missing required statement argument (schema)

LYVE_TOOMANY 

too many instances of some object

LYVE_DUPID 

duplicated identifier (schema)

LYVE_DUPLEAFLIST 

multiple instances of leaf-list

LYVE_DUPLIST 

multiple instances of list

LYVE_NOUNIQ 

unique leaves match on 2 list instances (data)

LYVE_ENUM_INVAL 

invalid enum value (schema)

LYVE_ENUM_INNAME 

invalid enum name (schema)

LYVE_ENUM_WS 

enum name with leading/trailing whitespaces (schema)

LYVE_BITS_INVAL 

invalid bits value (schema)

LYVE_BITS_INNAME 

invalid bits name (schema)

LYVE_INMOD 

invalid module name

LYVE_KEY_NLEAF 

list key is not a leaf (schema)

LYVE_KEY_TYPE 

invalid list key type (schema)

LYVE_KEY_CONFIG 

key config value differs from the list config value

LYVE_KEY_MISS 

list key not found (schema)

LYVE_KEY_DUP 

duplicated key identifier (schema)

LYVE_INREGEX 

invalid regular expression (schema)

LYVE_INRESOLV 

no resolvents found (schema)

LYVE_INSTATUS 

invalid derivation because of status (schema)

LYVE_CIRC_LEAFREFS 

circular chain of leafrefs detected (schema)

LYVE_CIRC_FEATURES 

circular chain of features detected (schema)

LYVE_CIRC_IMPORTS 

circular chain of imports detected (schema)

LYVE_CIRC_INCLUDES 

circular chain of includes detected (schema)

LYVE_INVER 

non-matching YANG versions of module and its submodules (schema)

LYVE_SUBMODULE 

submodule given instead of a module

LYVE_OBSDATA 

obsolete data instantiation (data)

LYVE_NORESOLV 

no resolvents found for an expression (data)

LYVE_INELEM 

invalid element (data)

LYVE_MISSELEM 

missing required element (data)

LYVE_INVAL 

invalid value of an element (data)

LYVE_INMETA 

invalid metadata (attribute) value (data)

LYVE_INATTR 

invalid attribute in an element (data)

LYVE_MISSATTR 

missing attribute in an element (data)

LYVE_NOCONSTR 

value out of range/length/pattern (data)

LYVE_INCHAR 

unexpected characters (data)

LYVE_INPRED 

predicate resolution fail (data)

LYVE_MCASEDATA 

data for more cases of a choice (data)

LYVE_NOMUST 

unsatisfied must condition (data)

LYVE_NOWHEN 

unsatisfied when condition (data)

LYVE_INORDER 

invalid order of elements (data)

LYVE_INWHEN 

irresolvable when condition (data)

LYVE_NOMIN 

min-elements constraint not honored (data)

LYVE_NOMAX 

max-elements constraint not honored (data)

LYVE_NOREQINS 

required instance does not exits (data)

LYVE_NOLEAFREF 

leaf pointed to by leafref does not exist (data)

LYVE_NOMANDCHOICE 

no mandatory choice case branch exists (data)

LYVE_XPATH_INTOK 

unexpected XPath token

LYVE_XPATH_EOF 

unexpected end of an XPath expression

LYVE_XPATH_INOP 

invalid XPath operation operands

LYVE_XPATH_INCTX 

invalid XPath context type

LYVE_XPATH_INMOD 

invalid module name

LYVE_XPATH_INFUNC 

invalid XPath function name

LYVE_XPATH_INARGCOUNT 

invalid number of arguments for an XPath function

LYVE_XPATH_INARGTYPE 

invalid type of arguments for an XPath function

LYVE_XPATH_DUMMY 

invalid use of the XPath dummy node

LYVE_XPATH_NOEND 

unterminated string

LYVE_PATH_INCHAR 

invalid characters (path)

LYVE_PATH_INMOD 

invalid module name (path)

LYVE_PATH_MISSMOD 

missing module name (path)

LYVE_PATH_INNODE 

invalid node name (path)

LYVE_PATH_INKEY 

invalid key name (path)

LYVE_PATH_MISSKEY 

missing some list keys (path)

LYVE_PATH_INIDENTREF 

missing module name prefix in identityref predicate value (path)

LYVE_PATH_EXISTS 

target node already exists (path)

LYVE_PATH_MISSPAR 

some parent of the target node is missing (path)

LYVE_PATH_PREDTOOMANY 

too many predicates specified (path)

Definition at line 2003 of file libyang.h.

Function Documentation

◆ ly_verb()

LY_LOG_LEVEL ly_verb ( LY_LOG_LEVEL  level)

Set logger verbosity level.

Parameters
[in]levelVerbosity level.
Returns
Previous verbosity level.

◆ ly_log_options()

int ly_log_options ( int  opts)

Set additional logger options. Default is LY_LOLOG | LY_LOSTORE_LAST.

Parameters
[in]optsBitfield of Logging options.
Returns
Previous logger options.

◆ ly_verb_dbg()

void ly_verb_dbg ( int  dbg_groups)

Enable specific debugging messages (independent of log level).

Parameters
[in]dbg_groupsBitfield of enabled debug message groups (see Debug message groups).

◆ ly_set_log_clb()

void ly_set_log_clb ( void(*)(LY_LOG_LEVEL level, const char *msg, const char *path)  clb,
int  path 
)

Set logger callback.

!IMPORTANT! If an error has a specific error-app-tag defined in the model, it will NOT be set at the time of calling this callback. It will be set right after, so to retrieve it it must be checked afterwards with ly_errapptag().

Parameters
[in]clbLogging callback.
[in]pathflag to resolve and provide path as the third parameter of the callback function. In case of validation and some other errors, it can be useful to get the path to the problematic element. Note, that according to the tree type and the specific situation, the path can slightly differs (keys presence) or it can be NULL, so consider it as an optional parameter. If the flag is 0, libyang will not bother with resolving the path.

◆ ly_vecode()

LY_VECODE ly_vecode ( const struct ly_ctx ctx)

Get the last (thread, context-specific) validation error code.

This value is set only if ly_errno is LY_EVALID.

Parameters
[in]ctxRelative context.
Returns
Validation error code.

◆ ly_errmsg()

const char* ly_errmsg ( const struct ly_ctx ctx)

Get the last (thread, context-specific) error message. If the corresponding module defined a specific error message, it will be used instead the default one.

Sometimes, the error message is extended with path of the element where the problem is. The path is available via ly_errpath().

Parameters
[in]ctxRelative context.
Returns
Text of the last error message, empty string if there is no error.

◆ ly_errpath()

const char* ly_errpath ( const struct ly_ctx ctx)

Get the last (thread, context-specific) path of the element where was an error.

The path always corresponds to the error message available via ly_errmsg(), so whenever a subsequent error message is printed, the path is erased or rewritten. The path reflects the type of the processed tree - data path for data tree functions and schema path in case of schema tree functions. In case of processing YIN schema or XML data, the path can be just XML path. In such a case, the corresponding ly_vecode (value 1-3) is set.

Parameters
[in]ctxRelative context.
Returns
Path of the error element, empty string if error path does not apply to the last error.

◆ ly_errapptag()

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 module for the last error.

The app-tag always corresponds to the error message available via ly_errmsg(), so whenever a subsequent error message is printed, the app-tag is erased or rewritten.

Parameters
[in]ctxRelative context.
Returns
Error-app-tag of the last error, empty string if the error-app-tag does not apply to the last error.

◆ ly_err_first()

struct ly_err_item* ly_err_first ( const struct ly_ctx ctx)

Get the first (thread, context-specific) generated error structure.

Parameters
[in]ctxRelative context.
Returns
First error structure (can be NULL), do not modify!

◆ ly_err_print()

void ly_err_print ( struct ly_err_item eitem)

Print the error structure as if just generated.

Parameters
[in]eitemError item structure to print.

◆ ly_err_clean()

void ly_err_clean ( struct ly_ctx ctx,
struct ly_err_item eitem 
)

Free error structures from a context.

If eitem is not set, free all the error structures.

Parameters
[in]ctxRelative context.
[in]eitemOldest error structure to remove, optional.

Variable Documentation

◆ ly_get_log_clb

void(*)(LY_LOG_LEVEL, const char *, const char *) ly_get_log_clb(void)

Get logger callback.

Returns
Logger callback (can be NULL).

Definition at line 1980 of file libyang.h.