yumapro  24.10-3
YumaPro SDK
Loading...
Searching...
No Matches
Logging Functions

Configure logging and write to the various logging streams. More...

Collaboration diagram for Logging Functions:

Functions

void disable_default_stdout (void)
 Used by yp-client to disable log.c output.
 
void enable_default_stdout (void)
 Used by C program variants of yp-client to enable log.c output.
 
void log_cleanup (boolean phase2, boolean debugs)
 Final logger cleanup prior to restart or shutdown. More...
 
status_t log_open (const char *fname, boolean append, boolean tstamps)
 Open a logfile for writing. More...
 
void log_close (void)
 Close the logfile. More...
 
status_t log_audit_open (const char *fname, boolean append, boolean tstamps)
 Open the audit logfile for writing. More...
 
void log_audit_close (void)
 Close the audit_logfile. More...
 
boolean log_audit_is_open (void)
 Check if the audit log is open. More...
 
status_t log_alt_open (const char *fname)
 Open an alternate logfile for writing. More...
 
status_t log_alt_open_ex (const char *fname, boolean overwrite)
 Open an alternate logfile for writing. More...
 
status_t log_alt_open_force (const char *fname, boolean overwrite, boolean force_mode)
 Open an alternate logfile for writing. More...
 
void log_alt_close (void)
 Close the alternate logfile. More...
 
void log_init (void)
 Initialize logger state. More...
 
void log_flush (void)
 Flush output buffers. More...
 
void log_stdout (const char *fstr,...) __attribute__((format(printf
 Write output to STDOUT. More...
 
void void log_stdout_level (log_debug_t level, const char *fstr,...) __attribute__((format(printf
 Write output to STDOUT if debug level set. More...
 
void void void log_write (const char *fstr,...) __attribute__((format(printf
 Write a new entry to the main log. More...
 
void void void void log_write_append (const char *fstr,...) __attribute__((format(printf
 Append to the last log entry to the main log. More...
 
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. More...
 
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. More...
 
void log_alt_write (const char *fstr,...) __attribute__((format(printf
 Write to the alternate log file. More...
 
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. More...
 
void log_error (const char *fstr,...) __attribute__((format(printf
 Generate a new LOG_DEBUG_ERROR log entry. More...
 
void void log_error_append (const char *fstr,...) __attribute__((format(printf
 Append to a LOG_DEBUG_ERROR log entry. More...
 
void void void log_warn (const char *fstr,...) __attribute__((format(printf
 Generate a new LOG_DEBUG_WARN log entry. More...
 
void void void void log_warn_append (const char *fstr,...) __attribute__((format(printf
 Append to a LOG_DEBUG_WARN log entry. More...
 
void void void void void log_info (const char *fstr,...) __attribute__((format(printf
 Generate a new LOG_DEBUG_INFO log entry. More...
 
void void void void void void log_info_append (const char *fstr,...) __attribute__((format(printf
 Append to a LOG_DEBUG_INFO log entry. More...
 
void void void void void void void log_debug (const char *fstr,...) __attribute__((format(printf
 Generate a new LOG_DEBUG_DEBUG log entry. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
logfn_t log_get_appendfn (log_debug_t loglevel)
 Get the logfn_t for the corresponding log-level FOR APPEND. More...
 
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. More...
 
void log_set_syslog_log_level (log_debug_t dlevel)
 Set the syslog log level. More...
 
void log_set_pthread_log_level (log_debug_t dlevel)
 Set the pthreads log level. More...
 
log_debug_t log_get_log_level (void)
 Get the main log level. More...
 
log_debug_t log_get_syslog_log_level (void)
 Get the syslog log level. More...
 
log_debug_t log_get_pthread_log_level (void)
 Get the pthreads log level. More...
 
void log_set_highres_datetime (boolean val)
 Set the high resolution date-time usage flag. More...
 
boolean log_get_highres_datetime (void)
 Get the high resolution date-time usage flag. More...
 

Detailed Description

Configure logging and write to the various logging streams.

The server can configure 3 different logging streams

The yangcli program uses the 'alt' log to save output to a temporary file.

Function Documentation

◆ log_alt_close()

void log_alt_close ( void  )

Close the alternate logfile.

See also
log_alt_open
Here is the call graph for this function:

◆ log_alt_open()

status_t log_alt_open ( const char *  fname)

Open an alternate logfile for writing.

DO NOT use this function to send log entries to STDOUT Leave the logfile NULL instead.

Parameters
fnamefull filespec string for logfile
Returns
status
See also
log_alt_close
Here is the call graph for this function:

◆ log_alt_open_ex()

status_t log_alt_open_ex ( const char *  fname,
boolean  overwrite 
)

Open an alternate logfile for writing.

DO NOT use this function to send log entries to STDOUT Leave the logfile NULL instead.

Parameters
fnamefull filespec string for logfile
overwriteTRUE if OK to overwrite; FALSE to generate DATA_EXISTS errors
Returns
status
See also
log_alt_close
Here is the call graph for this function:

◆ log_alt_open_force()

status_t log_alt_open_force ( const char *  fname,
boolean  overwrite,
boolean  force_mode 
)

Open an alternate logfile for writing.

DO NOT use this function to send log entries to STDOUT Leave the logfile NULL instead.

This logfile will get a copy of the output if the force_mode parameter is true

Parameters
fnamefull filespec string for logfile
overwriteTRUE if OK to overwrite;
FALSE to generate DATA_EXISTS errors
force_modeTRUE to check this log file from the log_vlog_common function
FALSE to only check the altlogfile if a log_alt_write API is used.
Returns
status
Here is the caller graph for this function:

◆ log_alt_write()

void log_alt_write ( const char *  fstr,
  ... 
)

Write to the alternate log file.

Parameters
fstrformat string in printf format
...any additional arguments for fprintf

◆ log_alt_write_level()

void void log_alt_write_level ( log_debug_t  level,
const char *  fstr,
  ... 
)

Write to the alternate log file if debug-level set.

Parameters
leveldebug level to check
fstrformat string in printf format
...any additional arguments for fprintf

◆ log_audit_close()

void log_audit_close ( void  )

Close the audit_logfile.

See also
log_audit_open
Here is the call graph for this function:

◆ log_audit_is_open()

boolean log_audit_is_open ( void  )

Check if the audit log is open.

Returns
TRUE if audit log is open; FALSE if not
Here is the caller graph for this function:

◆ log_audit_open()

status_t log_audit_open ( const char *  fname,
boolean  append,
boolean  tstamps 
)

Open the audit logfile for writing.

DO NOT use this function to send log entries to STDOUT Leave the audit_logfile NULL instead.

Parameters
fnamefull filespec string for audit logfile
appendTRUE if the log should be appended; FALSE if it should be rewriten
tstampsTRUE if the datetime stamp should be generated at log-open and log-close time; FALSE if no open and close timestamps should be generated
Returns
status
See also
log_audit_close
Here is the caller graph for this function:

◆ log_audit_write()

void void void void void void void void void log_audit_write ( const char *  fstr,
  ... 
)

Write an new entry to the audit log file.

Generate an audit log entry, regardless of log level

Parameters
fstrformat string in printf format
...any additional arguments for printf

◆ 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,
  ... 
)

Write an new entry to the audit log file if the log level is set.

Parameters
leveldebug level to check
fstrformat string in printf format
...any additional arguments for printf

◆ log_cleanup()

void log_cleanup ( boolean  phase2,
boolean  debugs 
)

Final logger cleanup prior to restart or shutdown.

See also
log_init
Here is the call graph for this function:
Here is the caller graph for this function:

◆ log_close()

void log_close ( void  )

Close the logfile.

See also
log_open
Here is the call graph for this function:
Here is the caller graph for this function:

◆ log_debug()

void void void void void void void log_debug ( const char *  fstr,
  ... 
)

Generate a new LOG_DEBUG_DEBUG log entry.

Parameters
fstrformat string in printf format
...any additional arguments for printf
See also
log_debug_append

◆ log_debug2()

void void void void void void void void void log_debug2 ( const char *  fstr,
  ... 
)

Generate a new LOG_DEBUG_DEBUG2 log entry.

Parameters
fstrformat string in printf format
...any additional arguments for printf
See also
log_debug2_append

◆ log_debug2_append()

void void void void void void void void void void log_debug2_append ( const char *  fstr,
  ... 
)

Append to a LOG_DEBUG_DEBUG2 log entry.

Parameters
fstrformat string in printf format
...any additional arguments for printf
See also
log_debug2

◆ log_debug3()

void void void void void void void void void void void log_debug3 ( const char *  fstr,
  ... 
)

Generate a new LOG_DEBUG_DEBUG3 log entry.

Parameters
fstrformat string in printf format
...any additional arguments for printf
See also
log_debug3_append

◆ log_debug3_append()

void void void void void void void void void void void void log_debug3_append ( const char *  fstr,
  ... 
)

Append to a LOG_DEBUG_DEBUG3 log entry.

Parameters
fstrformat string in printf format
...any additional arguments for printf
See also
log_debug3

◆ log_debug4()

void void void void void void void void void void void void void log_debug4 ( const char *  fstr,
  ... 
)

Generate a new LOG_DEBUG_DEBUG4 log entry.

Parameters
fstrformat string in printf format
...any additional arguments for printf
See also
log_debug4_append

◆ log_debug4_append()

void void void void void void void void void void void void void void log_debug4_append ( const char *  fstr,
  ... 
)

Append to a LOG_DEBUG_DEBUG4 log entry.

Parameters
fstrformat string in printf format
...any additional arguments for printf
See also
log_debug4

◆ log_debug_append()

void void void void void void void void log_debug_append ( const char *  fstr,
  ... 
)

Append to a LOG_DEBUG_DEBUG log entry.

Parameters
fstrformat string in printf format
...any additional arguments for printf
See also
log_debug

◆ log_error()

void log_error ( const char *  fstr,
  ... 
)

Generate a new LOG_DEBUG_ERROR log entry.

In general, call log_error() once and append additional output as many times as necessary to complete the message (for example, from a loop). Note that additional output at a different log level should NOT be attempted, but no check is made for this condition currently.

Parameters
fstrformat string in printf format
...any additional arguments for printf
See also
log_error_append

◆ log_error_append()

void void log_error_append ( const char *  fstr,
  ... 
)

Append to a LOG_DEBUG_ERROR log entry.

Parameters
fstrformat string in printf format
...any additional arguments for printf
See also
log_error

◆ log_flush()

void log_flush ( void  )

Flush output buffers.

NOTE: For "classic" output this is probably redundant since we clear buffers as we go along. However, for syslog and vendor streams this is important. That's because we buffer our formatted output and only send it on in full chunks. The buffering code can't always know when a buffered log message is complete.

Here is the caller graph for this function:

◆ log_get_appendfn()

logfn_t log_get_appendfn ( log_debug_t  loglevel)

Get the logfn_t for the corresponding log-level FOR APPEND.

Parameters
loglevellog level enum to return default log function
Returns
pointer to log append function or NULL if some error
Here is the caller graph for this function:

◆ log_get_highres_datetime()

boolean log_get_highres_datetime ( void  )

Get the high resolution date-time usage flag.

Returns
TRUE if timestamps using microsecond resolution
FALSE if timestamps using second resolution

◆ log_get_log_level()

log_debug_t log_get_log_level ( void  )

Get the main log level.

Returns
the main log level setting
Here is the caller graph for this function:

◆ log_get_logfn()

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.

Parameters
loglevellog level enum to return default log function
Returns
pointer to log function or NULL if some error
Here is the caller graph for this function:

◆ log_get_pthread_log_level()

log_debug_t log_get_pthread_log_level ( void  )

Get the pthreads log level.

Returns
the pthreads log level setting
Here is the caller graph for this function:

◆ log_get_syslog_log_level()

log_debug_t log_get_syslog_log_level ( void  )

Get the syslog log level.

Returns
the syslog log level setting
Here is the caller graph for this function:

◆ log_info()

void void void void void log_info ( const char *  fstr,
  ... 
)

Generate a new LOG_DEBUG_INFO log entry.

Parameters
fstrformat string in printf format
...any additional arguments for printf
See also
log_info_append

◆ log_info_append()

void void void void void void log_info_append ( const char *  fstr,
  ... 
)

Append to a LOG_DEBUG_INFO log entry.

Parameters
fstrformat string in printf format
...any additional arguments for printf
See also
log_info

◆ log_init()

void log_init ( void  )

Initialize logger state.

NOTE: Called early in initialization by each app.

See also
log_cleanup

◆ log_open()

status_t log_open ( const char *  fname,
boolean  append,
boolean  tstamps 
)

Open a logfile for writing.

DO NOT use this function to send log entries to STDOUT Leave the logfile NULL instead.

Parameters
fnamefull filespec string for logfile
appendTRUE if the log should be appended; FALSE if it should be rewriten
tstampsTRUE if the datetime stamp should be generated at log-open and log-close time; FALSE if no open and close timestamps should be generated
Returns
status
See also
log_close
Here is the caller graph for this function:

◆ log_set_highres_datetime()

void log_set_highres_datetime ( boolean  val)

Set the high resolution date-time usage flag.

If true then 'localtime' field will include a micro-seconds field. All 6 digits will be printed even if the value us less than 6 digits.

Implements –log-highres-datetime CLI parameter

Parameters
valvalue to use
Here is the caller graph for this function:

◆ log_set_log_level()

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.

Parameters
dlevelnew main log debug level
Here is the caller graph for this function:

◆ log_set_pthread_log_level()

void log_set_pthread_log_level ( log_debug_t  dlevel)

Set the pthreads log level.

Parameters
dlevelnew pthreads log debug level
Here is the caller graph for this function:

◆ log_set_syslog_log_level()

void log_set_syslog_log_level ( log_debug_t  dlevel)

Set the syslog log level.

Parameters
dlevelnew syslog log debug level
Here is the caller graph for this function:

◆ log_stdout()

void log_stdout ( const char *  fstr,
  ... 
)

Write output to STDOUT.

Write lines of text to STDOUT, even if the logfile is open, unless the debug mode is set to NONE to indicate silent batch mode

Parameters
fstrformat string in printf format @ param ... any additional arguments for printf

◆ log_stdout_level()

void void log_stdout_level ( log_debug_t  level,
const char *  fstr,
  ... 
)

Write output to STDOUT if debug level set.

Parameters
leveldebug level threshold for printing output
fstrformat string in printf format @ param ... any additional arguments for printf

◆ log_warn()

void void void log_warn ( const char *  fstr,
  ... 
)

Generate a new LOG_DEBUG_WARN log entry.

Parameters
fstrformat string in printf format
...any additional arguments for printf
See also
log_warn_append

◆ log_warn_append()

void void void void log_warn_append ( const char *  fstr,
  ... 
)

Append to a LOG_DEBUG_WARN log entry.

Parameters
fstrformat string in printf format
...any additional arguments for printf
See also
log_warn

◆ log_write()

void void void log_write ( const char *  fstr,
  ... 
)

Write a new entry to the main log.

Generate (append to) a log entry, regardless of log level (except batch mode).

Parameters
fstrformat string in printf format
...any additional arguments for printf
See also
log_write_append

◆ log_write_append()

void void void void log_write_append ( const char *  fstr,
  ... 
)

Append to the last log entry to the main log.

Parameters
fstrformat string in printf format
...any additional arguments for printf
See also
log_write