From 459cdc0829a9d4e8289285867b70b079cd8dd6de Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Sat, 26 Jul 2003 00:13:34 +0000 Subject: [PATCH] removed logFdAdd from logClient --- src/db/iocInit.c | 2 + src/libCom/Makefile.Vx | 2 + src/libCom/logMsgToErrlog.c | 98 +++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 src/libCom/logMsgToErrlog.c diff --git a/src/db/iocInit.c b/src/db/iocInit.c index b3434e226..793ab2b01 100644 --- a/src/db/iocInit.c +++ b/src/db/iocInit.c @@ -57,6 +57,7 @@ #define MODULE_TYPES_INIT 1 #include +void errlogDevInit (); LOCAL int initialized=FALSE; @@ -99,6 +100,7 @@ int iocInit(char * pResourceFilename) return(-1); } + errlogDevInit (); /* Setup initialization hooks, if initHooks routine has been defined. */ strcpy(name, "_"); diff --git a/src/libCom/Makefile.Vx b/src/libCom/Makefile.Vx index 1b86c104a..0b1d3e2f7 100644 --- a/src/libCom/Makefile.Vx +++ b/src/libCom/Makefile.Vx @@ -44,6 +44,7 @@ SRCS.c += ../aToIPAddr.c SRCS.c += ../adjustment.c SRCS.c += ../os/vxWorks/bsdSockResource.c SRCS.c += ../os/vxWorks/osiSleep.c +SRCS.c += ../logMsgToErrlog.c LIBOBJS += cvtFast.o LIBOBJS += ellLib.o @@ -74,6 +75,7 @@ LIBOBJS += aToIPAddr.o LIBOBJS += adjustment.o LIBOBJS += bsdSockResource.o LIBOBJS += osiSleep.o +LIBOBJS += logMsgToErrlog.o LIBNAME = libCom diff --git a/src/libCom/logMsgToErrlog.c b/src/libCom/logMsgToErrlog.c new file mode 100644 index 000000000..302a866cd --- /dev/null +++ b/src/libCom/logMsgToErrlog.c @@ -0,0 +1,98 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Chicago, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* EPICS BASE Versions 3.13.7 +* and higher are distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* + * $Id$ + * + * route vxWorks logMsg messages into the EPICS logging system + * + * Author: Jeff Hill + * + */ + +#include +#include + +#include +#include +#include + +#include "errlog.h" + +static int errlogOpen ( DEV_HDR * pHdr, const char * pMode, int opt ) +{ + return OK; +} + +static int errlogWrite ( DEV_HDR * pHdr, const char * pInBuf, int nbytes ) +{ + errlogPrintf ( "%.*s", nbytes, pInBuf ); + return nbytes; +} + +void errlogDevInit () +{ + DEV_HDR * pDev; + int status; + int errlogNo; + int fd; + + errlogNo = iosDrvInstall ( + 0, /* create not supported */ + 0, /* remove not supported */ + ( FUNCPTR ) errlogOpen, + 0, /* close is a noop */ + 0, /* read not supported */ + ( FUNCPTR ) errlogWrite, + 0 /* ioctl not supported */ + ); + if ( errlogNo == ERROR ) { + errlogPrintf ( + "Unable to install driver routing the vxWorks " + "logging system to the EPICS logging system because \"%s\"\n", + strerror ( errno ) ); + return; + } + pDev = ( DEV_HDR * ) calloc ( 1, sizeof ( *pDev ) ); + if ( ! pDev ) { + errlogPrintf ( + "Unable to create driver data structure for routing the vxWorks " + "logging system to the EPICS logging system because \"%s\"\n", + strerror ( errno ) ); + return; + } + status = iosDevAdd ( pDev, "/errlog/", errlogNo ); + if ( status < 0 ) { + errlogPrintf ( + "Unable to install device routing the vxWorks " + "logging system to the EPICS logging system because \"%s\"\n", + strerror ( errno ) ); + free ( pDev ); + return; + } + fd = open ( "/errlog/any", O_WRONLY, 0 ); + if ( fd < 0 ) { + errlogPrintf ( + "Unable to open fd routing the vxWorks " + "logging system to the EPICS logging system because \"%s\"\n", + strerror ( errno ) ); + return; + } + status = logFdAdd ( fd ); + if ( status != OK) { + errlogPrintf ( + "Unable to install fd routing the vxWorks " + "logging system to the EPICS logging system because \"%s\"\n", + strerror ( errno ) ); + close ( fd ); + return; + } +} +