69#if defined(_XOPEN_SOURCE) || defined(CYGWIN) || defined(MACOSX)
93#define LOG_INTERNAL_ERR(err_str, action) \
94 log_internal_err("\nERROR [%s@%d]: " #err_str " - " #action, \
95 __FUNCTION__, __LINE__)
97#define LOG_INTERNAL_LOCK_ERR(name, err_str, hndl, rc, action) \
98 log_internal_lock_err( \
99 "\nERROR [%s@%d]: [" #name "] " #err_str " (%p:%d) - " #action, \
100 __FUNCTION__, __LINE__, (void *)(hndl), rc)
118#define LOG_INTERNAL_BUF_ERR(err_str, ptr, action) \
119 log_internal_err("\nERROR [%s@%d]: " #err_str \
120 " [ptr=%p, id=%4x, start=%p, end=%p" \
121 ", len=%u(0x%x), remaining=%d(0x%x)]" \
122 " wp=%u" " - %s\n", __FUNCTION__, __LINE__, \
123 ptr, (ptr)->idid, (ptr)->start, (ptr)->end, \
124 (ptr)->len, (ptr)->len, (ptr)->remaining, (ptr)->remaining, \
125 (uint)(ptr)->write_pending, #action)
133#define LOG_CLEANUP_PHASE1 FALSE
134#define LOG_CLEANUP_PHASE2 !LOG_CLEANUP_PHASE1
156#define FILTER_DEBUG_LEVEL(lvl) \
157 ((log_get_system_log_level() < (lvl)) || \
158 ((log_get_log_level() < (lvl)) && \
159 (log_get_syslog_log_level() < (lvl))))
161#define ALLOW_DEBUG_LEVEL(lvl) !FILTER_DEBUG_LEVEL(lvl)
183#define FILTER_PTHREAD_DEBUG_LEVEL(lvl) \
184 ((log_get_system_log_level() < (lvl)) || \
185 (log_get_pthread_log_level() < (lvl)))
187#define ALLOW_PTHREAD_DEBUG_LEVEL(lvl) !FILTER_PTHREAD_DEBUG_LEVEL(lvl)
205#define LOGDEV0 (log_get_system_log_level() >= LOG_DEBUG_DEV0)
229#define LOGERROR (log_get_system_log_level() >= LOG_DEBUG_ERROR)
234#define LOGWARN (log_get_system_log_level() >= LOG_DEBUG_WARN)
239#define LOGINFO (log_get_system_log_level() >= LOG_DEBUG_INFO)
242#define LOGDEV1 (log_get_system_log_level() >= LOG_DEBUG_DEV1)
247#define LOGDEBUG (log_get_system_log_level() >= LOG_DEBUG_DEBUG)
252#define LOGDEBUG2 (log_get_system_log_level() >= LOG_DEBUG_DEBUG2)
257#define LOGDEBUG3 (log_get_system_log_level() >= LOG_DEBUG_DEBUG3)
262#define LOGDEBUG4 (log_get_system_log_level() >= LOG_DEBUG_DEBUG4)
270#define LOGDEV1_THD (log_get_pthread_log_level() >= LOG_DEBUG_DEV1)
271#define LOGDBG_THD (log_get_pthread_log_level() >= LOG_DEBUG_DEBUG)
272#define LOGDBG2_THD (log_get_pthread_log_level() >= LOG_DEBUG_DEBUG2)
273#define LOGDBG3_THD (log_get_pthread_log_level() >= LOG_DEBUG_DEBUG3)
274#define LOGDBG4_THD (log_get_pthread_log_level() >= LOG_DEBUG_DEBUG4)
277#define DWRT LOG_DEBUG_WRITE
278#define DEV0 LOG_DEBUG_DEV0
279#define DERR LOG_DEBUG_ERROR
280#define DWARN LOG_DEBUG_WARN
281#define DINFO LOG_DEBUG_INFO
282#define DEV1 LOG_DEBUG_DEV1
283#define DBG LOG_DEBUG_DEBUG
284#define DBG1 LOG_DEBUG_DEBUG
285#define DBG2 LOG_DEBUG_DEBUG2
286#define DBG3 LOG_DEBUG_DEBUG3
287#define DBG4 LOG_DEBUG_DEBUG4
289#define LOG_DEBUG_STR_OFF (const xmlChar *)"off"
290#define LOG_DEBUG_STR_WRITE (const xmlChar *)"write"
291#define LOG_DEBUG_STR_DEV0 (const xmlChar *)"dev0"
292#define LOG_DEBUG_STR_ERROR (const xmlChar *)"error"
293#define LOG_DEBUG_STR_WARN (const xmlChar *)"warn"
294#define LOG_DEBUG_STR_INFO (const xmlChar *)"info"
295#define LOG_DEBUG_STR_DEV1 (const xmlChar *)"dev1"
296#define LOG_DEBUG_STR_DEBUG (const xmlChar *)"debug"
297#define LOG_DEBUG_STR_DEBUG2 (const xmlChar *)"debug2"
298#define LOG_DEBUG_STR_DEBUG3 (const xmlChar *)"debug3"
299#define LOG_DEBUG_STR_DEBUG4 (const xmlChar *)"debug4"
302#define LOG_DEBUG_APP_STR_UNKNOWN (const char *)"?yuma?"
303#define LOG_DEBUG_APP_STR_YANGCLI (const char *)"yangcli-pro"
304#define LOG_DEBUG_APP_STR_YANGDUMP (const char *)"yangdump-pro"
305#define LOG_DEBUG_APP_STR_YANGDIFF (const char *)"yangdiff-pro"
306#define LOG_DEBUG_APP_STR_NETCONFD (const char *)"netconfd-pro"
312#define FRAME_OVERHEAD_CNT 4
333typedef enum log_stream_t_ {
345typedef enum log_debug_t_ {
364typedef enum log_debug_app_t_ {
378#define VALID_DEBUG_APP(app) \
379 ((app) > LOG_DEBUG_APP_NONE) && ((app) < LOG_DEBUG_APP_MAX)
381#define APP_IS_NETCONFD (log_get_debug_app() == LOG_DEBUG_APP_NETCONFD)
386typedef void (*logfn_void_t) (void);
392typedef void (*logfn_t) (
const char *fstr, ...)
393 __attribute__ ((format (printf, 1, 2)));
399typedef void (*logfn_cmn_va_t) (
boolean recursive,
401 const char *fstr, va_list args);
406typedef void (*logfn_app_va_t) (
boolean recursive,
408 const char *fstr, va_list args);
410typedef void (*logfn_flush_t) (void);
412typedef void (*logfn_connect_t) (void);
415 const char *fstr, ...)
416 __attribute__ ((format (printf, 3, 4)));
420extern logfn_connect_t logfn_connect;
421extern logfn_send_t logfn_send;
440extern void log_enter_cs (
void );
446extern void log_exit_cs (
void );
505 log_internal_err (
const char *fstr, ...)
506 __attribute__ ((format (printf, 1, 2)));
509 log_internal_lock_err (const
char *fstr, ...)
510 __attribute__ ((format (printf, 1, 2)));
528 log_get_backtrace_detail (
void);
530 log_set_backtrace_detail (
void);
534 log_set_custom (
void);
538 log_set_localtime (
void);
542 log_set_audit_localtime (
void);
546 log_set_mirroring (
void);
549 log_get_mirroring (
void);
553 log_set_stderr (
void);
557 log_set_suppress_ctrl (
void);
561 log_get_syslog_bfr_allocated (
void);
564 log_syslog_log_level (
void);
568 log_get_vendor_bfr_allocated (
void);
572 log_set_syslog_bfr_allocated (
void);
576 log_set_vendor_bfr_allocated (
void);
580 log_clr_syslog_bfr_allocated (
void);
584 log_clr_vendor_bfr_allocated (
void);
587extern
void log_set_syslog (
void);
588extern
void log_clr_syslog (
void);
589extern
boolean log_get_syslog (
void);
593 log_set_vendor (
void);
597 log_set_backtrace_logfile (
void);
601 log_set_backtrace_stderr (
void);
605 log_set_backtrace_stdout (
void);
609 log_get_backtrace_syslog (
void);
611 log_set_backtrace_syslog (
void);
615 log_get_backtrace_vendor (
void);
617 log_set_backtrace_vendor (
void);
635 log_set_backtrace (uint frame_cnt);
694 log_set_backtrace_level_mask (uint mask);
710 log_get_backtrace_level_mask (
void);
751 log_do_backtrace (
log_debug_t sub_level,
boolean flag);
922 const
char *fstr, va_list args);
938 const
char *fstr, va_list args);
973 log_print_backtrace (
boolean syslog_call,
975 logfn_flush_t localfn_flush,
978 const
char *preamble);
999 log_capture_backtrace (
char ***strP,
void *bt_arrayP, uint max_frames);
1017 log_backtrace (
log_debug_t level, const
char *fstr, ...)
1018 __attribute__ ((format (printf, 2, 3)));
1037 log_stderr_backtrace (
boolean max_detail, const
char *preamble);
1052 __attribute__ ((format (printf, 1, 2)));
1064 __attribute__ ((format (printf, 2, 3)));
1079 __attribute__ ((format (printf, 1, 2)));
1090 __attribute__ ((format (printf, 1, 2)));
1094 log_write_filtered (
log_debug_t level, const
char *fstr, ...)
1095 __attribute__ ((format (printf, 2, 3)));
1098 log_write_filtered_append (
log_debug_t level, const
char *fstr, ...)
1099 __attribute__ ((format (printf, 2, 3)));
1102 log_write_syslog_level (
log_debug_t level, const
char *fstr, ...)
1103 __attribute__ ((format (printf, 2, 3)));
1106 log_write_syslog_level_append (
log_debug_t level, const
char *fstr, ...)
1107 __attribute__ ((format (printf, 2, 3)));
1120 __attribute__ ((format (printf, 1, 2)));
1133 __attribute__ ((format (printf, 2, 3)));
1147 log_audit_indent (int32 indentcnt);
1150 log_audit_indent_level (
log_debug_t level, int32 indentcnt);
1161 __attribute__ ((format (printf, 1, 2)));
1173 __attribute__ ((format (printf, 2, 3)));
1188 log_alt_indent (int32 indentcnt);
1191 log_alt_indent_level (
log_debug_t level, int32 indentcnt);
1205 vlog_error (const
char *fstr, va_list args );
1222 __attribute__ ((format (printf, 1, 2)));
1234 __attribute__ ((format (printf, 1, 2)));
1246 __attribute__ ((format (printf, 1, 2)));
1258 __attribute__ ((format (printf, 1, 2)));
1270 __attribute__ ((format (printf, 1, 2)));
1282 __attribute__ ((format (printf, 1, 2)));
1294 __attribute__ ((format (printf, 1, 2)));
1306 __attribute__ ((format (printf, 1, 2)));
1318 __attribute__ ((format (printf, 1, 2)));
1330 __attribute__ ((format (printf, 1, 2)));
1342 __attribute__ ((format (printf, 1, 2)));
1354 __attribute__ ((format (printf, 1, 2)));
1366 __attribute__ ((format (printf, 1, 2)));
1378 __attribute__ ((format (printf, 1, 2)));
1395 log_dev0 (const
char *fstr, ...)
1396 __attribute__ ((format (printf, 1, 2)));
1399 log_dev0_append (const
char *fstr, ...)
1400 __attribute__ ((format (printf, 1, 2)));
1417 log_dev1 (const
char *fstr, ...)
1418 __attribute__ ((format (printf, 1, 2)));
1421 log_dev1_append (const
char *fstr, ...)
1422 __attribute__ ((format (printf, 1, 2)));
1439 log_write_level (
log_debug_t level, const
char *fstr, ...)
1440 __attribute__ ((format (printf, 2, 3)));
1443 log_write_level_append (
log_debug_t level, const
char *fstr, ...)
1444 __attribute__ ((format (printf, 2, 3)));
1482 log_dev1_thd (
const char *fstr, ...)
1483 __attribute__ ((format (printf, 1, 2)));
1486 log_dev1_append_thd (const
char *fstr, ...)
1487 __attribute__ ((format (printf, 1, 2)));
1490 log_debug_thd (const
char *fstr, ...)
1491 __attribute__ ((format (printf, 1, 2)));
1494 log_debug_append_thd (const
char *fstr, ...)
1495 __attribute__ ((format (printf, 1, 2)));
1498 log_debug2_thd (const
char *fstr, ...)
1499 __attribute__ ((format (printf, 1, 2)));
1502 log_debug2_append_thd (const
char *fstr, ...)
1503 __attribute__ ((format (printf, 1, 2)));
1506 log_debug3_thd (const
char *fstr, ...)
1507 __attribute__ ((format (printf, 1, 2)));
1510 log_debug3_append_thd (const
char *fstr, ...)
1511 __attribute__ ((format (printf, 1, 2)));
1514 log_debug4_thd (const
char *fstr, ...)
1515 __attribute__ ((format (printf, 1, 2)));
1518 log_debug4_append_thd (const
char *fstr, ...)
1519 __attribute__ ((format (printf, 1, 2)));
1535 log_noop (
const char *fstr, ...)
1536 __attribute__ ((format (printf, 1, 2)));
1572extern log_debug_t log_get_system_log_level (
void);
1611 log_get_debug_level_enum (
const char *str);
1614 log_parse_debug_level_str (
const char *str);
1629extern const xmlChar *
1710 log_get_debug_app (
void);
1726 log_debug_app_string (
void);
1750 log_indent (int32 indentcnt);
1752 log_indent_append (int32 indentcnt);
1754 log_indent_level_append (
log_debug_t level, int32 indentcnt);
1767 log_stdout_indent (int32 indentcnt);
1770 log_stdout_level_indent (
log_debug_t level, int32 indentcnt);
1784 log_get_logfile (
void);
1799 log_start_capture (
const char *fname);
1809 log_end_capture (
void);
1821 log_trigger_rotate (
void);
1833 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:3307
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:539
void log_close(void)
Close the logfile.
Definition: log.c:1137
log_debug_t log_get_pthread_log_level(void)
Get the pthreads log level.
Definition: log.c:3792
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:1991
status_t log_alt_open_force(const char *fname, boolean overwrite, boolean force_mode)
Open an alternate logfile for writing.
Definition: log.c:1292
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:3627
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:3740
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:4360
log_debug_t log_get_syslog_log_level(void)
Get the syslog log level.
Definition: log.c:3755
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:270
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:3267
status_t log_alt_open(const char *fname)
Open an alternate logfile for writing.
Definition: log.c:1242
void log_alt_close(void)
Close the alternate logfile.
Definition: log.c:1329
boolean log_audit_is_open(void)
Check if the audit log is open.
Definition: log.c:1221
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:4378
status_t log_open(const char *fname, boolean append, boolean tstamps)
Open a logfile for writing.
Definition: log.c:1119
void log_audit_close(void)
Close the audit_logfile.
Definition: log.c:1193
void log_set_pthread_log_level(log_debug_t dlevel)
Set the pthreads log level.
Definition: log.c:3702
void log_set_syslog_log_level(log_debug_t dlevel)
Set the syslog log level.
Definition: log.c:3670
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:1175
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:275
status_t log_alt_open_ex(const char *fname, boolean overwrite)
Open an alternate logfile for writing.
Definition: log.c:1263
void log_cleanup(boolean phase2, boolean debugs)
Final logger cleanup prior to restart or shutdown.
Definition: log.c:564
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:364
log_stream_t
The output stream enumerations used in util/log.c.
Definition: log.h:333
log_debug_t
The debug level enumerations used in util/log.c.
Definition: log.h:345
@ LOG_DEBUG_APP_YANGDIFF
app is yangdiff
Definition: log.h:368
@ LOG_DEBUG_APP_YANGCLI
app is yangcli
Definition: log.h:366
@ LOG_DEBUG_APP_NETCONFD
app is netconfd
Definition: log.h:369
@ LOG_DEBUG_APP_YANGDUMP
app is yangdump
Definition: log.h:367
@ LOG_STREAM_LOGFILE
Output destined for logfile.
Definition: log.h:337
@ LOG_STREAM_STDERR
Output destined for stderr.
Definition: log.h:336
@ LOG_STREAM_NONE
value not set or error
Definition: log.h:334
@ LOG_STREAM_STDOUT
Output destined for stdout.
Definition: log.h:335
@ LOG_STREAM_CAPFILE
Output destined for capfile.
Definition: log.h:338
@ LOG_DEBUG_DEV0
Special use developer debugging only.
Definition: log.h:349
@ LOG_DEBUG_NONE
value not set or error
Definition: log.h:346
@ LOG_DEBUG_ERROR
fatal + internal errors only
Definition: log.h:350
@ LOG_DEBUG_DEBUG
debug level 1
Definition: log.h:354
@ LOG_DEBUG_WARN
all errors + warnings
Definition: log.h:351
@ LOG_DEBUG_DEBUG2
debug level 2
Definition: log.h:355
@ LOG_DEBUG_INFO
all previous + user info trace
Definition: log.h:352
@ LOG_DEBUG_DEBUG4
debug level 4
Definition: log.h:357
@ LOG_DEBUG_DEV1
Special use developer debugging only.
Definition: log.h:353
@ LOG_DEBUG_WRITE
logging turned on
Definition: log.h:348
@ LOG_DEBUG_DEBUG3
debug level 3
Definition: log.h:356
@ LOG_DEBUG_OFF
logging turned off
Definition: log.h:347
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)