add errlogStop; remove old sytle C function prototypes
This commit is contained in:
@@ -72,11 +72,13 @@ typedef struct msgNode {
|
||||
|
||||
LOCAL struct {
|
||||
epicsEventId errlogTaskWaitForWork;
|
||||
epicsEventId errlogStopWaitForStop;
|
||||
epicsMutexId msgQueueLock;
|
||||
epicsMutexId listenerLock;
|
||||
ELLLIST listenerList;
|
||||
ELLLIST msgQueue;
|
||||
msgNode *pnextSend;
|
||||
int stopNow;
|
||||
int errlogInitFailed;
|
||||
int buffersize;
|
||||
int sevToLog;
|
||||
@@ -310,6 +312,7 @@ static void errlogInitPvt(void *arg)
|
||||
ellInit(&pvtData.msgQueue);
|
||||
pvtData.toConsole = TRUE;
|
||||
pvtData.errlogTaskWaitForWork = epicsEventMustCreate(epicsEventEmpty);
|
||||
pvtData.errlogStopWaitForStop = epicsEventMustCreate(epicsEventEmpty);
|
||||
pvtData.listenerLock = epicsMutexMustCreate();
|
||||
pvtData.msgQueueLock = epicsMutexMustCreate();
|
||||
/*Allow an extra MAX_MESSAGE_SIZE for extra margain of safety*/
|
||||
@@ -333,6 +336,13 @@ epicsShareFunc int epicsShareAPI errlogInit(int bufsize)
|
||||
return(0);
|
||||
}
|
||||
|
||||
epicsShareFunc void epicsShareAPI errlogStop(void)
|
||||
{
|
||||
pvtData.stopNow = 1;
|
||||
epicsEventSignal(pvtData.errlogTaskWaitForWork);
|
||||
epicsEventMustWait(pvtData.errlogStopWaitForStop);
|
||||
}
|
||||
|
||||
LOCAL void errlogTask(void)
|
||||
{
|
||||
listenerNode *plistenerNode;
|
||||
@@ -352,6 +362,11 @@ LOCAL void errlogTask(void)
|
||||
epicsMutexUnlock(pvtData.listenerLock);
|
||||
msgbufFreeSend();
|
||||
}
|
||||
if(!pvtData.stopNow) continue;
|
||||
epicsThreadSleep(.2); /*just wait an extra .2 seconds*/
|
||||
/*SHOULD HAVE WAY OF NOTIFYING LISTENERS*/
|
||||
epicsEventSignal(pvtData.errlogStopWaitForStop);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,26 +13,14 @@ of this distribution.
|
||||
#ifndef INCerrlogh
|
||||
#define INCerrlogh
|
||||
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "shareLib.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#define epicsPrintUseProtoANSI
|
||||
#endif
|
||||
|
||||
#ifdef __STDC__
|
||||
#ifndef epicsPrintUseProtoANSI
|
||||
#define epicsPrintUseProtoANSI
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef epicsPrintUseProtoANSI
|
||||
# include <stdarg.h>
|
||||
#else
|
||||
# include <varargs.h>
|
||||
#endif
|
||||
|
||||
/* define errMessage with a macro so we can print the file and line number*/
|
||||
#define errMessage(S, PM) \
|
||||
@@ -41,11 +29,8 @@ extern "C" {
|
||||
#define epicsPrintf errlogPrintf
|
||||
#define epicsVprintf errlogVprintf
|
||||
|
||||
#ifdef __STDC__
|
||||
typedef void(*errlogListener) (void *pPrivate, const char *message);
|
||||
#else
|
||||
typedef void(*errlogListener) ();
|
||||
#endif
|
||||
|
||||
typedef enum {errlogInfo,errlogMinor,errlogMajor,errlogFatal} errlogSevEnum;
|
||||
|
||||
#ifdef ERRLOG_INIT
|
||||
@@ -54,8 +39,6 @@ epicsShareDef char * errlogSevEnumString[] = {"info","minor","major","fatal"};
|
||||
epicsShareExtern char * errlogSevEnumString[];
|
||||
#endif
|
||||
|
||||
#ifdef epicsPrintUseProtoANSI
|
||||
|
||||
epicsShareFunc int epicsShareAPIV errlogPrintf(
|
||||
const char *pformat, ...);
|
||||
epicsShareFunc int epicsShareAPIV errlogVprintf(
|
||||
@@ -80,27 +63,12 @@ epicsShareFunc void epicsShareAPI errlogRemoveListener(
|
||||
|
||||
epicsShareFunc int epicsShareAPI eltc(int yesno);
|
||||
epicsShareFunc int epicsShareAPI errlogInit(int bufsize);
|
||||
epicsShareFunc void epicsShareAPI errlogStop(void);
|
||||
|
||||
/*other routines that write to log file*/
|
||||
epicsShareFunc void epicsShareAPIV errPrintf(long status, const char *pFileName,
|
||||
int lineno, const char *pformat, ...);
|
||||
|
||||
#else /* not epicsPrintUseProtoANSI */
|
||||
epicsShareFunc int epicsShareAPI errlogPrintf();
|
||||
epicsShareFunc int epicsShareAPI errlogVprintf();
|
||||
epicsShareFunc int epicsShareAPI errlogSevPrintf();
|
||||
epicsShareFunc int epicsShareAPI errlogSevVprintf();
|
||||
epicsShareFunc int epicsShareAPI errlogMessage();
|
||||
epicsShareFunc char * epicsShareAPI errlogGetSevEnumString();
|
||||
epicsShareFunc void epicsShareAPI errlogSetSevToLog();
|
||||
epicsShareFunc errlogSevEnum epicsShareAPI errlogGetSevToLog();
|
||||
epicsShareFunc void epicsShareAPI errlogAddListener();
|
||||
epicsShareFunc void epicsShareAPI errlogRemoveListener();
|
||||
epicsShareFunc void epicsShareAPI eltc();
|
||||
epicsShareFunc void epicsShareAPI errlogInit();
|
||||
epicsShareFunc void epicsShareAPI errPrintf();
|
||||
#endif /* ifdef epicsPrintUseProtoANSI */
|
||||
|
||||
epicsShareExtern int errVerbose;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user