logging.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include "libdali.h"

Include dependency graph for logging.c:


Functions

void dl_loginit_main (DLLog *logp, int verbosity, void(*log_print)(char *), const char *logprefix, void(*diag_print)(char *), const char *errprefix)
 Initialize the logging system.
int dl_log_main (DLLog *logp, int level, int verb, va_list *varlist)
 Primary log message processing routine.
void dl_loginit (int verbosity, void(*log_print)(char *), const char *logprefix, void(*diag_print)(char *), const char *errprefix)
 Initialize global logging system parameters.
void dl_loginit_r (DLCP *dlconn, int verbosity, void(*log_print)(char *), const char *logprefix, void(*diag_print)(char *), const char *errprefix)
 Initialize logging parameters specific to a DLCP.
DLLogdl_loginit_rl (DLLog *log, int verbosity, void(*log_print)(char *), const char *logprefix, void(*diag_print)(char *), const char *errprefix)
 Initialize logging parameters for a specific DLLog.
int dl_log (int level, int verb,...)
 Log a message using the global logging parameters.
int dl_log_r (const DLCP *dlconn, int level, int verb,...)
 Log a message using the log parameters from a DLCP.
int dl_log_rl (DLLog *log, int level, int verb,...)
 Log a message using the log parameters from a DLCP.

Variables

DLLog gDLLog = {NULL, NULL, NULL, NULL, 0}

Detailed Description

Log handling routines for libdali.

These logging routines are used throughout the library and allow all log, diagnostic and error message output to be redirected or otherwise fine tuned.

The most important routines for general library use are dl_loginit() and dl_log().

Author:
Chad Trabant, IRIS Data Management Center
modified: 2008.193

Function Documentation

int dl_log ( int  level,
int  verb,
  ... 
)

Log a message using the global logging parameters.

A wrapper to dl_log_main() that uses the global logging parameters.

Parameters:
level Level at which to log the message (1, 2 or 3)
verb Verbosity threshold at which to log the message
... Message format and optional arguments in printf style
Returns:
See dl_log_main() description for return values.

int dl_log_main ( DLLog logp,
int  level,
int  verb,
va_list *  varlist 
)

Primary log message processing routine.

Prinmary logging/printing routine.

This routine acts as a central message facility for the all of the libdali functions.

The function uses logging parameters specified in the supplied DLLog.

This function expects 3+ arguments, message level, verbosity level, fprintf format, and fprintf arguments. If the verbosity level is less than or equal to the set verbosity (see dl_loginit_main()), the fprintf format and arguments will be printed at the appropriate level.

Three levels are recognized: 0 : Normal log messages, printed using log_print with logprefix 1 : Diagnostic messages, printed using diag_print with logprefix 2+ : Error messagess, printed using diag_print with errprefix

This function builds the log/error message and passes to it as a string (char *) to the functions defined with dl_loginit() or dl_loginit_r(). If the log/error printing functions have not been defined messages will be printed with fprintf, log messages to stdout and error messages to stderr.

If the log/error prefix's have been set with dl_loginit() or dl_loginit_r() they will be pre-pended to the message.

All messages will be truncated to the MAX_LOG_MSG_LENGTH, this includes any set prefix.

Parameters:
logp DLLog logging paramters
level Level at which to log the message (1, 2 or 3)
verb Verbosity threshold at which to log the message
varlist Message format and optional arguments in printf style
Returns:
The number of characters formatted on success, and a a negative value on error.

int dl_log_r ( const DLCP dlconn,
int  level,
int  verb,
  ... 
)

Log a message using the log parameters from a DLCP.

A wrapper to dl_log_main() that uses the logging parameters in a supplied DLCP. If the supplied pointer is NULL the global logging parameters will be used.

Parameters:
dlconn DataLink Connection Parameters with associated logging paramters
level Level at which to log the message (1, 2 or 3)
verb Verbosity threshold at which to log the message
... Message format and optional arguments in printf style
Returns:
See dl_log_main() description for return values.

int dl_log_rl ( DLLog log,
int  level,
int  verb,
  ... 
)

Log a message using the log parameters from a DLCP.

A wrapper to dl_log_main() that uses the logging parameters in a supplied DLLog. If the supplied pointer is NULL the global logging parameters will be used.

Parameters:
log DLLog logging paramters
level Level at which to log the message (1, 2 or 3)
verb Verbosity threshold at which to log the message
... Message format and optional arguments in printf style
Returns:
See dl_log_main() description for return values.

void dl_loginit ( int  verbosity,
void(*)(char *)  log_print,
const char *  logprefix,
void(*)(char *)  diag_print,
const char *  errprefix 
)

Initialize global logging system parameters.

Initialize the global logging parameters.

See dl_loginit_main() description for usage.

void dl_loginit_main ( DLLog logp,
int  verbosity,
void(*)(char *)  log_print,
const char *  logprefix,
void(*)(char *)  diag_print,
const char *  errprefix 
)

Initialize the logging system.

Initialize the logging subsystem. The logging paramters determine how dl_log() and dl_log_r() emit messages.

This function modifies the logging parameters in the passed DLLog.

Any log/error printing functions indicated must accept a single argument, namely a string (char *). The dl_log() and dl_log_r() functions format each message and then pass the result on to the log/error printing functions.

If the log/error prefixes have been set they will be pre-pended to the message.

Use NULL for the function pointers or the prefixes if they should not be changed from previously set or default values. The default behavior of the logging subsystem is given in the example below.

Example: dl_loginit_main (0, (void*)&printf, NULL, (void*)&printf, "error: ");

Parameters:
logp The DLLog parameters to change
verbosity The verbosity level
log_print Pointer to a log message printing function
logprefix Prefix to add to each log & diganostic message
diag_print Pointer to a diagnostic & error message printing function
errprefix Prefix to add to each error message

void dl_loginit_r ( DLCP dlconn,
int  verbosity,
void(*)(char *)  log_print,
const char *  logprefix,
void(*)(char *)  diag_print,
const char *  errprefix 
)

Initialize logging parameters specific to a DLCP.

Initialize DLCP specific logging parameters. If the logging parameters have not been initialized (dlconn->log == NULL) new parameter space will be allocated.

See dl_loginit_main() description for usage.

DLLog* dl_loginit_rl ( DLLog log,
int  verbosity,
void(*)(char *)  log_print,
const char *  logprefix,
void(*)(char *)  diag_print,
const char *  errprefix 
)

Initialize logging parameters for a specific DLLog.

Initialize DLLog specific logging parameters. If the logging parameters have not been initialized (log == NULL) new parameter space will be allocated.

See dl_loginit_main() description for usage.

Returns:
A pointer to the created/re-initialized DLLog struct.


Variable Documentation

DLLog gDLLog = {NULL, NULL, NULL, NULL, 0}

Initial global logging parameters


Generated on Fri Sep 12 15:38:53 2008 for libdali by  doxygen 1.5.6