72#if defined(_XOPEN_SOURCE) || defined(CYGWIN) || defined(MACOSX)
96#define LOG_INTERNAL_ERR(err_str, action) \
97 log_internal_err("\nERROR [%s@%d]: " #err_str " - " #action, \
98 __FUNCTION__, __LINE__)
100#define LOG_INTERNAL_LOCK_ERR(name, err_str, hndl, rc, action) \
101 log_internal_lock_err( \
102 "\nERROR [%s@%d]: [" #name "] " #err_str " (%p:%d) - " #action, \
103 __FUNCTION__, __LINE__, (void *)(hndl), rc)
121#define LOG_INTERNAL_BUF_ERR(err_str, ptr, action) \
122 log_internal_err("\nERROR [%s@%d]: " #err_str \
123 " [ptr=%p, id=%4x, start=%p, end=%p" \
124 ", len=%u(0x%x), remaining=%d(0x%x)]" \
125 " wp=%u" " - %s\n", __FUNCTION__, __LINE__, \
126 ptr, (ptr)->idid, (ptr)->start, (ptr)->end, \
127 (ptr)->len, (ptr)->len, (ptr)->remaining, (ptr)->remaining, \
128 (uint)(ptr)->write_pending, #action)
136#define LOG_CLEANUP_PHASE1 FALSE
137#define LOG_CLEANUP_PHASE2 !LOG_CLEANUP_PHASE1
159#define FILTER_DEBUG_LEVEL(lvl) \
160 ((log_get_system_log_level() < (lvl)) || \
161 ((log_get_log_level() < (lvl)) && \
162 (log_get_syslog_log_level() < (lvl))))
164#define ALLOW_DEBUG_LEVEL(lvl) !FILTER_DEBUG_LEVEL(lvl)
186#define FILTER_PTHREAD_DEBUG_LEVEL(lvl) \
187 ((log_get_system_log_level() < (lvl)) || \
188 (log_get_pthread_log_level() < (lvl)))
190#define ALLOW_PTHREAD_DEBUG_LEVEL(lvl) !FILTER_PTHREAD_DEBUG_LEVEL(lvl)
208#define LOGDEV0 (log_get_system_log_level() >= LOG_DEBUG_DEV0)
232#define LOGERROR (log_get_system_log_level() >= LOG_DEBUG_ERROR)
237#define LOGWARN (log_get_system_log_level() >= LOG_DEBUG_WARN)
242#define LOGINFO (log_get_system_log_level() >= LOG_DEBUG_INFO)
245#define LOGDEV1 (log_get_system_log_level() >= LOG_DEBUG_DEV1)
250#define LOGDEBUG (log_get_system_log_level() >= LOG_DEBUG_DEBUG)
255#define LOGDEBUG2 (log_get_system_log_level() >= LOG_DEBUG_DEBUG2)
260#define LOGDEBUG3 (log_get_system_log_level() >= LOG_DEBUG_DEBUG3)
265#define LOGDEBUG4 (log_get_system_log_level() >= LOG_DEBUG_DEBUG4)
273#define LOGDEV1_THD (log_get_pthread_log_level() >= LOG_DEBUG_DEV1)
274#define LOGDBG_THD (log_get_pthread_log_level() >= LOG_DEBUG_DEBUG)
275#define LOGDBG2_THD (log_get_pthread_log_level() >= LOG_DEBUG_DEBUG2)
276#define LOGDBG3_THD (log_get_pthread_log_level() >= LOG_DEBUG_DEBUG3)
277#define LOGDBG4_THD (log_get_pthread_log_level() >= LOG_DEBUG_DEBUG4)
280#define DWRT LOG_DEBUG_WRITE
281#define DEV0 LOG_DEBUG_DEV0
282#define DERR LOG_DEBUG_ERROR
283#define DWARN LOG_DEBUG_WARN
284#define DINFO LOG_DEBUG_INFO
285#define DEV1 LOG_DEBUG_DEV1
286#define DBG LOG_DEBUG_DEBUG
287#define DBG1 LOG_DEBUG_DEBUG
288#define DBG2 LOG_DEBUG_DEBUG2
289#define DBG3 LOG_DEBUG_DEBUG3
290#define DBG4 LOG_DEBUG_DEBUG4
292#define LOG_DEBUG_STR_OFF (const xmlChar *)"off"
293#define LOG_DEBUG_STR_WRITE (const xmlChar *)"write"
294#define LOG_DEBUG_STR_DEV0 (const xmlChar *)"dev0"
295#define LOG_DEBUG_STR_ERROR (const xmlChar *)"error"
296#define LOG_DEBUG_STR_WARN (const xmlChar *)"warn"
297#define LOG_DEBUG_STR_INFO (const xmlChar *)"info"
298#define LOG_DEBUG_STR_DEV1 (const xmlChar *)"dev1"
299#define LOG_DEBUG_STR_DEBUG (const xmlChar *)"debug"
300#define LOG_DEBUG_STR_DEBUG2 (const xmlChar *)"debug2"
301#define LOG_DEBUG_STR_DEBUG3 (const xmlChar *)"debug3"
302#define LOG_DEBUG_STR_DEBUG4 (const xmlChar *)"debug4"
305#define LOG_DEBUG_APP_STR_UNKNOWN (const char *)"?yuma?"
306#define LOG_DEBUG_APP_STR_YANGCLI (const char *)"yangcli-pro"
307#define LOG_DEBUG_APP_STR_YANGDUMP (const char *)"yangdump-pro"
308#define LOG_DEBUG_APP_STR_YANGDIFF (const char *)"yangdiff-pro"
309#define LOG_DEBUG_APP_STR_NETCONFD (const char *)"netconfd-pro"
315#define FRAME_OVERHEAD_CNT 4
336typedef enum log_stream_t_ {
348typedef enum log_debug_t_ {
367typedef enum log_debug_app_t_ {
381#define VALID_DEBUG_APP(app) \
382 ((app) > LOG_DEBUG_APP_NONE) && ((app) < LOG_DEBUG_APP_MAX)
384#define APP_IS_NETCONFD (log_get_debug_app() == LOG_DEBUG_APP_NETCONFD)
389typedef void (*logfn_void_t) (void);
395typedef void (*logfn_t) (
const char *fstr, ...)
396 __attribute__ ((format (printf, 1, 2)));
402typedef void (*logfn_cmn_va_t) (
boolean recursive,
404 const char *fstr, va_list args);
409typedef void (*logfn_app_va_t) (
boolean recursive,
411 const char *fstr, va_list args);
413typedef void (*logfn_flush_t) (void);
415typedef void (*logfn_connect_t) (void);
418 const char *fstr, ...)
419 __attribute__ ((format (printf, 3, 4)));
423extern logfn_connect_t logfn_connect;
424extern logfn_send_t logfn_send;
443extern void log_enter_cs (
void );
449extern void log_exit_cs (
void );
508 log_internal_err (
const char *fstr, ...)
509 __attribute__ ((format (printf, 1, 2)));
512 log_internal_lock_err (const
char *fstr, ...)
513 __attribute__ ((format (printf, 1, 2)));
531 log_get_backtrace_detail (
void);
533 log_set_backtrace_detail (
void);
537 log_set_custom (
void);
541 log_set_localtime (
void);
545 log_set_audit_localtime (
void);
549 log_set_mirroring (
void);
552 log_get_mirroring (
void);
556 log_set_stderr (
void);
560 log_set_suppress_ctrl (
void);
564 log_get_syslog_bfr_allocated (
void);
567 log_syslog_log_level (
void);
571 log_get_vendor_bfr_allocated (
void);
575 log_set_syslog_bfr_allocated (
void);
579 log_set_vendor_bfr_allocated (
void);
583 log_clr_syslog_bfr_allocated (
void);
587 log_clr_vendor_bfr_allocated (
void);
590extern
void log_set_syslog (
void);
591extern
void log_clr_syslog (
void);
592extern
boolean log_get_syslog (
void);
596 log_set_vendor (
void);
600 log_set_backtrace_logfile (
void);
604 log_set_backtrace_stderr (
void);
608 log_set_backtrace_stdout (
void);
612 log_get_backtrace_syslog (
void);
614 log_set_backtrace_syslog (
void);
618 log_get_backtrace_vendor (
void);
620 log_set_backtrace_vendor (
void);
638 log_set_backtrace (uint frame_cnt);
697 log_set_backtrace_level_mask (uint mask);
713 log_get_backtrace_level_mask (
void);
754 log_do_backtrace (
log_debug_t sub_level,
boolean flag);
925 const
char *fstr, va_list args);
941 const
char *fstr, va_list args);
976 log_print_backtrace (
boolean syslog_call,
978 logfn_flush_t localfn_flush,
981 const
char *preamble);
1002 log_capture_backtrace (
char ***strP,
void *bt_arrayP, uint max_frames);
1020 log_backtrace (
log_debug_t level, const
char *fstr, ...)
1021 __attribute__ ((format (printf, 2, 3)));
1040 log_stderr_backtrace (
boolean max_detail, const
char *preamble);
1055 __attribute__ ((format (printf, 1, 2)));
1067 __attribute__ ((format (printf, 2, 3)));
1082 __attribute__ ((format (printf, 1, 2)));
1093 __attribute__ ((format (printf, 1, 2)));
1097 log_write_filtered (
log_debug_t level, const
char *fstr, ...)
1098 __attribute__ ((format (printf, 2, 3)));
1101 log_write_filtered_append (
log_debug_t level, const
char *fstr, ...)
1102 __attribute__ ((format (printf, 2, 3)));
1105 log_write_syslog_level (
log_debug_t level, const
char *fstr, ...)
1106 __attribute__ ((format (printf, 2, 3)));
1109 log_write_syslog_level_append (
log_debug_t level, const
char *fstr, ...)
1110 __attribute__ ((format (printf, 2, 3)));
1123 __attribute__ ((format (printf, 1, 2)));
1136 __attribute__ ((format (printf, 2, 3)));
1150 log_audit_indent (int32 indentcnt);
1153 log_audit_indent_level (
log_debug_t level, int32 indentcnt);
1164 __attribute__ ((format (printf, 1, 2)));
1176 __attribute__ ((format (printf, 2, 3)));
1191 log_alt_indent (int32 indentcnt);
1194 log_alt_indent_level (
log_debug_t level, int32 indentcnt);
1208 vlog_error (const
char *fstr, va_list args );
1225 __attribute__ ((format (printf, 1, 2)));
1237 __attribute__ ((format (printf, 1, 2)));
1249 __attribute__ ((format (printf, 1, 2)));
1261 __attribute__ ((format (printf, 1, 2)));
1273 __attribute__ ((format (printf, 1, 2)));
1285 __attribute__ ((format (printf, 1, 2)));
1297 __attribute__ ((format (printf, 1, 2)));
1309 __attribute__ ((format (printf, 1, 2)));
1321 __attribute__ ((format (printf, 1, 2)));
1333 __attribute__ ((format (printf, 1, 2)));
1345 __attribute__ ((format (printf, 1, 2)));
1357 __attribute__ ((format (printf, 1, 2)));
1369 __attribute__ ((format (printf, 1, 2)));
1381 __attribute__ ((format (printf, 1, 2)));
1398 log_dev0 (const
char *fstr, ...)
1399 __attribute__ ((format (printf, 1, 2)));
1402 log_dev0_append (const
char *fstr, ...)
1403 __attribute__ ((format (printf, 1, 2)));
1420 log_dev1 (const
char *fstr, ...)
1421 __attribute__ ((format (printf, 1, 2)));
1424 log_dev1_append (const
char *fstr, ...)
1425 __attribute__ ((format (printf, 1, 2)));
1442 log_write_level (
log_debug_t level, const
char *fstr, ...)
1443 __attribute__ ((format (printf, 2, 3)));
1446 log_write_level_append (
log_debug_t level, const
char *fstr, ...)
1447 __attribute__ ((format (printf, 2, 3)));
1485 log_dev1_thd (
const char *fstr, ...)
1486 __attribute__ ((format (printf, 1, 2)));
1489 log_dev1_append_thd (const
char *fstr, ...)
1490 __attribute__ ((format (printf, 1, 2)));
1493 log_debug_thd (const
char *fstr, ...)
1494 __attribute__ ((format (printf, 1, 2)));
1497 log_debug_append_thd (const
char *fstr, ...)
1498 __attribute__ ((format (printf, 1, 2)));
1501 log_debug2_thd (const
char *fstr, ...)
1502 __attribute__ ((format (printf, 1, 2)));
1505 log_debug2_append_thd (const
char *fstr, ...)
1506 __attribute__ ((format (printf, 1, 2)));
1509 log_debug3_thd (const
char *fstr, ...)
1510 __attribute__ ((format (printf, 1, 2)));
1513 log_debug3_append_thd (const
char *fstr, ...)
1514 __attribute__ ((format (printf, 1, 2)));
1517 log_debug4_thd (const
char *fstr, ...)
1518 __attribute__ ((format (printf, 1, 2)));
1521 log_debug4_append_thd (const
char *fstr, ...)
1522 __attribute__ ((format (printf, 1, 2)));
1538 log_noop (
const char *fstr, ...)
1539 __attribute__ ((format (printf, 1, 2)));
1575extern log_debug_t log_get_system_log_level (
void);
1614 log_get_debug_level_enum (
const char *str);
1617 log_parse_debug_level_str (
const char *str);
1632extern const xmlChar *
1713 log_get_debug_app (
void);
1729 log_debug_app_string (
void);
1753 log_indent (int32 indentcnt);
1755 log_indent_append (int32 indentcnt);
1757 log_indent_level_append (
log_debug_t level, int32 indentcnt);
1770 log_stdout_indent (int32 indentcnt);
1773 log_stdout_level_indent (
log_debug_t level, int32 indentcnt);
1787 log_get_logfile (
void);
1802 log_start_capture (
const char *fname);
1812 log_end_capture (
void);
1824 log_trigger_rotate (
void);
1836 log_rotate_requested (
void);
void log_alt_write(const char *fstr,...) __attribute__((format(printf
Write to the alternate log file.
logfn_t log_get_appendfn(log_debug_t loglevel)
Get the logfn_t for the corresponding log-level FOR APPEND.
Definition: log.c:3317
void void log_alt_write_level(log_debug_t level, const char *fstr,...) __attribute__((format(printf
Write to the alternate log file if debug-level set.
void log_error(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_ERROR log entry.
void void log_error_append(const char *fstr,...) __attribute__((format(printf
Append to a LOG_DEBUG_ERROR log entry.
void log_init(void)
Initialize logger state.
Definition: log.c:545
void log_close(void)
Close the logfile.
Definition: log.c:1143
log_debug_t log_get_pthread_log_level(void)
Get the pthreads log level.
Definition: log.c:3802
void void void void void void void log_debug(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG log entry.
void void log_stdout_level(log_debug_t level, const char *fstr,...) __attribute__((format(printf
Write output to STDOUT if debug level set.
void log_flush(void)
Flush output buffers.
Definition: log.c:2001
status_t log_alt_open_force(const char *fname, boolean overwrite, boolean force_mode)
Open an alternate logfile for writing.
Definition: log.c:1302
void void void void void void void void void void void void log_set_log_level(log_debug_t dlevel)
Set the main log level.
Definition: log.c:3637
void void void log_write(const char *fstr,...) __attribute__((format(printf
Write a new entry to the main log.
void void void void void void void void void void void log_debug3(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG3 log entry.
log_debug_t log_get_log_level(void)
Get the main log level.
Definition: log.c:3750
void void void void void void void void void log_audit_write(const char *fstr,...) __attribute__((format(printf
Write an new entry to the audit log file.
void log_set_highres_datetime(boolean val)
Set the high resolution date-time usage flag.
Definition: log.c:4370
log_debug_t log_get_syslog_log_level(void)
Get the syslog log level.
Definition: log.c:3765
void void void void void void void void void void log_audit_write_level(log_debug_t level, const char *fstr,...) __attribute__((format(printf
Write an new entry to the audit log file if the log level is set.
void void void void void void void void void void void void log_debug3_append(const char *fstr,...) __attribute__((format(printf
Append to a LOG_DEBUG_DEBUG3 log entry.
void disable_default_stdout(void)
Used by yp-client to disable log.c output.
Definition: log.c:272
void void void void void void void void void void void void void void void void void void void void logfn_t log_get_logfn(log_debug_t loglevel)
Get the logfn_t for the corresponding log-level.
Definition: log.c:3277
status_t log_alt_open(const char *fname)
Open an alternate logfile for writing.
Definition: log.c:1252
void log_alt_close(void)
Close the alternate logfile.
Definition: log.c:1339
boolean log_audit_is_open(void)
Check if the audit log is open.
Definition: log.c:1231
void void void void void void void void void void void void void void log_debug4_append(const char *fstr,...) __attribute__((format(printf
Append to a LOG_DEBUG_DEBUG4 log entry.
void void void log_warn(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_WARN log entry.
void void void void void void void void void void log_debug2_append(const char *fstr,...) __attribute__((format(printf
Append to a LOG_DEBUG_DEBUG2 log entry.
void void void void log_warn_append(const char *fstr,...) __attribute__((format(printf
Append to a LOG_DEBUG_WARN log entry.
boolean log_get_highres_datetime(void)
Get the high resolution date-time usage flag.
Definition: log.c:4388
status_t log_open(const char *fname, boolean append, boolean tstamps)
Open a logfile for writing.
Definition: log.c:1125
void log_audit_close(void)
Close the audit_logfile.
Definition: log.c:1199
void log_set_pthread_log_level(log_debug_t dlevel)
Set the pthreads log level.
Definition: log.c:3712
void log_set_syslog_log_level(log_debug_t dlevel)
Set the syslog log level.
Definition: log.c:3680
void void void void void void void void log_debug_append(const char *fstr,...) __attribute__((format(printf
Append to a LOG_DEBUG_DEBUG log entry.
void log_stdout(const char *fstr,...) __attribute__((format(printf
Write output to STDOUT.
status_t log_audit_open(const char *fname, boolean append, boolean tstamps)
Open the audit logfile for writing.
Definition: log.c:1181
void void void void void void void void void void void void void log_debug4(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG4 log entry.
void void void void void void log_info_append(const char *fstr,...) __attribute__((format(printf
Append to a LOG_DEBUG_INFO log entry.
void void void void log_write_append(const char *fstr,...) __attribute__((format(printf
Append to the last log entry to the main log.
void void void void void log_info(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_INFO log entry.
void enable_default_stdout(void)
Used by C program variants of yp-client to enable log.c output.
Definition: log.c:277
status_t log_alt_open_ex(const char *fname, boolean overwrite)
Open an alternate logfile for writing.
Definition: log.c:1273
void log_cleanup(boolean phase2, boolean debugs)
Final logger cleanup prior to restart or shutdown.
Definition: log.c:570
void void void void void void void void void log_debug2(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG2 log entry.
log_debug_app_t
syslog wants to know what app is logging ...
Definition: log.h:367
log_stream_t
The output stream enumerations used in util/log.c.
Definition: log.h:336
log_debug_t
The debug level enumerations used in util/log.c.
Definition: log.h:348
@ LOG_DEBUG_APP_YANGDIFF
app is yangdiff
Definition: log.h:371
@ LOG_DEBUG_APP_YANGCLI
app is yangcli
Definition: log.h:369
@ LOG_DEBUG_APP_NETCONFD
app is netconfd
Definition: log.h:372
@ LOG_DEBUG_APP_YANGDUMP
app is yangdump
Definition: log.h:370
@ LOG_STREAM_LOGFILE
Output destined for logfile.
Definition: log.h:340
@ LOG_STREAM_STDERR
Output destined for stderr.
Definition: log.h:339
@ LOG_STREAM_NONE
value not set or error
Definition: log.h:337
@ LOG_STREAM_STDOUT
Output destined for stdout.
Definition: log.h:338
@ LOG_STREAM_CAPFILE
Output destined for capfile.
Definition: log.h:341
@ LOG_DEBUG_DEV0
Special use developer debugging only.
Definition: log.h:352
@ LOG_DEBUG_NONE
value not set or error
Definition: log.h:349
@ LOG_DEBUG_ERROR
fatal + internal errors only
Definition: log.h:353
@ LOG_DEBUG_DEBUG
debug level 1
Definition: log.h:357
@ LOG_DEBUG_WARN
all errors + warnings
Definition: log.h:354
@ LOG_DEBUG_DEBUG2
debug level 2
Definition: log.h:358
@ LOG_DEBUG_INFO
all previous + user info trace
Definition: log.h:355
@ LOG_DEBUG_DEBUG4
debug level 4
Definition: log.h:360
@ LOG_DEBUG_DEV1
Special use developer debugging only.
Definition: log.h:356
@ LOG_DEBUG_WRITE
logging turned on
Definition: log.h:351
@ LOG_DEBUG_DEBUG3
debug level 3
Definition: log.h:359
@ LOG_DEBUG_OFF
logging turned off
Definition: log.h:350
status_t
global error return code
Definition: status_enum.h:210
Global error messages for status code enumerations.
Thread support (for now limited to netconfd)