rllib  1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Functions | Variables
rlevent.cpp File Reference
#include "rlevent.h"
#include "rlsocket.h"
#include "rltime.h"
#include "rlcutil.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
Include dependency graph for rlevent.cpp:

Go to the source code of this file.

Functions

void rlEventInit (int ac, char **av, const char *module)
 
void rlSetEventLocation (const char *file, int line)
 
void rlEventPrintf (int event_type, const char *format,...)
 

Variables

static rlSocket toEventLogServer ("localhost",-1, 1)
 
static rlTime mytime
 
static char rlmodule [32]
 
static char rllocation [rlMAX_EVENT]
 
static char rlmessage [rlMAX_EVENT]
 
static char rlfinal [rlMAX_EVENT *4]
 

Function Documentation

void rlEventInit ( int  ac,
char **  av,
const char *  module 
)
initialize rlEvent
parameters:
-eventhost=adr
-eventport=num

Definition at line 36 of file rlevent.cpp.

{
const char *cptr;
rlwsa();
for(int i=0; i<ac; i++)
{
cptr = av[i];
if(strncmp("-eventhost=",cptr,11) == 0) toEventLogServer.setAdr(&cptr[11]);
if(strncmp("-eventport=",cptr,11) == 0) toEventLogServer.setPort(atoi(&cptr[11]));
}
rlstrncpy(rlmodule,module,sizeof(rlmodule)-1);
}
void rlEventPrintf ( int  event_type,
const char *  format,
  ... 
)
output the message

Definition at line 82 of file rlevent.cpp.

{
if(toEventLogServer.getPort() <= 0) return;
va_list ap;
va_start(ap,format);
rlvsnprintf(rlmessage,sizeof(rlmessage)-1,format,ap);
va_end(ap);
if(event_type < 0 ) event_type = rlError;
if(event_type >= rlEVENT_SIZE) event_type = rlError;
#ifdef RLUNIX
snprintf(rlfinal,sizeof(rlfinal)-1,"%s %s %s %s%s\n",
rlevent_name[event_type],
);
#endif
#ifdef __VMS
sprintf(rlfinal,"%s %s %s %s%s\n",
rlevent_name[event_type],
);
rlfinal[rlMAX_EVENT-1] = '\0';
#endif
#ifdef RLWIN32
_snprintf(rlfinal,sizeof(rlfinal)-1,"%s %s %s %s%s\n",
rlevent_name[event_type],
);
#endif
{
toEventLogServer.printf("%s",rlfinal);
}
else
{
{
toEventLogServer.printf("%s",rlfinal);
} // else give up
}
}
void rlSetEventLocation ( const char *  file,
int  line 
)
set the location where rlEvent is called

Definition at line 50 of file rlevent.cpp.

{
#ifdef RLWIN32
const char *cptr;
if(strchr(file,'\\') == NULL) cptr = NULL
else cptr = strrchr(file,'\\');
if(cptr != NULL) cptr++;
else cptr = file;
#endif
#ifdef __VMS
const char *cptr;
if(strchr(file,']') == NULL) cptr = NULL
else cptr = strrchr(file,']');
if(cptr != NULL) cptr++;
else cptr = file;
#endif
#ifdef RLUNIX
snprintf(rllocation,sizeof(rllocation)-1,":%s:%d",file,line);
#endif
#ifdef __VMS
sprintf(rllocation,":%s:%d",file,line);
#endif
#ifdef RLWIN32
_snprintf(rllocation,sizeof(rllocation)-1,":%s:%d",file,line);
#endif
}

Variable Documentation

rlTime mytime
static

Definition at line 26 of file rlevent.cpp.

char rlfinal[rlMAX_EVENT *4]
static

Definition at line 31 of file rlevent.cpp.

char rllocation[rlMAX_EVENT]
static

Definition at line 28 of file rlevent.cpp.

char rlmessage[rlMAX_EVENT]
static

Definition at line 29 of file rlevent.cpp.

char rlmodule[32]
static

Definition at line 27 of file rlevent.cpp.

rlSocket toEventLogServer("localhost",-1, 1)
static