diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-06-14 09:13:18 -0400 |
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-08-14 20:02:05 +0000 |
| commit | 481bc15ffcebcc7d0395a3ffa8ce70249e221d5b (patch) | |
| tree | 9c11638144a147251871840b9fb94429433cfe32 /lib/log.c | |
| parent | 3ec8b5b8980bb0267f32dfc2508c457db55d5156 (diff) | |
lib: Add LIB_ERR_SYSTEM_CALL and convert VRF_SOCKET to SOCKET
Add a new error code LIB_ERR_SYSTEM_CALL to the ferr subsystem.
Additionally convert LIB_ERR_VRF_SOCKET to a more generic
LIB_ERR_SOCKET.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/log.c')
| -rw-r--r-- | lib/log.c | 27 |
1 files changed, 15 insertions, 12 deletions
@@ -28,6 +28,8 @@ #include "log_int.h" #include "memory.h" #include "command.h" +#include "lib_errors.h" + #ifndef SUNOS_5 #include <sys/un.h> #endif @@ -631,15 +633,16 @@ void zlog_backtrace(int priority) size = backtrace(array, array_size(array)); if (size <= 0 || (size_t)size > array_size(array)) { - zlog_err( - "Cannot get backtrace, returned invalid # of frames %d " - "(valid range is between 1 and %lu)", - size, (unsigned long)(array_size(array))); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "Cannot get backtrace, returned invalid # of frames %d " + "(valid range is between 1 and %lu)", + size, (unsigned long)(array_size(array))); return; } zlog(priority, "Backtrace for %d stack frames:", size); if (!(strings = backtrace_symbols(array, size))) { - zlog_err("Cannot get backtrace symbols (out of memory?)"); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "Cannot get backtrace symbols (out of memory?)"); for (i = 0; i < size; i++) zlog(priority, "[bt %d] %p", i, array[i]); } else { @@ -712,10 +715,10 @@ void _zlog_assert_failed(const char *assertion, const char *file, void memory_oom(size_t size, const char *name) { - zlog_err( - "out of memory: failed to allocate %zu bytes for %s" - "object", - size, name); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "out of memory: failed to allocate %zu bytes for %s" + "object", + size, name); zlog_backtrace(LOG_ERR); abort(); } @@ -864,9 +867,9 @@ int zlog_rotate(void) save_errno = errno; umask(oldumask); if (zl->fp == NULL) { - zlog_err( - "Log rotate failed: cannot open file %s for append: %s", - zl->filename, safe_strerror(save_errno)); + zlog_ferr(LIB_ERR_SYSTEM_CALL, + "Log rotate failed: cannot open file %s for append: %s", + zl->filename, safe_strerror(save_errno)); ret = -1; } else { logfile_fd = fileno(zl->fp); |
