This commit was manufactured by cvs2svn to create branch 'B3.14'.
This commit is contained in:
155
src/libCom/logClient/iocLog.c
Normal file
155
src/libCom/logClient/iocLog.c
Normal file
@@ -0,0 +1,155 @@
|
||||
/*************************************************************************\
|
||||
* 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.
|
||||
\*************************************************************************/
|
||||
/* logClient.c,v 1.25.2.6 2004/10/07 13:37:34 mrk Exp */
|
||||
/*
|
||||
* Author: Jeffrey O. Hill
|
||||
* Date: 080791
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
|
||||
#define epicsExportSharedSymbols
|
||||
#include "envDefs.h"
|
||||
#include "errlog.h"
|
||||
#include "logClient.h"
|
||||
#include "iocLog.h"
|
||||
|
||||
#ifndef LOCAL
|
||||
#define LOCAL static
|
||||
#endif
|
||||
|
||||
int iocLogDisable = 0;
|
||||
|
||||
static const int iocLogSuccess = 0;
|
||||
static const int iocLogError = -1;
|
||||
|
||||
LOCAL logClientId iocLogClient;
|
||||
|
||||
/*
|
||||
* getConfig()
|
||||
* Get Server Configuration
|
||||
*/
|
||||
LOCAL int getConfig (struct in_addr *pserver_addr, unsigned short *pserver_port)
|
||||
{
|
||||
long status;
|
||||
long epics_port;
|
||||
|
||||
status = envGetLongConfigParam (&EPICS_IOC_LOG_PORT, &epics_port);
|
||||
if (status<0) {
|
||||
fprintf (stderr,
|
||||
"iocLog: EPICS environment variable \"%s\" undefined\n",
|
||||
EPICS_IOC_LOG_PORT.name);
|
||||
return iocLogError;
|
||||
}
|
||||
|
||||
if (epics_port<0 || epics_port>USHRT_MAX) {
|
||||
fprintf (stderr,
|
||||
"iocLog: EPICS environment variable \"%s\" out of range\n",
|
||||
EPICS_IOC_LOG_PORT.name);
|
||||
return iocLogError;
|
||||
}
|
||||
*pserver_port = (unsigned short) epics_port;
|
||||
|
||||
status = envGetInetAddrConfigParam (&EPICS_IOC_LOG_INET, pserver_addr);
|
||||
if (status<0) {
|
||||
fprintf (stderr,
|
||||
"iocLog: EPICS environment variable \"%s\" undefined\n",
|
||||
EPICS_IOC_LOG_INET.name);
|
||||
return iocLogError;
|
||||
}
|
||||
|
||||
return iocLogSuccess;
|
||||
}
|
||||
|
||||
/*
|
||||
* iocLogFlush ()
|
||||
*/
|
||||
void epicsShareAPI epicsShareAPI iocLogFlush ()
|
||||
{
|
||||
if (iocLogClient!=NULL) {
|
||||
logClientFlush (iocLogClient);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* iocLogClientInit()
|
||||
*/
|
||||
LOCAL logClientId iocLogClientInit (void)
|
||||
{
|
||||
int status;
|
||||
logClientId id;
|
||||
struct in_addr addr;
|
||||
unsigned short port;
|
||||
|
||||
status = getConfig (&addr, &port);
|
||||
if (status) {
|
||||
return NULL;
|
||||
}
|
||||
id = logClientCreate (addr, port);
|
||||
if (id != NULL) {
|
||||
errlogAddListener ( logClientSendMessage, id );
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
/*
|
||||
* iocLogInit()
|
||||
*/
|
||||
int epicsShareAPI iocLogInit (void)
|
||||
{
|
||||
/*
|
||||
* check for global disable
|
||||
*/
|
||||
if (iocLogDisable) {
|
||||
return iocLogSuccess;
|
||||
}
|
||||
/*
|
||||
* dont init twice
|
||||
*/
|
||||
if (iocLogClient!=NULL) {
|
||||
return iocLogSuccess;
|
||||
}
|
||||
iocLogClient = iocLogClientInit ();
|
||||
if (iocLogClient) {
|
||||
return iocLogSuccess;
|
||||
}
|
||||
else {
|
||||
return iocLogError;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* iocLogShow ()
|
||||
*/
|
||||
void epicsShareAPI iocLogShow (unsigned level)
|
||||
{
|
||||
if (iocLogClient!=NULL) {
|
||||
logClientShow (iocLogClient, level);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* logClientInit(); deprecated
|
||||
*/
|
||||
logClientId epicsShareAPI logClientInit ()
|
||||
{
|
||||
return iocLogClientInit ();
|
||||
}
|
||||
|
||||
/*
|
||||
* logClientSendMessage (); deprecated
|
||||
*/
|
||||
void logClientSendMessage ( logClientId id, const char * message )
|
||||
{
|
||||
if ( !iocLogDisable ) {
|
||||
logClientSend (id, message);
|
||||
}
|
||||
}
|
||||
38
src/libCom/logClient/iocLog.h
Normal file
38
src/libCom/logClient/iocLog.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*************************************************************************\
|
||||
* 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.
|
||||
\*************************************************************************/
|
||||
|
||||
/* logClient.h,v 1.5.2.1 2003/07/08 00:08:06 jhill Exp */
|
||||
/*
|
||||
*
|
||||
* Author: Jeffrey O. Hill
|
||||
* Date: 080791
|
||||
*/
|
||||
|
||||
#ifndef INCiocLogh
|
||||
#define INCiocLogh 1
|
||||
#include "shareLib.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ioc log client interface
|
||||
*/
|
||||
epicsShareExtern int iocLogDisable;
|
||||
epicsShareFunc int epicsShareAPI iocLogInit (void);
|
||||
epicsShareFunc void epicsShareAPI iocLogShow (unsigned level);
|
||||
epicsShareFunc void epicsShareAPI iocLogFlush ();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*INCiocLogh*/
|
||||
Reference in New Issue
Block a user