rllib  1
Macros | Enumerations | Functions | Variables
rlevent.h File Reference
#include "rldefine.h"
Include dependency graph for rlevent.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define rlMAX_EVENT   256
 
#define rlEvent   rlSetEventLocation(__FILE__,__LINE__);rlEventPrintf
 

Enumerations

enum  EventTypes {
  rlInfo = 0, rlWarning, rlError, rlCritical,
  rlFatal, rlTest, rlEVENT_SIZE
}
 

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 const char rlevent_name [][4] = { "INF", "WAR", "ERR", "CRI", "FAT", "TST" }
 

Macro Definition Documentation

◆ rlEvent

#define rlEvent   rlSetEventLocation(__FILE__,__LINE__);rlEventPrintf

Definition at line 43 of file rlevent.h.

◆ rlMAX_EVENT

#define rlMAX_EVENT   256
These functions allow you to send event log messages over TCP/IP to the event log server
implemented by the pvserver pcontrol (available as separate download)
See also the class rlEventLogServer.

Definition at line 26 of file rlevent.h.

Enumeration Type Documentation

◆ EventTypes

enum EventTypes
Enumerator
rlInfo 
rlWarning 
rlError 
rlCritical 
rlFatal 
rlTest 
rlEVENT_SIZE 

Definition at line 29 of file rlevent.h.

30 {
31  rlInfo = 0,
32  rlWarning,
33  rlError,
34  rlCritical,
35  rlFatal,
36  rlTest,
38 };
Definition: rlevent.h:36
Definition: rlevent.h:31

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

◆ rlevent_name

const char rlevent_name[][4] = { "INF", "WAR", "ERR", "CRI", "FAT", "TST" }
static

Definition at line 28 of file rlevent.h.