rllib  1
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

◆ rlEventInit()

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

Definition at line 36 of file rlevent.cpp.

37 {
38  const char *cptr;
39 
40  rlwsa();
41  for(int i=0; i<ac; i++)
42  {
43  cptr = av[i];
44  if(strncmp("-eventhost=",cptr,11) == 0) toEventLogServer.setAdr(&cptr[11]);
45  if(strncmp("-eventport=",cptr,11) == 0) toEventLogServer.setPort(atoi(&cptr[11]));
46  }
47  rlstrncpy(rlmodule,module,sizeof(rlmodule)-1);
48 }
void setPort(int port)
Definition: rlsocket.cpp:176
static char rlmodule[32]
Definition: rlevent.cpp:27
char * rlstrncpy(char *dest, const char *source, int n)
Definition: rlcutil.cpp:169
void setAdr(const char *adr)
Definition: rlsocket.cpp:168
int rlwsa()
Definition: rlsocket.cpp:68
static rlSocket toEventLogServer("localhost",-1, 1)

◆ rlEventPrintf()

void rlEventPrintf ( int  event_type,
const char *  format,
  ... 
)
output the message

Definition at line 82 of file rlevent.cpp.

83 {
84  if(toEventLogServer.getPort() <= 0) return;
85  va_list ap;
86  va_start(ap,format);
87  rlvsnprintf(rlmessage,sizeof(rlmessage)-1,format,ap);
88  va_end(ap);
89 
90  if(event_type < 0 ) event_type = rlError;
91  if(event_type >= rlEVENT_SIZE) event_type = rlError;
93 #ifdef RLUNIX
94  snprintf(rlfinal,sizeof(rlfinal)-1,"%s %s %s %s%s\n",
95  rlevent_name[event_type],
97  rlmessage,
98  rlmodule,
100  );
101 #endif
102 #ifdef __VMS
103  sprintf(rlfinal,"%s %s %s %s%s\n",
104  rlevent_name[event_type],
106  rlmessage,
107  rlmodule,
108  rllocation
109  );
110  rlfinal[rlMAX_EVENT-1] = '\0';
111 #endif
112 #ifdef RLWIN32
113  _snprintf(rlfinal,sizeof(rlfinal)-1,"%s %s %s %s%s\n",
114  rlevent_name[event_type],
116  rlmessage,
117  rlmodule,
118  rllocation
119  );
120 #endif
122  {
124  }
125  else
126  {
129  {
131  } // else give up
132  }
133 }
const char * getTimeString()
Definition: rltime.cpp:106
void getLocalTime()
Definition: rltime.cpp:342
static char rlmessage[rlMAX_EVENT]
Definition: rlevent.cpp:29
#define rlMAX_EVENT
Definition: rlevent.h:26
static const char rlevent_name[][4]
Definition: rlevent.h:28
static char rlfinal[rlMAX_EVENT *4]
Definition: rlevent.cpp:31
static rlTime mytime
Definition: rlevent.cpp:26
int rlvsnprintf(char *text, int len, const char *format, va_list ap)
Definition: rlcutil.cpp:197
static char rlmodule[32]
Definition: rlevent.cpp:27
int getPort()
Definition: rlsocket.cpp:181
int connect()
Definition: rlsocket.cpp:321
int isConnected()
Definition: rlsocket.cpp:559
static char rllocation[rlMAX_EVENT]
Definition: rlevent.cpp:28
static rlSocket toEventLogServer("localhost",-1, 1)
int printf(const char *format,...)
Definition: rlsocket.cpp:586

◆ rlSetEventLocation()

void rlSetEventLocation ( const char *  file,
int  line 
)
set the location where rlEvent is called

Definition at line 50 of file rlevent.cpp.

51 {
52 #ifdef RLWIN32
53  const char *cptr;
54 
55  if(strchr(file,'\\') == NULL) cptr = NULL;
56  else cptr = strrchr(file,'\\');
57  if(cptr != NULL) cptr++;
58  else cptr = file;
59 #endif
60 #ifdef __VMS
61  const char *cptr;
62 
63  if(strchr(file,']') == NULL) cptr = NULL;
64  else cptr = strrchr(file,']');
65  if(cptr != NULL) cptr++;
66  else cptr = file;
67 #endif
68 
69 #ifdef RLUNIX
70  snprintf(rllocation,sizeof(rllocation)-1,":%s:%d",file,line);
71 #endif
72 
73 #ifdef __VMS
74  sprintf(rllocation,":%s:%d",file,line);
75 #endif
76 
77 #ifdef RLWIN32
78  _snprintf(rllocation,sizeof(rllocation)-1,":%s:%d",file,line);
79 #endif
80 }
static char rllocation[rlMAX_EVENT]
Definition: rlevent.cpp:28

Variable Documentation

◆ mytime

rlTime mytime
static

Definition at line 26 of file rlevent.cpp.

◆ rlfinal

char rlfinal[rlMAX_EVENT *4]
static

Definition at line 31 of file rlevent.cpp.

◆ rllocation

char rllocation[rlMAX_EVENT]
static

Definition at line 28 of file rlevent.cpp.

◆ rlmessage

char rlmessage[rlMAX_EVENT]
static

Definition at line 29 of file rlevent.cpp.

◆ rlmodule

char rlmodule[32]
static

Definition at line 27 of file rlevent.cpp.

◆ toEventLogServer

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