include/nmxp_log.h File Reference

Log for Nanometrics Protocol Library. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define NMXP_LOG_H   1
#define NMXP_LOG_SET   -1
#define NMXP_LOG_NORM   0
#define NMXP_LOG_ERR   1
#define NMXP_LOG_WARN   2
#define NMXP_LOG_NORM_NO   3
#define NMXP_LOG_NORM_PKG   4
#define NMXP_LOG_STR(s)   (s == NULL)? "<null>" : s
#define NMXP_LOG_D_NULL   0
#define NMXP_LOG_D_CHANSTATE   1
#define NMXP_LOG_D_CHANNEL   NMXP_LOG_D_CHANSTATE << 1
#define NMXP_LOG_D_RAWSTREAM   NMXP_LOG_D_CHANSTATE << 2
#define NMXP_LOG_D_CRC   NMXP_LOG_D_CHANSTATE << 3
#define NMXP_LOG_D_CONNFLOW   NMXP_LOG_D_CHANSTATE << 4
#define NMXP_LOG_D_PACKETMAN   NMXP_LOG_D_CHANSTATE << 5
#define NMXP_LOG_D_EXTRA   NMXP_LOG_D_CHANSTATE << 6
#define NMXP_LOG_D_DATE   NMXP_LOG_D_CHANSTATE << 7
#define NMXP_LOG_D_GAP   NMXP_LOG_D_CHANSTATE << 8
#define NMXP_LOG_D_DOD   NMXP_LOG_D_CHANSTATE << 9
#define NMXP_LOG_D_ANY

Functions

void nmxp_log_set_prefix (char *prefix)
 Add prefix string for logging.
const char * nmxp_log_version ()
 Print value of PACKAGE_NAME and PACKAGE_VERSION.
void nmxp_log_init (int(*func_log)(char *), int(*func_log_err)(char *))
 Set function pointers for "normal logging" and "error logging".
void nmxp_log_add (int(*func_log)(char *), int(*func_log_err)(char *))
 Add function pointers to "normal logging" and "error_logging".
void nmxp_log_rem (int(*func_log)(char *), int(*func_log_err)(char *))
 Remove function pointers from "normal logging" and "error_logging".
int nmxp_log_stdout (char *msg)
 Wrapper for fprintf to stdout and flushing.
int nmxp_log_stderr (char *msg)
 Wrapper for fprintf to stderror and flushing.
int nmxp_log (int level, int verb,...)
 A generic logging/printing routine.


Detailed Description

Log for Nanometrics Protocol Library.

Author: Matteo Quintiliani Istituto Nazionale di Geofisica e Vulcanologia - Italy quintiliani@ingv.it

Id

Define Documentation

#define NMXP_LOG_H   1

#define NMXP_LOG_SET   -1

normal output with time and package name

#define NMXP_LOG_NORM   0

normal output with time and package name

#define NMXP_LOG_ERR   1

error output with time and package name

#define NMXP_LOG_WARN   2

warning output with time and package name

#define NMXP_LOG_NORM_NO   3

normal output without time and package name

#define NMXP_LOG_NORM_PKG   4

normal output with only package name

#define NMXP_LOG_STR (  )     (s == NULL)? "<null>" : s

If s is NULL return "<null>", otherwise value of s

#define NMXP_LOG_D_NULL   0

kind of log message

#define NMXP_LOG_D_CHANSTATE   1

#define NMXP_LOG_D_CHANNEL   NMXP_LOG_D_CHANSTATE << 1

#define NMXP_LOG_D_RAWSTREAM   NMXP_LOG_D_CHANSTATE << 2

#define NMXP_LOG_D_CRC   NMXP_LOG_D_CHANSTATE << 3

#define NMXP_LOG_D_CONNFLOW   NMXP_LOG_D_CHANSTATE << 4

#define NMXP_LOG_D_PACKETMAN   NMXP_LOG_D_CHANSTATE << 5

#define NMXP_LOG_D_EXTRA   NMXP_LOG_D_CHANSTATE << 6

#define NMXP_LOG_D_DATE   NMXP_LOG_D_CHANSTATE << 7

#define NMXP_LOG_D_GAP   NMXP_LOG_D_CHANSTATE << 8

#define NMXP_LOG_D_DOD   NMXP_LOG_D_CHANSTATE << 9

#define NMXP_LOG_D_ANY

Value:


Function Documentation

void nmxp_log_set_prefix ( char *  prefix  ) 

Add prefix string for logging.

Parameters:
prefix string message

const char* nmxp_log_version (  ) 

Print value of PACKAGE_NAME and PACKAGE_VERSION.

void nmxp_log_init ( int(*)(char *)  func_log,
int(*)(char *)  func_log_err 
)

Set function pointers for "normal logging" and "error logging".

Parameters:
func_log Function pointer to the the function for "normal logging"
func_log_err Function pointer to the the function for "error logging"

void nmxp_log_add ( int(*)(char *)  func_log,
int(*)(char *)  func_log_err 
)

Add function pointers to "normal logging" and "error_logging".

Parameters:
func_log Function pointer to the the function for "normal logging"
func_log_err Function pointer to the the function for "error logging"

void nmxp_log_rem ( int(*)(char *)  func_log,
int(*)(char *)  func_log_err 
)

Remove function pointers from "normal logging" and "error_logging".

Parameters:
func_log Function pointer to the the function for "normal logging"
func_log_err Function pointer to the the function for "error logging"

int nmxp_log_stdout ( char *  msg  ) 

Wrapper for fprintf to stdout and flushing.

Parameters:
msg String message

int nmxp_log_stderr ( char *  msg  ) 

Wrapper for fprintf to stderror and flushing.

Parameters:
msg String message

int nmxp_log ( int  level,
int  verb,
  ... 
)

A generic logging/printing routine.

This function works in two modes:

  1. Initialization, expecting 2 arguments with the first (level) being NMXP_LOG_SET and the second being verbosity bitmap. This will set the verbosity for all future calls, the default is NMXP_LOG_D_NULL. Can be used to change the verbosity at any time. I.e. 'nmxp_log(NMXP_LOG_SET, NMXP_LOG_D_PACKET | NMXP_LOG_D_CONNFLOW);'
  2. Expecting 3+ arguments, log level, verbosity, printf format, and printf arguments. If the verbosity is included into the set verbosity bitmap (see mode 1), the printf format and arguments will be printed at the appropriate log level, where level represents:
    1. 0, normal output with time and package name
    2. 1, error output with time and package name
    3. 2, warning output with time and package name
    4. 3, normal output without time and package name
    5. 4, normal output with only package name N.B. Error messages will always be printed! TODO Optional for all warning messages

Return values:
new_verbosity if using mode 1.
n the number of characters formatted on success, and a a negative value on error if using mode 2.
Parameters:
level 
verb 
... 


Generated on Wed Jul 23 02:18:05 2008 for libnmxp by  doxygen 1.5.3