sysrepo  2.11.7
YANG-based system repository for all-around configuration management.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Logging API

Functions

sr_log_level_t sr_log_get_stderr (void)
 Learn current standard error output log level. More...
 
sr_log_level_t sr_log_get_syslog (void)
 Learn current system log log level. More...
 
void sr_log_set_cb (sr_log_cb log_callback)
 Sets callback that will be called when a log entry would be populated. Callback will be called for every message regardless of any log level. More...
 
void sr_log_stderr (sr_log_level_t log_level)
 Enables / disables / changes log level (verbosity) of logging to standard error output. More...
 
void sr_log_syslog (const char *app_name, sr_log_level_t log_level)
 Enables / disables / changes log level (verbosity) of logging to system log. More...
 
const char * sr_strerror (int err_code)
 Returns the error message corresponding to the error code. More...
 
enum  sr_error_t {
  SR_ERR_OK = 0, SR_ERR_INVAL_ARG, SR_ERR_LY, SR_ERR_SYS,
  SR_ERR_NO_MEMORY, SR_ERR_NOT_FOUND, SR_ERR_EXISTS, SR_ERR_INTERNAL,
  SR_ERR_UNSUPPORTED, SR_ERR_VALIDATION_FAILED, SR_ERR_OPERATION_FAILED, SR_ERR_UNAUTHORIZED,
  SR_ERR_LOCKED, SR_ERR_TIME_OUT, SR_ERR_CALLBACK_FAILED, SR_ERR_CALLBACK_SHELVE
}
 Sysrepo error codes. More...
 
enum  sr_log_level_t {
  SR_LL_NONE = 0, SR_LL_ERR, SR_LL_WRN, SR_LL_INF,
  SR_LL_DBG
}
 Log levels used to determine if message of certain severity should be printed. More...
 
typedef void(* sr_log_cb )(sr_log_level_t level, const char *message)
 Sets callback that will be called when a log entry would be populated. More...
 

Detailed Description

Typedef Documentation

typedef void(* sr_log_cb)(sr_log_level_t level, const char *message)

Sets callback that will be called when a log entry would be populated.

Parameters
[in]levelVerbosity level of the log entry.
[in]messageMessage of the log entry.

Definition at line 77 of file sysrepo_types.h.

Enumeration Type Documentation

enum sr_error_t

Sysrepo error codes.

Enumerator
SR_ERR_OK 

No error.

SR_ERR_INVAL_ARG 

Invalid argument.

SR_ERR_LY 

Error generated by libyang.

SR_ERR_SYS 

System function call failed.

SR_ERR_NO_MEMORY 

Not enough memory.

SR_ERR_NOT_FOUND 

Item not found.

SR_ERR_EXISTS 

Item already exists.

SR_ERR_INTERNAL 

Other internal error.

SR_ERR_UNSUPPORTED 

Unsupported operation requested.

SR_ERR_VALIDATION_FAILED 

Validation of the changes failed.

SR_ERR_OPERATION_FAILED 

An operation failed.

SR_ERR_UNAUTHORIZED 

Operation not authorized.

SR_ERR_LOCKED 

Requested resource is already locked.

SR_ERR_TIME_OUT 

Time out has expired.

SR_ERR_CALLBACK_FAILED 

User callback failure caused the operation to fail.

SR_ERR_CALLBACK_SHELVE 

User callback has not processed the event and will do so on some future event processing.

Definition at line 40 of file sysrepo_types.h.

Log levels used to determine if message of certain severity should be printed.

Enumerator
SR_LL_NONE 

Do not print any messages.

SR_LL_ERR 

Print only error messages.

SR_LL_WRN 

Print error and warning messages.

SR_LL_INF 

Besides errors and warnings, print some other informational messages.

SR_LL_DBG 

Print all messages including some development debug messages.

Definition at line 63 of file sysrepo_types.h.

Function Documentation

sr_log_level_t sr_log_get_stderr ( void  )

Learn current standard error output log level.

Returns
stderr log level.
sr_log_level_t sr_log_get_syslog ( void  )

Learn current system log log level.

Returns
syslog log level.
void sr_log_set_cb ( sr_log_cb  log_callback)

Sets callback that will be called when a log entry would be populated. Callback will be called for every message regardless of any log level.

Parameters
[in]log_callbackCallback to be called when a log entry would populated.
void sr_log_stderr ( sr_log_level_t  log_level)

Enables / disables / changes log level (verbosity) of logging to standard error output.

By default, logging to stderr is disabled. Setting log level to any value other than SR_LL_NONE enables the logging to stderr. Setting log level back to SR_LL_NONE disables the logging to stderr.

Parameters
[in]log_levelRequested log level (verbosity).
void sr_log_syslog ( const char *  app_name,
sr_log_level_t  log_level 
)

Enables / disables / changes log level (verbosity) of logging to system log.

By default, logging into syslog is disabled. Setting log level to any value other than SR_LL_NONE enables the logging into syslog. Setting log level back to SR_LL_NONE disables the logging into syslog.

Library messages are logged with LOG_USER facility and plugin (syrepo-plugind) messages are logged with LOG_DAEMON facility.

Note
Please note that enabling logging into syslog will overwrite your syslog connection settings (calls openlog), if you are connected to syslog already.
Parameters
[in]app_nameName of the application. If not set, "sysrepo" will be used.
[in]log_levelRequested log level (verbosity).
const char* sr_strerror ( int  err_code)

Returns the error message corresponding to the error code.

Parameters
[in]err_codeError code.
Returns
Error message (statically allocated, do not free).