yumapro  20.10-12
YumaPro SDK
log.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 - 2012, Andy Bierman, All Rights Reserved.
3  * Copyright (c) 2012 - 2021, YumaWorks, Inc., All Rights Reserved.
4  *
5  * Unless required by applicable law or agreed to in writing,
6  * software distributed under the License is distributed on an
7  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8  * KIND, either express or implied. See the License for the
9  * specific language governing permissions and limitations
10  * under the License.
11  */
12 #ifndef _H_log
13 #define _H_log
14 /* FILE: log.h
15 *********************************************************************
16 * *
17 * P U R P O S E *
18 * *
19 *********************************************************************/
20 
21 
22 
30 /********************************************************************
31 * *
32 * C H A N G E H I S T O R Y *
33 * *
34 *********************************************************************
35 
36 date init comment
37 ----------------------------------------------------------------------
38 08-jan-06 abb begun
39 28may12 mts Logging feature set mods
40 */
41 
42 
43 
44 
45 #include <stdio.h>
46 #include <xmlstring.h>
47 
48 #include "procdefs.h"
49 #include "status.h"
50 
51 #ifdef PTHREADS
52 #ifndef _H_thd
53 #include "thd.h"
54 #endif
55 #endif
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 /********************************************************************
62 * *
63 * M A C R O S *
64 * *
65 *********************************************************************/
66 
67 #if defined(_XOPEN_SOURCE) || defined(CYGWIN) || defined(MACOSX)
68 #define uint uint32
69 #endif
70 
71 #if 0 // removed -- not threadsafe, may cause deadlocks
72 
73 /* THESE MACROS NOW DEFINED IN platform/procdefs.f
74  * ENTER_CS and EXIT_CS used instead
75  */
76 
77 #ifndef PTHREADS
78 /* NOP for non-threaded build */
79 #define LOG_ENTER_CS
80 #define LOG_EXIT_CS
81 #else
82 
83 /*
84  * Since multiple threads may call the logger at any time, access
85  * is synchronized via a mutex in order to prevent garbled output.
86  * In addition, a series of calls may be related (for example,
87  * val_dump_value() or trace_buff()). In order to allow nested calls
88  * on logger, a recursive "counting" mutex is used, allowing
89  * the owner to make multiple log calls in a "critical section".
90  *
91  * These are exported in order to allow the aforementioned calls
92  * from application code. (See val.c)
93  *
94  * Note that since the macros check for server vs client, these may
95  * be placed in common output code with no issues.
96  */
97 
98 #define LOG_ENTER_CS if (ncx_netconfd_running()) { \
99  if (thd_lock_recursive_log_cs_mutex()) \
100  { \
101  SET_ERROR(ERR_MUTEX_ERR); \
102  } \
103  }
104 
105 #define LOG_EXIT_CS if (ncx_netconfd_running()) { \
106  if (thd_unlock_recursive_log_cs_mutex()) \
107  { \
108  SET_ERROR(ERR_MUTEX_ERR); \
109  } \
110  }
111 
112 #endif // PTHREADS
113 #endif // 0
114 
115 /*
116  * Log internal errors to stderr. We can't call logger code to
117  * handle its own internal errors.
118  */
119 
120 /********************************************************************
121 * MACRO: LOG_INTERNAL_ERR
122 *
123 * Output string to stderr reporting error, function name, and line number
124 * and resulting action ...
125 *
126 * EXAMPLE:
127 *
128 * MACRO: LOG_INTERNAL_ERR(Null buf ptr, RETURN);
129 *
130 * OUTPUT: ERROR [log_util_init_buf@86]: Null buf ptr - RETURN
131 *
132 *
133 *********************************************************************/
134 #define LOG_INTERNAL_ERR(err_str, action) \
135  log_internal_err("\nERROR [%s@%d]: " #err_str " - " #action, \
136  __FUNCTION__, __LINE__)
137 
138 #define LOG_INTERNAL_LOCK_ERR(name, err_str, hndl, rc, action) \
139  log_internal_lock_err( \
140  "\nERROR [%s@%d]: [" #name "] " #err_str " (%p:%d) - " #action, \
141  __FUNCTION__, __LINE__, (void *)hndl, rc)
142 
143 
144 /********************************************************************
145 * MACRO: LOG_INTERNAL_BUFF_ERR
146 *
147 * Output string to stderr reporting error, function name, and line number.
148 * Dump salient buffer descriptor state, and resulting action ...
149 *
150 * EXAMPLE:
151 *
152 * MACRO: LOG_INTERNAL_BUF_ERR(Bad buf, buf, remaining, REINIT);
153 *
154 * OUTPUT: ERROR [upd_log_buf@179]: Bad buf 'remaining' [ptr=81783a0, \
155 * id=4242, start=81783cc, end=81787cc, len=1024(0x400), \
156 * remaining=1024(0x400)]->remaining=400 - REINIT \
157 *
158 *********************************************************************/
159 #define LOG_INTERNAL_BUF_ERR(err_str, ptr, action) \
160  log_internal_err("\nERROR [%s@%d]: " #err_str \
161  " [ptr=%p, id=%4x, start=%p, end=%p" \
162  ", len=%u(0x%x), remaining=%d(0x%x)]" \
163  " wp=%u" " - %s\n", __FUNCTION__, __LINE__, \
164  ptr, ptr->idid, ptr->start, ptr->end, \
165  ptr->len, ptr->len, ptr->remaining, ptr->remaining, \
166  (uint)ptr->write_pending, #action)
167 
168 
169 /********************************************************************
170 * *
171 * C O N S T A N T S *
172 * *
173 *********************************************************************/
174 #define LOG_CLEANUP_PHASE1 FALSE
175 #define LOG_CLEANUP_PHASE2 !LOG_CLEANUP_PHASE1
176 
177 
178 /********************************************************************
179 * MACRO FILTER_DEBUG_LEVEL(lvl)
180 *
181 * Filter log calls at debug_level and syslog_level.
182 *
183 * Note: For efficiency, looks first at system_debug_level which is defined
184 * to be max of (debug_level, syslog_log_level, pthread_log_level).
185 * If system_debug_level indicates filtering, then no need to look
186 * at context specific debug levels.
187 *
188 * Note: pthread_log_level only exists in PTHREAD build
189 *
190 * INPUTS:
191 * lvl == debug level to inspect
192 *
193 * RETURNS:
194 * TRUE => filter
195 * FALSE => pass
196 *********************************************************************/
197 #define FILTER_DEBUG_LEVEL(lvl) \
198  ((log_get_system_log_level() < lvl) || \
199  ((log_get_log_level() < lvl) && \
200  (log_get_syslog_log_level() < lvl)))
201 
202 #define ALLOW_DEBUG_LEVEL(lvl) !FILTER_DEBUG_LEVEL(lvl)
203 
204 #ifdef PTHREADS
205 /********************************************************************
206 * MACRO FILTER_PTHREAD_DEBUG_LEVEL(lvl)
207 *
208 * Filter pthread specific log calls at pthread_debug_level
209 *
210 * Note: For efficiency, looks first at system_debug_level which is defined
211 * to be max of (debug_level, syslog_log_level, pthread_log_level).
212 * If system_debug_level indicates filtering, then no need to look
213 * at context specific debug levels.
214 *
215 * Note: pthread_log_level only exists in PTHREAD build
216 *
217 * INPUTS:
218 * lvl == debug level to inspect
219 *
220 * RETURNS:
221 * TRUE => filter
222 * FALSE => pass
223 *********************************************************************/
224 #define FILTER_PTHREAD_DEBUG_LEVEL(lvl) \
225  ((log_get_system_log_level() < lvl) || (log_get_pthread_log_level() < lvl))
226 
227 #define ALLOW_PTHREAD_DEBUG_LEVEL(lvl) !FILTER_PTHREAD_DEBUG_LEVEL(lvl)
228 #endif
229 
230 
231 // Header only
232 
245 #define LOGDEV0 (log_get_system_log_level() >= LOG_DEBUG_DEV0)
246 
247  // BEGIN ncxlib/log/logmacros
263 
264 
265 
269 #define LOGERROR (log_get_system_log_level() >= LOG_DEBUG_ERROR)
270 
274 #define LOGWARN (log_get_system_log_level() >= LOG_DEBUG_WARN)
275 
279 #define LOGINFO (log_get_system_log_level() >= LOG_DEBUG_INFO)
280 
281 
282 #define LOGDEV1 (log_get_system_log_level() >= LOG_DEBUG_DEV1)
283 
287 #define LOGDEBUG (log_get_system_log_level() >= LOG_DEBUG_DEBUG)
288 
292 #define LOGDEBUG2 (log_get_system_log_level() >= LOG_DEBUG_DEBUG2)
293 
297 #define LOGDEBUG3 (log_get_system_log_level() >= LOG_DEBUG_DEBUG3)
298 
302 #define LOGDEBUG4 (log_get_system_log_level() >= LOG_DEBUG_DEBUG4)
303  // END ncxlib/log/logmacros
305 
306 
307 
308 /* macros to check pthread debug level only ... improves performance when
309  running without debugs enabled */
310 #define LOGDEV1_THD (log_get_pthread_log_level() >= LOG_DEBUG_DEV1)
311 #define LOGDBG_THD (log_get_pthread_log_level() >= LOG_DEBUG_DEBUG)
312 #define LOGDBG2_THD (log_get_pthread_log_level() >= LOG_DEBUG_DEBUG2)
313 #define LOGDBG3_THD (log_get_pthread_log_level() >= LOG_DEBUG_DEBUG3)
314 #define LOGDBG4_THD (log_get_pthread_log_level() >= LOG_DEBUG_DEBUG4)
315 
316  /* Ultra concise version */
317 #define DWRT LOG_DEBUG_WRITE
318 #define DEV0 LOG_DEBUG_DEV0
319 #define DERR LOG_DEBUG_ERROR
320 #define DWARN LOG_DEBUG_WARN
321 #define DINFO LOG_DEBUG_INFO
322 #define DEV1 LOG_DEBUG_DEV1
323 #define DBG LOG_DEBUG_DEBUG
324 #define DBG1 LOG_DEBUG_DEBUG
325 #define DBG2 LOG_DEBUG_DEBUG2
326 #define DBG3 LOG_DEBUG_DEBUG3
327 #define DBG4 LOG_DEBUG_DEBUG4
328 
329 #define LOG_DEBUG_STR_OFF (const xmlChar *)"off"
330 #define LOG_DEBUG_STR_WRITE (const xmlChar *)"write" /* "Force" output */
331 #define LOG_DEBUG_STR_DEV0 (const xmlChar *)"dev0" /* Special debugging */
332 #define LOG_DEBUG_STR_ERROR (const xmlChar *)"error"
333 #define LOG_DEBUG_STR_WARN (const xmlChar *)"warn"
334 #define LOG_DEBUG_STR_INFO (const xmlChar *)"info"
335 #define LOG_DEBUG_STR_DEV1 (const xmlChar *)"dev1" /* Special debugging */
336 #define LOG_DEBUG_STR_DEBUG (const xmlChar *)"debug"
337 #define LOG_DEBUG_STR_DEBUG2 (const xmlChar *)"debug2"
338 #define LOG_DEBUG_STR_DEBUG3 (const xmlChar *)"debug3"
339 #define LOG_DEBUG_STR_DEBUG4 (const xmlChar *)"debug4"
340 
341 /* syslog wants to know what app is calling ... */
342 #define LOG_DEBUG_APP_STR_UNKNOWN (const char *)"?yuma?"
343 #define LOG_DEBUG_APP_STR_YANGCLI (const char *)"yangcli-pro"
344 #define LOG_DEBUG_APP_STR_YANGDUMP (const char *)"yangdump-pro"
345 #define LOG_DEBUG_APP_STR_YANGDIFF (const char *)"yangdiff-pro"
346 #define LOG_DEBUG_APP_STR_NETCONFD (const char *)"netconfd-pro"
347 
348 /*
349  * Count to skip backtrace frames that are within the logging code ...
350  * these are usually not interesting or meaningful to the end user.
351  */
352 #define FRAME_OVERHEAD_CNT 4
353 
354 /********************************************************************
355 * *
356 * T Y P E S *
357 * *
358 *********************************************************************/
359  // BEGIN ncxlib/log/logtypes
368 
369 
373 typedef enum log_stream_t_ {
379 } log_stream_t;
380 
381 
385 typedef enum log_debug_t_ {
398 } log_debug_t;
399 
400 
404 typedef enum log_debug_app_t_ {
405  LOG_DEBUG_APP_NONE,
410  LOG_DEBUG_APP_MAX
411 } log_debug_app_t;
412 
413  // END ncxlib/log/logtypes
415 
416 
417 
418 #define VALID_DEBUG_APP(app) \
419  (app > LOG_DEBUG_APP_NONE) && (app < LOG_DEBUG_APP_MAX)
420 
421 #define APP_IS_NETCONFD (log_get_debug_app() == LOG_DEBUG_APP_NETCONFD)
422 
423 /* logging function template to switch between
424  * log_stdout and log_write
425  */
426 typedef void (*logfn_void_t) (void);
427 
428 /*
429  * Function vectors to switch between native versus syslog (or
430  * vendor-specific) logging.
431  */
432 typedef void (*logfn_t) (const char *fstr, ...)
433  __attribute__ ((format (printf, 1, 2)));
434 
435 
436 /*
437  * log_common() and log_xxx_common()
438  */
439 typedef void (*logfn_cmn_va_t) (boolean recursive,
440  log_debug_t level, log_debug_t sub_level,
441  const char *fstr, va_list args);
442 
443 /*
444  * log_append() and log_xxx_append()
445  */
446 typedef void (*logfn_app_va_t) (boolean recursive,
447  log_debug_t level, log_debug_t sub_level,
448  const char *fstr, va_list args);
449  /* log_flush() and log_xxx_flush() */
450 typedef void (*logfn_flush_t) (void);
451  /* log_xxx_connect() */
452 typedef void (*logfn_connect_t) (void);
453  /* log_xxx_send() */
454 typedef void (*logfn_send_t) (log_debug_app_t app, log_debug_t level,
455  const char *fstr, ...)
456  __attribute__ ((format (printf, 3, 4)));
457 
458 
459 /* Accessed by log_syslog.c and log_vendor.c */
460 extern logfn_connect_t logfn_connect;
461 extern logfn_send_t logfn_send;
462 
463 /********************************************************************
464 * *
465 * V A R I A B L E S *
466 * *
467 *********************************************************************/
468 
469 
470 
471 /********************************************************************
472 * *
473 * F U N C T I O N S *
474 * *
475 *********************************************************************/
476 
477 /*
478 * Enforce logger critical section via logger mutex
479 */
480 extern void log_enter_cs ( void );
481 
482 
483 /*
484 * Enforce logger critical section via logger mutex
485 */
486 extern void log_exit_cs ( void );
487 
488  // BEGIN ncxlib/log/logfns
502 
503 
507 extern void disable_default_stdout(void);
508 
509 
513 extern void enable_default_stdout(void);
514 
515 
516 
517 
523 void
524  log_cleanup ( boolean phase2, boolean debugs );
525 
526 
527 /********************************************************************
528 * FUNCTION log_internal_err
529 *
530 * Send internal logging error info to stderr. This function is called
531 * when an error is detected while in the process of trying to send
532 * info via the logging stream.
533 *
534 * See also LOG_INTERNAL_ERR() and LOG_INTERNAL_BUF_ERR macros.
535 *
536 * INPUTS:
537 *
538 * fstr == format output string
539 * ... == variable argument list
540 *
541 * RETURNS:
542 * None
543 *********************************************************************/
544 void
545  log_internal_err (const char *fstr, ...)
546  __attribute__ ((format (printf, 1, 2)));
547 
548 void
549  log_internal_lock_err (const char *fstr, ...)
550  __attribute__ ((format (printf, 1, 2)));
551 
552 
553 /********************************************************************
554 * FUNCTIONs log_set_xxx and log_get_xxx
555 *
556 * Read/write support for the various (binary) --log-xxx config
557 * options above. Additional comments inline where noteworthy.
558 *
559 * INPUTS:
560 * None
561 *
562 * RETURNS:
563 * if log_get_xxx(), the requested configured value
564 *********************************************************************/
565 
566 /* Backtrace info level */
567 extern boolean
568  log_get_backtrace_detail (void);
569 extern void
570  log_set_backtrace_detail (void);
571 
572 /* --logheader="custom" */
573 extern void
574  log_set_custom (void);
575 
576 /* --log-header="localtime" */
577 extern void
578  log_set_localtime (void);
579 
580 /* --log-mirroring */
581 extern void
582  log_set_mirroring (void);
583 /* --log-mirroring */
584 extern boolean
585  log_get_mirroring (void);
586 
587 /* --log-stderr */
588 extern void
589  log_set_stderr (void);
590 
591 /* --log-suppress-ctrl */
592 extern void
593  log_set_suppress_ctrl (void);
594 
595 /* --log-syslog --log-vendor */
596 extern boolean
597  log_get_syslog_bfr_allocated (void);
598 
599 extern log_debug_t
600  log_syslog_log_level (void);
601 
602 /* --log-syslog --log-vendor */
603 extern boolean
604  log_get_vendor_bfr_allocated (void);
605 
606 /* --log-syslog --log-vendor */
607 extern void
608  log_set_syslog_bfr_allocated (void);
609 
610 /* --log-syslog --log-vendor */
611 extern void
612  log_set_vendor_bfr_allocated (void);
613 
614 /* --log-syslog --log-vendor */
615 extern void
616  log_clr_syslog_bfr_allocated (void);
617 
618 /* --log-syslog --log-vendor */
619 extern void
620  log_clr_vendor_bfr_allocated (void);
621 
622 /* --log-syslog */
623 extern void log_set_syslog (void);
624 extern void log_clr_syslog (void);
625 extern boolean log_get_syslog (void);
626 
627 /* --log-vendor */
628 extern void
629  log_set_vendor (void);
630 
631 /* --log-backtrace-stream="logfile" */
632 extern void
633  log_set_backtrace_logfile (void);
634 
635 /* --log-backtrace-stream="stderr" */
636 extern void
637  log_set_backtrace_stderr (void);
638 
639 /* --log-backtrace-stream="stdout" */
640 extern void
641  log_set_backtrace_stdout (void);
642 
643 /* --log-backtrace-stream="syslog" */
644 extern boolean
645  log_get_backtrace_syslog (void);
646 extern void
647  log_set_backtrace_syslog (void);
648 
649 /* --log-backtrace-stream="vendor" */
650 extern boolean
651  log_get_backtrace_vendor (void);
652 extern void
653  log_set_backtrace_vendor (void);
654 
655 
656 /********************************************************************
657  * FUNCTION log_set_backtrace
658 *
659 * Set the maximum frame count to report on a backtrace log entry
660 * (--log-backtrace=<frame_count>)
661 *
662 * INPUTS:
663 *
664 * frame_cnt == the requested frame count (if 0 then use internal default).
665 *
666 * RETURNS:
667 * None
668 *
669 *********************************************************************/
670 extern void
671  log_set_backtrace (uint frame_cnt);
672 
673 
674 /********************************************************************
675 * FUNCTIONs log_cvt_debug_level2bit
676 *
677 * Convert a debug level to a unique bit mask
678 *
679 * INPUTS:
680 *
681 * level == debug level enum to convert
682 *
683 * RETURNS:
684 * Unique bit mask
685 *
686 *********************************************************************/
687 extern uint
688  log_cvt_debug_level2bit (log_debug_t level);
689 
690 
691 /********************************************************************
692 * FUNCTIONs log_set_backtrace_level and log_clear_backtrace_level
693 *
694 * Manage the debug level bit mask to allow or restrict
695 * reporting of backtrace log entries
696 *
697 * INPUTS:
698 *
699 * log_set_backtrace_level: level == debug level for which backtrace
700 * log entries will be reported
701 *
702 * log_clear_backtrace_level: level == debug level for which backtrace
703 * log entries should no longer be reported
704 *
705 *
706 * RETURNS:
707 * none
708 *********************************************************************/
709 extern void
710  log_clear_backtrace_level (log_debug_t level);
711 
712 
713 extern void
714  log_set_backtrace_level (log_debug_t level);
715 
716 
717 /********************************************************************
718 * FUNCTION log_set_backtrace_level_mask
719 *
720 * Set the debug level bit mask to restrict reporting of backtrace info
721 *
722 * INPUTS:
723 * mask == bit mask respresenting debug levels for which to append
724 * backtrace info
725 *
726 * RETURNS:
727 * none
728 *********************************************************************/
729 extern void
730  log_set_backtrace_level_mask (uint mask);
731 
732 
733 /********************************************************************
734 * FUNCTIONs log_get_backtrace_level_mask
735 *
736 * Return the debug level bit mask in current use
737 *
738 * INPUTS:
739 * none
740 *
741 * RETURNS:
742 * mask == bit mask respresenting debug levels for which to append
743 * backtrace info
744 *********************************************************************/
745 extern uint
746  log_get_backtrace_level_mask (void);
747 
748 /********************************************************************
749 * FUNCTIONs log_test_backtrace_level
750 *
751 * Return whether a given debug level is enabled for backtrace
752 *
753 * INPUTS:
754 * level == debug level to test
755 *
756 * RETURNS:
757 * TRUE == backtrace enabled for level
758 * FALSE == backtrace disabled for level
759 *********************************************************************/
760 extern boolean
761  log_test_backtrace_level (log_debug_t level);
762 
763 
764 /********************************************************************
765 * FUNCTION log_do_backtrace
766 *
767 * Return the configured status for including backtrace info on a
768 * given output stream (e.g., logfile, syslog, stderr, etc.) at a
769 * given content level (e.g., error, warn, info, etc.).
770 *
771 * NOTE: Slightly funky. To use, pass the current (boolean) value
772 * of the config flag to be tested, along with the current
773 * content level (sub_level).
774 *
775 * INPUTS:
776 *
777 * sub_level == the content level for the log output
778 * flag == the --log-backtrace-stream flag to test
779 *
780 * RETURNS:
781 *
782 * TRUE == backtrace info should be generated
783 * FALSE == backtrace info should NOT be generated
784 *
785 *********************************************************************/
786 extern boolean
787  log_do_backtrace (log_debug_t sub_level, boolean flag);
788 
789 
805 extern status_t
806  log_open (const char *fname,
807  boolean append,
808  boolean tstamps);
809 
810 
816 extern void
817  log_close (void);
818 
819 
835 extern status_t
836  log_audit_open (const char *fname,
837  boolean append,
838  boolean tstamps);
839 
840 
846 extern void
847  log_audit_close (void);
848 
849 
855 extern boolean
856  log_audit_is_open (void);
857 
858 
869 extern status_t
870  log_alt_open (const char *fname);
871 
872 
885 extern status_t
886  log_alt_open_ex (const char *fname,
887  boolean overwrite);
888 
889 
895 extern void
896  log_alt_close (void);
897 
898 
906 extern void
907  log_init (void);
908 
909 
910 /********************************************************************
911 * FUNCTION log_common
912 *
913 * Generate "new" message log output, optionally pre-pended with an
914 * internal status header (date, time, level, etc). Additional info
915 * may be appended (via log_append()) on the same or subsequent lines.
916 *
917 * INPUTS:
918 * recursive == TRUE means this is a recursive callback from print_backtrace()
919 * level == internal logger "screening" level
920 * sub_level == internal logger functional (content) level
921 * fstr == format string in printf format
922 * args == any additional arguments for printf
923 *
924 * KLUDGE ALERT:
925 * For convenience we equate the 'recursive' param to a call from
926 * print_backtrace(), passing this information unvetted on to
927 * log_common_internal(). At present, this works because print_backtrace()
928 * is the ONLY routine to pass recursive as TRUE. Someday this may change.
929 *
930 *********************************************************************/
931 extern void
932  log_common (boolean recursive, log_debug_t level, log_debug_t sub_level,
933  const char *fstr, va_list args);
934 
935 
936 /*
937 * Append formatted string to the current logger output stream
938 *
939 * INPUTS:
940 * recursive == TRUE means this is a recursive callback from print_backtrace()
941 * level == internal logger "screening" level
942 * sub_level == internal logger functional (content) level
943 * fstr == format string in printf format
944 * args == additional arguments for printf
945 *
946 *********************************************************************/
947 extern void
948  log_append (boolean recursive, log_debug_t level, log_debug_t sub_level,
949  const char *fstr, va_list args);
950 
951 
963 extern void
964  log_flush (void);
965 
966 
967 /********************************************************************
968 * FUNCTION log_print_backtrace
969 *
970 * Print up to (array[] size) stack frame addresses
971 *
972 * INPUT:
973 *
974 * orig_sub_level == content level
975 * localfn_flush == flush call vector function
976 * max_detail == include maximum backtrace return information
977 * frame_overhead == number of frames in logger code (skip)
978 * preamble == prompt string to precede backtrace output
979 *
980 * RETURNS:
981 * none
982 *********************************************************************/
983 extern void
984  log_print_backtrace (boolean syslog_call,
985  log_debug_t orig_sub_level,
986  logfn_flush_t localfn_flush,
987  boolean max_detail,
988  uint frame_overhead,
989  const char *preamble);
990 
991 
992 /********************************************************************
993 * FUNCTION log_capture_backtrace
994 *
995 * Capture backtrace context for storage and later display. Used by
996 * chkheaps.c
997 *
998 * INPUT:
999 * strP == ptr to a ptr to an array of printable strings describing the
1000 * backtrace represented by bt_arrayP. This memory MUST be
1001 * returned (via free()) by the caller.
1002 * bt_arrayP == ptr to a (pre-allocated) buffer of size sufficient
1003 * to hold max_frames backtrace addresses (void * ptrs).
1004 * max_frames == max frames to dump, preallocated and described by bt_arrayP
1005 *
1006 * RETURNS:
1007 * none
1008 *********************************************************************/
1009 extern uint
1010  log_capture_backtrace (char ***strP, void *bt_arrayP, uint max_frames);
1011 
1012 
1013 /********************************************************************
1014 * FUNCTION log_backtrace
1015 *
1016 * Output a string followed by backtrace detail, regardless of
1017 * backtrace setting.
1018 *
1019 * In general, use only for debugging ... should not be present in released
1020 * software (though it might be useful for debugging in the field).
1021 *
1022 * INPUTS:
1023 * level == output level
1024 * fstr == format string for log message
1025 * ... == variable arg list for format string
1026 *********************************************************************/
1027 extern void
1028  log_backtrace (log_debug_t level, const char *fstr, ...)
1029  __attribute__ ((format (printf, 2, 3)));
1030 
1031 
1032 /********************************************************************
1033 * FUNCTION log_stderr_backtrace
1034 *
1035 * Print up to (array[] size) stack frame addresses but output to STDERR.
1036 * This is useful for debugging within logger, e.g., when generating an
1037 * error internal to the logging subsystem. (See log_internal_err())
1038 *
1039 * INPUT:
1040 *
1041 * max_detail == include maximum backtrace return information
1042 * preamble == prompt string to precede backtrace output
1043 *
1044 * RETURNS:
1045 * none
1046 *********************************************************************/
1047 void
1048  log_stderr_backtrace (boolean max_detail, const char *preamble);
1049 
1050 
1061 extern void
1062  log_stdout (const char *fstr, ...)
1063  __attribute__ ((format (printf, 1, 2)));
1064 
1065 
1073 extern void
1074  log_stdout_level (log_debug_t level, const char *fstr, ...)
1075  __attribute__ ((format (printf, 2, 3)));
1076 
1077 
1088 extern void
1089  log_write (const char *fstr, ...)
1090  __attribute__ ((format (printf, 1, 2)));
1091 
1099 extern void
1100  log_write_append (const char *fstr, ...)
1101  __attribute__ ((format (printf, 1, 2)));
1102 
1103 
1104 extern void
1105  log_write_filtered (log_debug_t level, const char *fstr, ...)
1106  __attribute__ ((format (printf, 2, 3)));
1107 
1108 extern void
1109  log_write_filtered_append (log_debug_t level, const char *fstr, ...)
1110  __attribute__ ((format (printf, 2, 3)));
1111 
1112 extern void
1113  log_write_syslog_level (log_debug_t level, const char *fstr, ...)
1114  __attribute__ ((format (printf, 2, 3)));
1115 
1116 extern void
1117  log_write_syslog_level_append (log_debug_t level, const char *fstr, ...)
1118  __attribute__ ((format (printf, 2, 3)));
1119 
1120 
1129 extern void
1130  log_audit_write (const char *fstr, ...)
1131  __attribute__ ((format (printf, 1, 2)));
1132 
1133 
1142 extern void
1143  log_audit_write_level (log_debug_t level, const char *fstr, ...)
1144  __attribute__ ((format (printf, 2, 3)));
1145 
1146 
1147 /********************************************************************
1148 * FUNCTION log_audit_indent
1149 *
1150 * Printf a newline to the audit logfile,
1151 * then the specified number of space chars
1152 *
1153 * INPUTS:
1154 * indentcnt == number of indent chars, -1 == skip everything
1155 *
1156 *********************************************************************/
1157 extern void
1158  log_audit_indent (int32 indentcnt);
1159 
1160 extern void
1161  log_audit_indent_level (log_debug_t level, int32 indentcnt);
1162 
1163 
1170 extern void
1171  log_alt_write (const char *fstr, ...)
1172  __attribute__ ((format (printf, 1, 2)));
1173 
1174 
1182 extern void
1183  log_alt_write_level (log_debug_t level, const char *fstr, ...)
1184  __attribute__ ((format (printf, 2, 3)));
1185 
1186 
1187 
1188 /********************************************************************
1189 * FUNCTION log_alt_indent
1190 *
1191 * Printf a newline to the alternate logfile,
1192 * then the specified number of space chars
1193 *
1194 * INPUTS:
1195 * indentcnt == number of indent chars, -1 == skip everything
1196 *
1197 *********************************************************************/
1198 extern void
1199  log_alt_indent (int32 indentcnt);
1200 
1201 extern void
1202  log_alt_indent_level (log_debug_t level, int32 indentcnt);
1203 
1204 
1205 /********************************************************************
1206 * FUNCTION vlog_error
1207 *
1208 * Generate a LOG_DEBUG_ERROR log entry
1209 *
1210 * INPUTS:
1211 * fstr == format string in printf format
1212 * valist == any additional arguments for printf
1213 *
1214 *********************************************************************/
1215 void
1216  vlog_error (const char *fstr, va_list args );
1217 
1218 
1231 extern void
1232  log_error (const char *fstr, ...)
1233  __attribute__ ((format (printf, 1, 2)));
1234 
1235 
1243 extern void
1244  log_error_append (const char *fstr, ...)
1245  __attribute__ ((format (printf, 1, 2)));
1246 
1247 
1255 extern void
1256  log_warn (const char *fstr, ...)
1257  __attribute__ ((format (printf, 1, 2)));
1258 
1259 
1267 extern void
1268  log_warn_append (const char *fstr, ...)
1269  __attribute__ ((format (printf, 1, 2)));
1270 
1271 
1279 extern void
1280  log_info (const char *fstr, ...)
1281  __attribute__ ((format (printf, 1, 2)));
1282 
1283 
1291 extern void
1292  log_info_append (const char *fstr, ...)
1293  __attribute__ ((format (printf, 1, 2)));
1294 
1295 
1303 extern void
1304  log_debug (const char *fstr, ...)
1305  __attribute__ ((format (printf, 1, 2)));
1306 
1307 
1315 extern void
1316  log_debug_append (const char *fstr, ...)
1317  __attribute__ ((format (printf, 1, 2)));
1318 
1319 
1327 extern void
1328  log_debug2 (const char *fstr, ...)
1329  __attribute__ ((format (printf, 1, 2)));
1330 
1331 
1339 extern void
1340  log_debug2_append (const char *fstr, ...)
1341  __attribute__ ((format (printf, 1, 2)));
1342 
1343 
1351 extern void
1352  log_debug3 (const char *fstr, ...)
1353  __attribute__ ((format (printf, 1, 2)));
1354 
1355 
1363 extern void
1364  log_debug3_append (const char *fstr, ...)
1365  __attribute__ ((format (printf, 1, 2)));
1366 
1367 
1375 extern void
1376  log_debug4 (const char *fstr, ...)
1377  __attribute__ ((format (printf, 1, 2)));
1378 
1379 
1387 extern void
1388  log_debug4_append (const char *fstr, ...)
1389  __attribute__ ((format (printf, 1, 2)));
1390 
1391 
1392 /********************************************************************
1393 * FUNCTIONs log_dev0 and log_dev0_append
1394 *
1395 * Generate (append to) a LOG_DEBUG_DEV0 log entry
1396 *
1397 * NOTE: This level is intended primarily for debugging, where output related
1398 * issues at {ERROR, WARN, INFO} levels change program behavior)
1399 *
1400 * INPUTS:
1401 * fstr == format string in printf format
1402 * ... == any additional arguments for printf
1403 *
1404 *********************************************************************/
1405 extern void
1406  log_dev0 (const char *fstr, ...)
1407  __attribute__ ((format (printf, 1, 2)));
1408 
1409 extern void
1410  log_dev0_append (const char *fstr, ...)
1411  __attribute__ ((format (printf, 1, 2)));
1412 
1413 
1414 /********************************************************************
1415 * FUNCTIONs log_dev1 and log_dev1_append
1416 *
1417 * Generate (append to) a LOG_DEBUG_DEV1 log entry
1418 *
1419 * NOTE: This level is intended primarily for debugging, where output related
1420 * issues at {DEBUG, DEBUG2, DEBUG3, DEBUG4} change program behavior)
1421 *
1422 * INPUTS:
1423 * fstr == format string in printf format
1424 * ... == any additional arguments for printf
1425 *
1426 *********************************************************************/
1427 extern void
1428  log_dev1 (const char *fstr, ...)
1429  __attribute__ ((format (printf, 1, 2)));
1430 
1431 extern void
1432  log_dev1_append (const char *fstr, ...)
1433  __attribute__ ((format (printf, 1, 2)));
1434 
1435 
1436 /********************************************************************
1437 * FUNCTIONs log_write_level and log_write_level_append
1438 *
1439 * Generate (append to) a LOG_DEBUG_<LEVEL> log trace entry
1440 *
1441 * NOTE: Useful when the desired debug level is passed as a param
1442 *
1443 * INPUTS:
1444 * level == debug level
1445 * fstr == format string in printf format
1446 * ... == any additional arguments for printf
1447 *
1448 *********************************************************************/
1449 extern void
1450  log_write_level (log_debug_t level, const char *fstr, ...)
1451  __attribute__ ((format (printf, 2, 3)));
1452 
1453 extern void
1454  log_write_level_append (log_debug_t level, const char *fstr, ...)
1455  __attribute__ ((format (printf, 2, 3)));
1456 
1457 
1458 /********************************************************************
1459 * FUNCTIONs log_xxx_thd and log_xxx_append_thd
1460 *
1461 * Generate (or append to) a "thread" LOG_DEBUG_XXX level log entry
1462 *
1463 * INPUTS:
1464 * fstr == format string in printf format
1465 * ... == any additional arguments for printf
1466 *
1467 *********************************************************************/
1468 #ifdef PTHREADS
1469 extern void
1470  log_dev1_thd (const char *fstr, ...)
1471  __attribute__ ((format (printf, 1, 2)));
1472 
1473 extern void
1474  log_dev1_append_thd (const char *fstr, ...)
1475  __attribute__ ((format (printf, 1, 2)));
1476 
1477 extern void
1478  log_debug_thd (const char *fstr, ...)
1479  __attribute__ ((format (printf, 1, 2)));
1480 
1481 extern void
1482  log_debug_append_thd (const char *fstr, ...)
1483  __attribute__ ((format (printf, 1, 2)));
1484 
1485 extern void
1486  log_debug2_thd (const char *fstr, ...)
1487  __attribute__ ((format (printf, 1, 2)));
1488 
1489 extern void
1490  log_debug2_append_thd (const char *fstr, ...)
1491  __attribute__ ((format (printf, 1, 2)));
1492 
1493 extern void
1494  log_debug3_thd (const char *fstr, ...)
1495  __attribute__ ((format (printf, 1, 2)));
1496 
1497 extern void
1498  log_debug3_append_thd (const char *fstr, ...)
1499  __attribute__ ((format (printf, 1, 2)));
1500 
1501 extern void
1502  log_debug4_thd (const char *fstr, ...)
1503  __attribute__ ((format (printf, 1, 2)));
1504 
1505 extern void
1506  log_debug4_append_thd (const char *fstr, ...)
1507  __attribute__ ((format (printf, 1, 2)));
1508 #endif //#ifdef PTHREADS
1509 
1510 
1511 /********************************************************************
1512 * FUNCTION log_noop
1513 *
1514 * Do not generate any log message NO-OP
1515 * Used to set logfn_t to no-loggging option
1516 *
1517 * INPUTS:
1518 * fstr == format string in printf format
1519 * ... == any additional arguments for printf
1520 *
1521 *********************************************************************/
1522 extern void
1523  log_noop (const char *fstr, ...)
1524  __attribute__ ((format (printf, 1, 2)));
1525 
1526 
1532 extern void log_set_log_level (log_debug_t dlevel);
1533 
1539 extern void log_set_syslog_log_level (log_debug_t dlevel);
1540 
1541 
1542 #ifdef PTHREADS
1543 
1548 extern void log_set_pthread_log_level (log_debug_t dlevel);
1549 #endif // PTHREADS
1550 
1551 
1552 /*
1553 * FUNCTION log_get_system_log_level
1554 *
1555 * Get the global debug filter threshold level
1556 *
1557 * RETURNS:
1558 * the debug level
1559 *********************************************************************/
1560 extern log_debug_t log_get_system_log_level (void);
1561 
1562 
1568 extern log_debug_t log_get_log_level (void);
1569 
1570 
1576 extern log_debug_t log_get_syslog_log_level (void);
1577 
1578 
1584 extern log_debug_t log_get_pthread_log_level (void);
1585 
1586 
1587 /********************************************************************
1588 * FUNCTION log_get_debug_level_enum
1589 *
1590 * Get the corresponding debug enum for the specified string
1591 *
1592 * INPUTS:
1593 * str == string value to convert
1594 *
1595 * RETURNS:
1596 * the corresponding enum for the specified debug level
1597 *********************************************************************/
1598 extern log_debug_t
1599  log_get_debug_level_enum (const char *str);
1600 
1601 extern uint
1602  log_parse_debug_level_str (const char *str);
1603 
1604 
1605 /********************************************************************
1606 * FUNCTION log_get_debug_level_string
1607 *
1608 * Get the corresponding string for the debug enum
1609 *
1610 * INPUTS:
1611 * level == the enum for the specified debug level
1612 *
1613 * RETURNS:
1614 * the string value for this enum
1615 
1616 *********************************************************************/
1617 extern const xmlChar *
1618  log_get_debug_level_string (log_debug_t level);
1619 
1620 
1621 
1622 /********************************************************************
1623 * FUNCTION log_get_debug_level_value
1624 *
1625 * Get the corresponding YANG enum value for the debug enum
1626 *
1627 * INPUTS:
1628 * level == the enum for the specified debug level
1629 *
1630 * RETURNS:
1631 * the int32 value for this enum
1632 *********************************************************************/
1633 extern int32
1634  log_get_debug_level_value (log_debug_t level);
1635 
1636 
1637 /********************************************************************
1638 * FUNCTION log_get_debug_app_string
1639 *
1640 * Get the corresponding string for the debug app enum
1641 *
1642 * INPUTS:
1643 * app == the enum for the specified debug app
1644 *
1645 * RETURNS:
1646 * the string value for this enum
1647 
1648 *********************************************************************/
1649 extern const char *
1650  log_debug_get_app_string (log_debug_app_t app);
1651 
1652 /********************************************************************
1653 * FUNCTION log_debug_app2facility
1654 *
1655 * Translate from YumaPro app to syslog facility
1656 *
1657 * INPUTS:
1658 * app == the enum for the specified YUMA app
1659 *
1660 * RETURNS:
1661 * Appropriate syslog facility code
1662 *
1663 *********************************************************************/
1664 extern int
1665  log_debug_app2facility (log_debug_app_t app);
1666 
1667 
1668 /********************************************************************
1669 * FUNCTION log_set_debug_app
1670 *
1671 * Set syslog application level ... for example, yangcli will set
1672 * USER while netconfd will set DAEMON for use by syslog.
1673 *
1674 * INPUTS:
1675 * app == the enum for the specified YUMA app
1676 *
1677 * RETURNS:
1678 * None
1679 *
1680 *********************************************************************/
1681 extern void
1682  log_set_debug_app (log_debug_app_t app);
1683 
1684 
1685 /********************************************************************
1686 * FUNCTION log_get_debug_app
1687 *
1688 * Return syslog application level.
1689 *
1690 * INPUTS:
1691 * None
1692 *
1693 * RETURNS:
1694 * enum for the current YUMA app
1695 *
1696 *********************************************************************/
1697 extern log_debug_app_t
1698  log_get_debug_app (void);
1699 
1700 
1701 /********************************************************************
1702 * FUNCTION log_debug_app_string
1703 *
1704 * Return syslog application level string equivalent
1705 *
1706 * INPUTS:
1707 * None
1708 *
1709 * RETURNS:
1710 * String equivalent for the current YUMA app type
1711 *
1712 *********************************************************************/
1713 extern const char *
1714  log_debug_app_string (void);
1715 
1716 /********************************************************************
1717 * FUNCTION log_is_open
1718 *
1719 * Check if the logfile is active
1720 *
1721 * RETURNS:
1722 * TRUE if logfile open, FALSE otherwise
1723 *********************************************************************/
1724 extern boolean
1725  log_is_open (void);
1726 
1727 
1728 /********************************************************************
1729 * FUNCTION log_indent
1730 *
1731 * Printf a newline, then the specified number of chars
1732 *
1733 * INPUTS:
1734 * indentcnt == number of indent chars, -1 == skip everything
1735 *
1736 *********************************************************************/
1737 extern void
1738  log_indent (int32 indentcnt);
1739 extern void
1740  log_indent_append (int32 indentcnt);
1741 extern void
1742  log_indent_level_append (log_debug_t level, int32 indentcnt);
1743 
1744 
1745 /********************************************************************
1746 * FUNCTION log_stdout_indent
1747 *
1748 * Printf a newline to stdout, then the specified number of chars
1749 *
1750 * INPUTS:
1751 * indentcnt == number of indent chars, -1 == skip everything
1752 *
1753 *********************************************************************/
1754 extern void
1755  log_stdout_indent (int32 indentcnt);
1756 
1757 extern void
1758  log_stdout_level_indent (log_debug_t level, int32 indentcnt);
1759 
1760 
1761 /********************************************************************
1762 * FUNCTION log_get_logfile
1763 *
1764 * Get the open logfile for direct output
1765 * Needed by libtecla to write command line history
1766 *
1767 * RETURNS:
1768 * pointer to open FILE if any
1769 * NULL if no open logfile
1770 *********************************************************************/
1771 extern FILE *
1772  log_get_logfile (void);
1773 
1774 
1775 /********************************************************************
1776 * FUNCTION log_start_capture
1777 *
1778 * Open a capture logfile for writing
1779 *
1780 * INPUTS:
1781 * fname == full filespec string for capfile
1782 *
1783 * RETURNS:
1784 * status
1785 *********************************************************************/
1786 extern status_t
1787  log_start_capture (const char *fname);
1788 
1789 
1790 /********************************************************************
1791 * FUNCTION log_end_capture
1792 *
1793 * Close a capture logfile after writing
1794 *
1795 *********************************************************************/
1796 extern void
1797  log_end_capture (void);
1798 
1799 
1800 /********************************************************************
1801 * FUNCTION log_trigger_rotate
1802 *
1803 * Trigger the logrotate procedure
1804 *
1805 * RETURNS:
1806 * none
1807 *********************************************************************/
1808 extern void
1809  log_trigger_rotate (void);
1810 
1811 /********************************************************************
1812 * FUNCTION log_rotate_requested
1813 *
1814 * Check if logrotate procedure is in progress
1815 *
1816 * RETURNS:
1817 * TRUE if logrotate procedure has been started
1818 *
1819 *********************************************************************/
1820 extern boolean
1821  log_rotate_requested (void);
1822 
1823  // END ncxlib/log/logfns
1825 
1826 
1827 
1828 #ifdef __cplusplus
1829 } /* end extern 'C' */
1830 #endif
1831 
1832 #endif /* _H_log */
LOG_STREAM_NONE
@ LOG_STREAM_NONE
value not set or error
Definition: log.h:374
log_info_append
void void void void void void log_info_append(const char *fstr,...) __attribute__((format(printf
Append to a LOG_DEBUG_INFO log entry.
log_syslog_cleanup
void log_syslog_cleanup(void)
Cleanup syslog related logging state, if any.
Definition: log_syslog.c:145
log_vendor_send
void log_vendor_send(log_debug_app_t app, log_debug_t level, const char *fstr,...) __attribute__((format(printf
Send log data to vendor log output stream.
log_debug_t_
log_debug_t_
The debug level enumerations used in util/log.c.
Definition: log.h:385
log_set_syslog_log_level
void log_set_syslog_log_level(log_debug_t dlevel)
Set the syslog log level.
Definition: log.c:3438
log_vendor_append
void log_vendor_append(boolean recursive, log_debug_t level, log_debug_t sub_level, const char *fstr, va_list args)
Append formatted string output to the internal vendor log buffer.
Definition: log_vendor.c:296
enable_default_stdout
void enable_default_stdout(void)
Used by C program variants of yp-client to enable log.c output.
Definition: log.c:260
tstamp.h
Timestamp utilities.
xml_strdup
xmlChar * xml_strdup(const xmlChar *copyFrom)
String duplicate for xmlChar.
Definition: xml_util.c:1553
log_audit_open
status_t log_audit_open(const char *fname, boolean append, boolean tstamps)
Open the audit logfile for writing.
Definition: log.c:1144
LOG_DEBUG_APP_YANGDUMP
@ LOG_DEBUG_APP_YANGDUMP
app is yangdump
Definition: log.h:407
log_vendor_common
void log_vendor_common(boolean recursive, log_debug_t level, log_debug_t sub_level, const char *fstr, va_list args)
Generate a log entry destined for vendor specific processing.
Definition: log_vendor.c:217
LOG_STREAM_CAPFILE
@ LOG_STREAM_CAPFILE
Output destined for capfile.
Definition: log.h:378
LOG_DEBUG_DEBUG4
@ LOG_DEBUG_DEBUG4
debug level 4
Definition: log.h:397
LOG_DEBUG_APP_YANGDIFF
@ LOG_DEBUG_APP_YANGDIFF
app is yangdiff
Definition: log.h:408
LOG_STREAM_STDOUT
@ LOG_STREAM_STDOUT
Output destined for stdout.
Definition: log.h:375
LOG_DEBUG_NONE
@ LOG_DEBUG_NONE
value not set or error
Definition: log.h:386
log_error
void log_error(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_ERROR log entry.
xml_util.h
XML Utilities.
ERR_NCX_DATA_EXISTS
@ ERR_NCX_DATA_EXISTS
271
Definition: status_enum.h:312
log_vendor.h
Logging manager vendor API.
log_debug3
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_alt_write_level
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.
ERR_HEAPCHK_ERR
@ ERR_HEAPCHK_ERR
016
Definition: status_enum.h:206
log_vendor_connect
void log_vendor_connect(void)
Connect to vendor log output stream (implementation TBD).
Definition: log_vendor.c:110
log_close
void log_close(void)
Close the logfile.
Definition: log.c:1106
ncxconst.h
Contains NCX constants.
log_set_log_level
void log_set_log_level(log_debug_t dlevel)
Set the main log level.
Definition: log.c:3395
ses_id_t
uint32 ses_id_t
Session ID.
Definition: ses.h:306
log_audit_write
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.
log_vendor_flush
void log_vendor_flush(void)
Flush contents of internal buffer to vendor logging system.
Definition: log_vendor.c:194
log_info
void void void void void log_info(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_INFO log entry.
log_debug2
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.
NO_ERR
@ NO_ERR
000
Definition: status_enum.h:188
log_vendor_extern.h
Logging manager vendor API registration.
log_syslog.h
Syslog logging manager API.
log_syslog_append
void log_syslog_append(boolean recursive, log_debug_t level, log_debug_t sub_level, const char *fstr, va_list args)
Append formatted string output to the internal syslog log buffer.
Definition: log_syslog.c:309
log_init
void log_init(void)
Initialize logger state.
Definition: log.c:519
LOG_STREAM_LOGFILE
@ LOG_STREAM_LOGFILE
Output destined for logfile.
Definition: log.h:377
log_alt_open_ex
status_t log_alt_open_ex(const char *fname, boolean overwrite)
Open an alternate logfile for writing.
Definition: log.c:1233
log_debug4
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.
log_set_pthread_log_level
void log_set_pthread_log_level(log_debug_t dlevel)
Set the pthreads log level.
Definition: log.c:3470
log_open
status_t log_open(const char *fname, boolean append, boolean tstamps)
Open a logfile for writing.
Definition: log.c:1088
log_warn
void void void log_warn(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_WARN log entry.
ERR_INTERNAL_VAL
@ ERR_INTERNAL_VAL
004
Definition: status_enum.h:194
log_alt_close
void log_alt_close(void)
Close the alternate logfile.
Definition: log.c:1269
LOG_DEBUG_WARN
@ LOG_DEBUG_WARN
all errors + warnings
Definition: log.h:391
log_stream_t_
log_stream_t_
The output stream enumerations used in util/log.c.
Definition: log.h:373
log_get_log_level
log_debug_t log_get_log_level(void)
Get the main log level.
Definition: log.c:3508
log_debug_append
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.
ERR_INTERNAL_MEM
@ ERR_INTERNAL_MEM
003
Definition: status_enum.h:193
LOG_STREAM_STDERR
@ LOG_STREAM_STDERR
Output destined for stderr.
Definition: log.h:376
log_cleanup
void log_cleanup(boolean phase2, boolean debugs)
Final logger cleanup prior to restart or shutdown.
Definition: log.c:544
LOG_DEBUG_WRITE
@ LOG_DEBUG_WRITE
logging turned on
Definition: log.h:388
ERR_INTERNAL_PTR
@ ERR_INTERNAL_PTR
002
Definition: status_enum.h:192
log_debug
void void void void void void void log_debug(const char *fstr,...) __attribute__((format(printf
Generate a new LOG_DEBUG_DEBUG log entry.
log_syslog_send
void log_syslog_send(log_debug_app_t app, log_debug_t level, const char *fstr,...) __attribute__((format(printf
Send log data to syslog via vsyslog()
log_write
void void void log_write(const char *fstr,...) __attribute__((format(printf
Write a new entry to the main log.
log_stdout
void log_stdout(const char *fstr,...) __attribute__((format(printf
Write output to STDOUT.
LOG_DEBUG_DEBUG2
@ LOG_DEBUG_DEBUG2
debug level 2
Definition: log.h:395
LOG_DEBUG_DEV1
@ LOG_DEBUG_DEV1
Special use developer debugging only.
Definition: log.h:393
LOG_DEBUG_APP_NETCONFD
@ LOG_DEBUG_APP_NETCONFD
app is netconfd
Definition: log.h:409
log_syslog_common
void log_syslog_common(boolean recursive, log_debug_t level, log_debug_t sub_level, const char *fstr, va_list args)
Generate a log entry destined for vendor specific processing.
Definition: log_syslog.c:247
LOG_DEBUG_APP_YANGCLI
@ LOG_DEBUG_APP_YANGCLI
app is yangcli
Definition: log.h:406
log_audit_close
void log_audit_close(void)
Close the audit_logfile.
Definition: log.c:1162
log_debug4_append
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.
log_syslog_connect
void log_syslog_connect(void)
Connect to syslog output stream via openlog()
Definition: log_syslog.c:178
log_vendor_cleanup
void log_vendor_cleanup(void)
Cleanup vendor related logging state, if any.
Definition: log_vendor.c:90
log_debug_app_t_
log_debug_app_t_
syslog wants to know what app is logging ...
Definition: log.h:404
tstamp_datetime
void tstamp_datetime(xmlChar *buff)
Set the current date and time in an XML dateTime string format.
Definition: tstamp.c:160
LOG_DEBUG_ERROR
@ LOG_DEBUG_ERROR
fatal + internal errors only
Definition: log.h:390
LOG_DEBUG_OFF
@ LOG_DEBUG_OFF
logging turned off
Definition: log.h:387
ncx_netconfd_running
boolean ncx_netconfd_running(void)
Check if netconfd running.
Definition: ncx.c:11805
xml_strcmp
int xml_strcmp(const xmlChar *s1, const xmlChar *s2)
String compare for xmlChar.
Definition: xml_util.c:1746
log_get_syslog_log_level
log_debug_t log_get_syslog_log_level(void)
Get the syslog log level.
Definition: log.c:3523
log.h
NCX System Logging Manager.
log_flush
void log_flush(void)
Flush output buffers.
Definition: log.c:1880
log_syslog_flush
void log_syslog_flush(void)
Flush contents of internal buffer to vendor logging system.
Definition: log_syslog.c:225
LOGDEBUG
#define LOGDEBUG
Check if at least log-level=debug.
Definition: log.h:287
LOG_DEBUG_DEV0
@ LOG_DEBUG_DEV0
Special use developer debugging only.
Definition: log.h:389
log_error_append
void void log_error_append(const char *fstr,...) __attribute__((format(printf
Append to a LOG_DEBUG_ERROR log entry.
log_write_append
void void void void log_write_append(const char *fstr,...) __attribute__((format(printf
Append to the last log entry to the main log.
log_stdout_level
void void log_stdout_level(log_debug_t level, const char *fstr,...) __attribute__((format(printf
Write output to STDOUT if debug level set.
thd.h
Thread support (for now limited to netconfd)
log_debug2_append
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.
ncx.h
YANG module utility functions.
LOG_DEBUG_DEBUG
@ LOG_DEBUG_DEBUG
debug level 1
Definition: log.h:394
LOG_DEBUG_DEBUG3
@ LOG_DEBUG_DEBUG3
debug level 3
Definition: log.h:396
TSTAMP_MIN_SIZE
#define TSTAMP_MIN_SIZE
normal minimum buffer size for a tstamp buffer
Definition: tstamp.h:67
LOG_DEBUG_INFO
@ LOG_DEBUG_INFO
all previous + user info trace
Definition: log.h:392
log_audit_is_open
boolean log_audit_is_open(void)
Check if the audit log is open.
Definition: log.c:1190
disable_default_stdout
void disable_default_stdout(void)
Used by yp-client to disable log.c output.
Definition: log.c:255
ncx_file_close
void ncx_file_close(FILE *fp)
Close a file; check result.
Definition: ncx.c:13235
log_audit_write_level
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.
log_warn_append
void void void void log_warn_append(const char *fstr,...) __attribute__((format(printf
Append to a LOG_DEBUG_WARN log entry.
log_alt_open
status_t log_alt_open(const char *fname)
Open an alternate logfile for writing.
Definition: log.c:1211
log_get_pthread_log_level
log_debug_t log_get_pthread_log_level(void)
Get the pthreads log level.
Definition: log.c:3560
SET_ERROR
#define SET_ERROR(E)
macro SET_ERROR
Definition: status_enum.h:103
thd_get_ids
void thd_get_ids(int *tid, ses_id_t *sid)
Return the TID and SID of the current running thread.
Definition: thd.c:1021
ERR_FIL_OPEN
@ ERR_FIL_OPEN
system errors start at 100
Definition: status_enum.h:212
tstamp_local_datetime
void tstamp_local_datetime(xmlChar *buff)
Set the current date and time in an XML dateTime string format.
Definition: tstamp.c:189
status.h
Global error messages for status code enumerations.
log_alt_write
void log_alt_write(const char *fstr,...) __attribute__((format(printf
Write to the alternate log file.
log_debug3_append
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.