diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2019-04-16 00:03:57 +0200 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2019-04-18 18:17:54 +0200 |
commit | c650e48c54c2f524a473781f019b059daf2fd8d0 (patch) | |
tree | c6b660c7d0432eae76ec2c7fa89d602331c7f340 /lib/northbound.c | |
parent | lib: move zlog() prototype back to the public logging API (diff) | |
download | frr-c650e48c54c2f524a473781f019b059daf2fd8d0.tar.xz frr-c650e48c54c2f524a473781f019b059daf2fd8d0.zip |
lib: introduce flog() to simplify the northbound code a little bit
flog() is a small wrapper around zlog() that can be useful in a
few places to reduce code duplication.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to '')
-rw-r--r-- | lib/northbound.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/northbound.c b/lib/northbound.c index fd92aaa9d..83c056957 100644 --- a/lib/northbound.c +++ b/lib/northbound.c @@ -753,40 +753,44 @@ static int nb_callback_configuration(const enum nb_event event, ret = (*nb_node->cbs.move)(event, dnode); break; default: - break; + flog_err(EC_LIB_DEVELOPMENT, + "%s: unknown operation (%u) [xpath %s]", __func__, + operation, xpath); + exit(1); } if (ret != NB_OK) { - enum lib_log_refs ref = 0; + int priority; + enum lib_log_refs ref; switch (event) { case NB_EV_VALIDATE: + priority = LOG_WARNING; ref = EC_LIB_NB_CB_CONFIG_VALIDATE; break; case NB_EV_PREPARE: + priority = LOG_WARNING; ref = EC_LIB_NB_CB_CONFIG_PREPARE; break; case NB_EV_ABORT: + priority = LOG_WARNING; ref = EC_LIB_NB_CB_CONFIG_ABORT; break; case NB_EV_APPLY: + priority = LOG_ERR; ref = EC_LIB_NB_CB_CONFIG_APPLY; break; + default: + flog_err(EC_LIB_DEVELOPMENT, + "%s: unknown event (%u) [xpath %s]", + __func__, event, xpath); + exit(1); } - if (event == NB_EV_VALIDATE || event == NB_EV_PREPARE) - flog_warn( - ref, - "%s: error processing configuration change: error [%s] event [%s] operation [%s] xpath [%s]", - __func__, nb_err_name(ret), - nb_event_name(event), - nb_operation_name(operation), xpath); - else - flog_err( - ref, - "%s: error processing configuration change: error [%s] event [%s] operation [%s] xpath [%s]", - __func__, nb_err_name(ret), - nb_event_name(event), - nb_operation_name(operation), xpath); + + flog(priority, ref, + "%s: error processing configuration change: error [%s] event [%s] operation [%s] xpath [%s]", + __func__, nb_err_name(ret), nb_event_name(event), + nb_operation_name(operation), xpath); } return ret; |