00001 #ifndef _RTS_LOG_H_
00002 #define _RTS_LOG_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifdef __cplusplus
00018 extern "C" {
00019 #endif
00020
00021
00022
00023 #define ANSI_GREEN "\033[32m"
00024 #define ANSI_RED "\033[31m"
00025 #define ANSI_BLUE "\033[34m"
00026 #define ANSI_YELLOW "\033[33m"
00027 #define ANSI_MAGENTA "\033[35m"
00028 #define ANSI_CYAN "\033[36m"
00029 #define ANSI_BOLD "\033[1m"
00030 #define ANSI_ITALIC "\033[3m"
00031 #define ANSI_UNDERLINE "\033[4m"
00032 #define ANSI_REVERSE "\033[7m"
00033 #define ANSI_RESET "\033[0m"
00034
00035
00036
00037
00038
00039 #define RTS_LOG_PORT_RTS 8000
00040 #define RTS_LOG_PORT_TEST 8001
00041 #define RTS_LOG_PORT_DAQ 8002
00042 #define RTS_LOG_PORT_TRG 8003
00043 #define RTS_LOG_PORT_EVP 8004
00044 #define RTS_LOG_PORT_READER 8005
00045 #define RTS_LOG_PORT_TPX 8006
00046 #define RTS_LOG_PORT_DB 8007
00047 #define RTS_LOG_PORT_ESB 8008
00048 #define RTS_LOG_PORT_L3 8009
00049 #define RTS_LOG_PORT_DET 8010
00050
00051 #define RTS_LOG_PORT RTS_LOG_PORT_TEST
00052
00053
00054 #ifdef RTS_DAQMAN
00055 #define RTS_LOG_HOST RTS_DAQMAN
00056 #else
00057 #define RTS_LOG_HOST "130.199.60.86"
00058 #endif
00059
00060
00061 #define RTS_LOG_NET 1
00062 #define RTS_LOG_STDERR 2
00063 #define RTS_LOG_FILE 4
00064
00065
00066 #define CRIT "CRITICAL"
00067 #define OPER "OPERATOR"
00068 #define ERR "ERROR"
00069 #define WARN "WARNING"
00070 #define NOTE "NOTICE"
00071 #define DBG "DEBUG"
00072
00073 #define INFO "INFO"
00074
00075 #define CAUTION "CAUTION"
00076
00077 #define TERR "Tonko"
00078
00079 #define SAVEme "SAVEme"
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 #ifdef RTS_DISABLE_LOG
00091
00092 #define RTS_ASSERT(expr) assert(expr)
00093
00094
00095 #define LOG(SEV,STRING,ARGS...) \
00096 do { \
00097 const char *const yada = SEV ; \
00098 if((*yada == 'E')) { \
00099 fprintf(stderr,""ANSI_RED"RTS_"SEV": "__FILE__" [line %d]: "STRING""ANSI_RESET"\n" , __LINE__ , ##ARGS) ;\
00100 } \
00101 else if((*yada == 'C')) { \
00102 fprintf(stderr,""ANSI_RED""ANSI_BOLD"RTS_"SEV": "__FILE__" [line %d]: "STRING""ANSI_RESET"\n" , __LINE__ , ##ARGS) ;\
00103 } \
00104 } while(0) \
00105
00106
00107
00108
00109
00110 #define rtsLogLevel(x)
00111 #define rtsLogAddDest(x,y)
00112 #define rtsLogLevelInt(x)
00113 #define rtsLogOutput(x)
00114
00115 #else
00116
00117
00118 #ifdef __GNUC__
00119 #define INLINE_HACK extern __inline__
00120 #else
00121 #define INLINE_HACK inline
00122 #endif
00123
00124
00125
00126
00127 extern volatile int tonkoLogLevel ;
00128
00129 extern int rtsLogAddDest(char *server, int port) ;
00130
00131
00132 INLINE_HACK void rtsLogLevelInt(int level)
00133 {
00134 tonkoLogLevel = level;
00135 return;
00136 }
00137
00138
00139 INLINE_HACK void rtsLogLevel(char *level)
00140 {
00141 switch((int) *level) {
00142 case 'D' :
00143 tonkoLogLevel = 0 ;
00144 break ;
00145 case 'N' :
00146 tonkoLogLevel = 1 ;
00147 break ;
00148 case 'W' :
00149 tonkoLogLevel = 2 ;
00150 break ;
00151 case 'E' :
00152 tonkoLogLevel = 3 ;
00153 break ;
00154 case 'O' :
00155 tonkoLogLevel = 4 ;
00156 break ;
00157 case 'C' :
00158 default :
00159 tonkoLogLevel = 5 ;
00160 break ;
00161 }
00162
00163 return ;
00164 }
00165
00166
00167
00168
00169
00170 #ifdef __vxworks
00171
00172 #include <vxWorks.h>
00173 #include <logLib.h>
00174
00175 #define RTS_ASSERT(expr)
00176
00177
00178 #ifdef _ARCH_PPC
00179 extern int sbLoggerStart(void) ;
00180 extern int sbLOG(char *str, unsigned int a1, unsigned int a2,
00181 unsigned int a3, unsigned int a4, unsigned int a5, unsigned int a6) ;
00182 extern int sbLoggerRemoveDesc(int desc) ;
00183 extern int sbLoggerAddDesc(int desc) ;
00184 #else
00185 #define sbLOG(args...)
00186 #endif
00187
00188
00189 #define LOG(SEV,STRING,A1,A2,A3,A4,A5) \
00190 do { \
00191 const char *const yada = SEV ; \
00192 if((tonkoLogLevel>0) && (*yada == 'D')) ; \
00193 else if((tonkoLogLevel>1) && (*yada == 'N')) ; \
00194 else if((tonkoLogLevel>2) && (*yada == 'W')) ; \
00195 else if((tonkoLogLevel>3) && (*yada == 'E')) ; \
00196 else if((tonkoLogLevel>4) && (*yada == 'O')) ; \
00197 else { \
00198 logMsg(""SEV": "__FILE__" [line %d]: "STRING"\n",__LINE__,(unsigned int)A1,(unsigned int)A2,(unsigned int)A3,(unsigned int)A4,(unsigned int)A5) ;\
00199 sbLOG(""SEV": "__FILE__" [line %d]: "STRING"\n",__LINE__,(unsigned int)A1,(unsigned int)A2,(unsigned int)A3,(unsigned int)A4,(unsigned int)A5) ;\
00200 } \
00201 } while(0) \
00202
00203
00204 #define rtsLogOutput(x)
00205
00206 #else
00207
00208 #define RTS_ASSERT(expr) LOG(CRIT,"assert(%s) true -- certain death follows",__STRING(expr))
00209
00210 extern int rtsLogUnix_v(const char *str, ...) ;
00211
00212 extern int rtsLogOutput(int flag) ;
00213
00214 extern void rtsLogAddCmd(const char *cmd) ;
00215
00216 extern int rtsLogAddFile(char *fname) ;
00217
00218 #ifdef RTS_LOG_COLORED
00219
00220 #define LOG(SEV,STRING,ARGS...) \
00221 do { \
00222 const char *const yada = SEV ; \
00223 if((tonkoLogLevel>0) && (*yada == 'D')) ; \
00224 else if((tonkoLogLevel>1) && (*yada == 'N')) ; \
00225 else if((tonkoLogLevel>2) && (*yada == 'W')) ; \
00226 else if((tonkoLogLevel>3) && (*yada == 'E')) ; \
00227 else if((tonkoLogLevel>4) && (*yada == 'O')) ; \
00228 else { \
00229 rtsLogUnix_v("COLOR"SEV": "__FILE__" [line %d]: "STRING"\n" , __LINE__ , ##ARGS) ;\
00230 } \
00231 } while(0) \
00232
00233 #else
00234 #define LOG(SEV,STRING,ARGS...) \
00235 do { \
00236 const char *const yada = SEV ; \
00237 if((tonkoLogLevel>0) && (*yada == 'D')) ; \
00238 else if((tonkoLogLevel>1) && (*yada == 'N')) ; \
00239 else if((tonkoLogLevel>2) && (*yada == 'W')) ; \
00240 else if((tonkoLogLevel>3) && (*yada == 'E')) ; \
00241 else if((tonkoLogLevel>4) && (*yada == 'O')) ; \
00242 else { \
00243 rtsLogUnix_v(""SEV": "__FILE__" [line %d]: "STRING"\n" , __LINE__ , ##ARGS) ;\
00244 } \
00245 } while(0) \
00246
00247
00248
00249 #endif
00250
00251 #endif
00252
00253
00254 #endif
00255
00256 #ifdef __cplusplus
00257 }
00258 #endif
00259
00260 #endif