EPICS Base  7.0.6.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Typedefs | Enumerations | Functions | Variables
errlog.h File Reference

Functions for interacting with the errlog task. More...

#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include "libComAPI.h"
#include "compilerDependencies.h"
Include dependency graph for errlog.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define errMessage(S, PM)   errPrintf(S, __FILE__, __LINE__, "%s", PM)
 
#define epicsPrintf   errlogPrintf
 
#define epicsVprintf   errlogVprintf
 

Typedefs

typedef void(* errlogListener )(void *pPrivate, const char *message)
 

Enumerations

enum  errlogSevEnum { errlogInfo, errlogMinor, errlogMajor, errlogFatal }
 

Functions

LIBCOM_API int errlogPrintf (const char *pformat,...) EPICS_PRINTF_STYLE(1
 
LIBCOM_API int LIBCOM_API int errlogVprintf (const char *pformat, va_list pvar)
 
LIBCOM_API int errlogSevPrintf (const errlogSevEnum severity, const char *pformat,...) EPICS_PRINTF_STYLE(2
 
LIBCOM_API int LIBCOM_API int errlogSevVprintf (const errlogSevEnum severity, const char *pformat, va_list pvar)
 
LIBCOM_API int errlogMessage (const char *message)
 
LIBCOM_API const char * errlogGetSevEnumString (errlogSevEnum severity)
 
LIBCOM_API void errlogSetSevToLog (errlogSevEnum severity)
 
LIBCOM_API errlogSevEnum errlogGetSevToLog (void)
 
LIBCOM_API void errlogAddListener (errlogListener listener, void *pPrivate)
 
LIBCOM_API int errlogRemoveListeners (errlogListener listener, void *pPrivate)
 
LIBCOM_API int eltc (int yesno)
 
LIBCOM_API int errlogSetConsole (FILE *stream)
 
LIBCOM_API int errlogInit (int bufsize)
 
LIBCOM_API int errlogInit2 (int bufsize, int maxMsgSize)
 
LIBCOM_API void errlogFlush (void)
 
LIBCOM_API void errPrintf (long status, const char *pFileName, int lineno, const char *pformat,...) EPICS_PRINTF_STYLE(4
 
LIBCOM_API void LIBCOM_API int errlogPrintfNoConsole (const char *pformat,...) EPICS_PRINTF_STYLE(1
 
LIBCOM_API void LIBCOM_API int
LIBCOM_API int 
errlogVprintfNoConsole (const char *pformat, va_list pvar)
 
LIBCOM_API void errSymLookup (long status, char *pBuf, size_t bufLength)
 

Variables

LIBCOM_API int errVerbose
 
LIBCOM_API const char * errlogSevEnumString []
 

Detailed Description

This file contains functions for passing error messages with varying severity, registering and un-registering listeners and modifying the log buffer size and max message size.

Some of these functions are similar to the standard C library functions printf and vprintf. For details on the arguments and return codes it is useful to consult any book that describes the standard C library such as The C Programming Language ANSI C Edition by Kernighan and Ritchie.

Definition in file errlog.h.

Macro Definition Documentation

#define errMessage (   S,
  PM 
)    errPrintf(S, __FILE__, __LINE__, "%s", PM)

errMessage is a macro so it can get the file and line number. It prints the message, the status symbol and string values, and the name of the task which invoked errMessage. It also prints the name of the source file and the line number from which the call was issued.

The status code used for the 1st argument is:

  • 0: Find latest vxWorks or Unix error (errno value).
  • -1: Don't report status.
  • Other: Use this status code and lookup the string value
Parameters
SStatus code
PMThe message to print

Definition at line 84 of file errlog.h.

#define epicsPrintf   errlogPrintf

epicsPrintf is an old name for errlog routines

Definition at line 88 of file errlog.h.

#define epicsVprintf   errlogVprintf

epicsVprintf is an old name for errlog routines

Definition at line 91 of file errlog.h.

Typedef Documentation

typedef void(* errlogListener)(void *pPrivate, const char *message)

errlogListener function type.

This is used when adding or removing log listeners in errlogAddListener and errlogRemoveListeners.

Definition at line 45 of file errlog.h.

Enumeration Type Documentation

errlog severity enums

Definition at line 48 of file errlog.h.

Function Documentation

LIBCOM_API int errlogPrintf ( const char *  pformat,
  ... 
)

errlogPrintf is like the printf function provided by the standard C library, except that the output is sent to the errlog task. Unless configured not to, the output will appear on the console as well.

LIBCOM_API int LIBCOM_API int errlogVprintf ( const char *  pformat,
va_list  pvar 
)

errlogVprintf is like the vprintf function provided by the standard C library, except that the output is sent to the errlog task. Unless configured not to, the output will appear on the console as well.

LIBCOM_API int errlogSevPrintf ( const errlogSevEnum  severity,
const char *  pformat,
  ... 
)

This function is like errlogPrintf except that it adds the severity to the beginning of the message in the form sevr=<value> where value is one of the enumerated severities in errlogSevEnum. Also the message is suppressed if severity is less than the current severity to suppress.

Parameters
severityOne of the severity enums from errlogSevEnum
pformatThe message to log or print
Returns
int Consult printf documentation in C standard library
LIBCOM_API int LIBCOM_API int errlogSevVprintf ( const errlogSevEnum  severity,
const char *  pformat,
va_list  pvar 
)

This function is like errlogVprintf except that it adds the severity to the beginning of the message in the form sevr=<value> where value is one of the enumerated severities in errlogSevEnum. Also the message is suppressed if severity is less than the current severity to suppress. If epicsThreadIsOkToBlock is true, which is true during iocInit, errlogSevVprintf does NOT send output to the errlog task.

Parameters
severityOne of the severity enums from errlogSevEnum
pformatThe message to log or print
pvarva_list
Returns
int Consult printf documentation in C standard library
LIBCOM_API int errlogMessage ( const char *  message)

Sends message to the errlog task.

Parameters
messageThe message to send
LIBCOM_API const char* errlogGetSevEnumString ( errlogSevEnum  severity)

Gets the string value of severity.

Parameters
severityThe severity from errlogSevEnum
Returns
The string value
LIBCOM_API void errlogSetSevToLog ( errlogSevEnum  severity)

Sets the severity to log

Parameters
severityThe severity from errlogSevEnum
LIBCOM_API errlogSevEnum errlogGetSevToLog ( void  )

Gets the current severity to log

Returns
errlogSevEnum
LIBCOM_API void errlogAddListener ( errlogListener  listener,
void *  pPrivate 
)

Any code can receive errlog message. This function will add a listener callback.

Parameters
listenerFunction pointer of type errlogListener
pPrivateThis will be passed as the first argument of listener()
LIBCOM_API int errlogRemoveListeners ( errlogListener  listener,
void *  pPrivate 
)

This function will remove a listener callback.

Parameters
listenerFunction pointer of type errlogListener
pPrivateThis will be passed as the first argument of listener()
LIBCOM_API int eltc ( int  yesno)

Normally the errlog system displays all messages on the console. During error message storms this function can be used to suppress console messages. A argument of 0 suppresses the messages, any other value lets messages go to the console.

Parameters
yesno(0=No, 1=Yes)
Returns
0
LIBCOM_API int errlogSetConsole ( FILE *  stream)

Sets a new stream to write the messages to

Parameters
streamPointer to file handle
Returns
0
LIBCOM_API int errlogInit ( int  bufsize)

Can be used to initialize the error logging system with a larger buffer. The default buffer size is 1280 bytes.

Parameters
bufsizeThe desired buffer size
LIBCOM_API int errlogInit2 ( int  bufsize,
int  maxMsgSize 
)

errlogInit2 can be used to initialize the error logging system with a larger buffer and maximum message size. The default buffer size is 1280 bytes, and the default maximum message size is 256.

Parameters
bufsizeThe desired buffer size
maxMsgSizeThe desired max message size
LIBCOM_API void errlogFlush ( void  )

Wakes up the errlog task and then waits until all messages are flushed from the queue.

LIBCOM_API void errPrintf ( long  status,
const char *  pFileName,
int  lineno,
const char *  pformat,
  ... 
)

Routine errPrintf is normally called as follows: errPrintf(status, __FILE__, __LINE__, "\<fmt\>", ...);

Where status is defined as:

  • 0: Find latest vxWorks or Unix error.
  • -1: Don't report status.
  • Other: Use this status code and lookup the string value
Parameters
statusSee above
pFileNameAs shown or NULL if the file name and line number should not be printed.
linenoAs shown
pformatThe message to log or print

The remaining arguments are just like the arguments to the C printf routine. errVerbose determines if the filename and line number are shown.

LIBCOM_API void errSymLookup ( long  status,
char *  pBuf,
size_t  bufLength 
)

Lookup the status code and return the string value in pBuf

Parameters
statusThe status code to lookup
pBufThe char buffer to write the string value into
bufLengthThe max size of pBuf

Variable Documentation

LIBCOM_API int errVerbose

Boolean to control whether some messages include more detail

LIBCOM_API const char* errlogSevEnumString[]

String representation of errlog severity values