Date: Tue, 05 Oct 2004 From: Marty Kraimer Cc: tech-talk@aps.anl.gov Subject: Re: Long Error Message errlog allows a maximum message size of 256 characters. It allows an extra 256 characters in an internal buffer. Until extra is > 256 there is no buffer overflow. Thus the following error message (at iocInit time) does not actually cause a problem. >errlog: A message overran buffer by 3. This is VERY bad In 3.14 errlog has been modified so that a buffer overflow can not occur.
typedef enum { errlogInfo,errlogMinor,errlogMajor,errlogFatal }errlogSevEnum; int errlogPrintf(const char *pformat, ...); int errlogVprintf(const char *pformat,va_list pvar); int errlogSevPrintf(const errlogSevEnum severity, const char *pformat, ...); int errlogSevVprintf(const errlogSevEnum severity, const char *pformat,va_list pvar); int errlogMessage( const char *message); char * errlogGetSevEnumString(const errlogSevEnum severity); void errlogSetSevToLog(const errlogSevEnum severity ); errlogSevEnum errlogGetSevToLog(void);These are the basic client routines.
errlogPrintf and errlogVprintf act just like printf and vprintf.
errlogSevPrintf and errlogSevVprintf are similar except that they also add the severity to the beginning of the message in the form "sevr=<value>" where value is on of "info, minor, major, fatal". Also the message is suppressed if severity is less than the current severity to suppress.
errlogMessage just logs message.
errlogGetSevEnumString gets the string value of severity.
errlogSetSevToLog sets the severity to log. errlogGetSevToLog gets the
current severity to log.
Status Routines
void errMessage(long status, char *message);
void errPrintf(long status, const char *pFileName, int lineno, const char *pformat, ...);errMessage is just a macro that calls errPrintf. errPrintf is meant to be called as follows:
errPrintf(status,__FILE__, __LINE__,"<format>",...)The argument status is described in the Application Developer's guide. The arguments __FILE__ and __LINE__ are standard C preprocessor variables.
int epicsPrintf(const char *pformat, ...); int epicsVprintf(const char *pformat,va_list pvar);These are exactly like errlogPrintf and errlogVprintf. They are provided because a lot of existing code calls them,. Add and Remove Log Listener
typedef void(*errlogListener) (const char *message); void errlogAddListener(errlogListener listener); void errlogRemoveListener(errlogListener listener);These routines add/remove a callback that receives each error message.
void eltc(int yesno); /* error log to console (0 or 1) */ void errlogInit(int bufsize);eltc determines if errlog task writes message to the console. If error messages storms are occuring the command can be used to suppress the messages. A argument of 0 suppresses the messages and any other value lets the message go to the console.
errlogInit can be used to initialize the error logging system with a larger buffer. The default is 1280 bytes. An extra MAX_MESSAGE_SIZE (currently 256) bytes are allocated but never used. This is a small extra protection against long error messages.
RETURN TO SLAC CMLOG HOME PAGE
SLAC Last modified: 12-Aug-
2000 by Ron MacKenzie