Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable logging outside of local domain (#644) #651

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 9 additions & 36 deletions StRoot/RTS/include/rtsLog.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,41 +93,14 @@ void rtsLogAddJmlFile (char *fname);



/*Tonko: not used Special (mis)handling for STAR Offline Code
#ifdef __ROOT__
#define RTS_DISABLE_LOG
#endif
*/

#ifdef RTS_DISABLE_LOG

#define RTS_ASSERT(expr) assert(expr)


#define LOG(SEV,STRING,ARGS...) \
do { \
const char *const yada = SEV ; \
if((*yada == 'E')) { \
fprintf(stderr,"" ANSI_RED "RTS_" SEV ": " __FILE__ " [line %d]: " STRING "" ANSI_RESET "\n" , __LINE__ , ##ARGS) ;\
} \
else if((*yada == 'C')) { \
fprintf(stderr,"" ANSI_RED "" ANSI_REVERSE "RTS_" SEV ": " __FILE__ " [line %d]: " STRING "" ANSI_RESET "\n" , __LINE__ , ##ARGS) ;\
} \
else if((*yada == 'I')) { \
fprintf(stderr,"" ANSI_BLUE "" ANSI_BOLD "RTS_" SEV ": " __FILE__ " [line %d]: " STRING "" ANSI_RESET "\n" , __LINE__ , ##ARGS) ;\
} \
else if((*yada == 'T')) { \
fprintf(stderr,"" ANSI_GREEN "" ANSI_BOLD "RTS_" SEV ": " __FILE__ " [line %d]: " STRING "" ANSI_RESET "\n" , __LINE__ , ##ARGS) ;\
} \
else if((*yada == 'W')) { \
fprintf(stderr,"" ANSI_CYAN "" ANSI_BOLD "RTS_" SEV ": " __FILE__ " [line %d]: " STRING "" ANSI_RESET "\n" , __LINE__ , ##ARGS) ;\
} \
else if((*yada == 'O')) { \
fprintf(stderr,"" ANSI_BLUE "" ANSI_REVERSE "RTS_" SEV ": " __FILE__ " [line %d]: " STRING "" ANSI_RESET "\n" , __LINE__ , ##ARGS) ;\
} \
} while(0) \

#ifndef RTS_ENABLE_LOG

#define RTS_ASSERT(expr) assert(expr)
#define LOG(SEV,STRING,ARGS...)
#define rtsLogUnix_v(str, ...)
#define rtsLogAddCmd(x)


// the following become noops...
Expand All @@ -136,7 +109,7 @@ void rtsLogAddJmlFile (char *fname);
#define rtsLogLevelInt(x)
#define rtsLogOutput(x)

#else /* RTS_DISABLE_LOG */
#else /* RTS_ENABLE_LOG */


#ifdef __GNUC__
Expand Down Expand Up @@ -270,12 +243,12 @@ INLINE_HACK void rtsLogLevel(const char *level)



#endif
#endif /* RTS_LOG_COLORED */

#endif
#endif /* __vxworks */


#endif /* RTS_DISABLE_LOG */
#endif /* RTS_ENABLE_LOG */

#ifdef __cplusplus
}
Expand Down
3 changes: 2 additions & 1 deletion StRoot/RTS/src/LOG/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
include ../rtsmakefile.def
include ../rtsplus.def


# zap LDLIBS
LDLIBS =

Expand All @@ -28,7 +29,7 @@ rtsLog.o : rtsLog.C

rtsLog: rtsLog.o rtsLogUnix.o
$(CXX) $(CXXFLAGS) rtsLogUnix.o rtsLog.o -o rtsLog

#operDisplay.sh:


Expand Down
2 changes: 1 addition & 1 deletion StRoot/RTS/src/LOG/rtsLog.C
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int main(int argc, char *argv[])
use_stdin = 0 ;

rtsLogLevel(DBG) ;
rtsLogOutput(RTS_LOG_NET) ;
//rtsLogOutput(RTS_LOG_NET) ;

memset(logstr,0,sizeof(logstr)) ;

Expand Down
38 changes: 32 additions & 6 deletions StRoot/RTS/src/LOG/rtsLogUnix.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,31 @@ extern "C" {
volatile int tonkoLogLevel = 2 ;


static char *getCmd(void) ;




#ifdef RTS_ENABLE_LOG
#warning "DAQ logging is enabled"
#ifdef RTS_LOG_DEFAULT_NET
#warning "DAQ logging defaults to daqman"
#else
#warning "DAQ logging defaults to STDERR"
#endif /* RTS_LOG_DEFAULT_NET */
#else
#warning "DAQ logging is disabled"
#endif /* RTS_ENABLE_LOG */


#ifdef RTS_ENABLE_LOG

#ifdef RTS_LOG_DEFAULT_NET
static int output_flag = RTS_LOG_NET ;
#else
static int output_flag = RTS_LOG_STDERR ;
#endif

static const char *getCmd(void) ;
static int odesc = -1 ;
static int handchange ;
static FILE *fdesc = 0 ;
Expand All @@ -42,7 +66,7 @@ static char servER[80] = RTS_LOG_HOST ;
#endif

static int port = RTS_LOG_PORT ;
static int output_flag = RTS_LOG_NET ;

static char cmd[1024] ;

/*
Expand Down Expand Up @@ -113,7 +137,6 @@ void rtsLogAddJmlFile (char *fname)
jml_fname = _g_fname;
}


int rtsLogUnix_v(const char *str, ...)
{
/* common to all threads */
Expand Down Expand Up @@ -328,9 +351,7 @@ int rtsLogUnix_v(const char *str, ...)
return 0 ;
}



static char *getCmd(void)
static const char *getCmd(void)
{


Expand Down Expand Up @@ -370,6 +391,11 @@ static char *getCmd(void)
#endif
}


#endif



#ifdef __cplusplus
}
#endif
Expand Down
43 changes: 41 additions & 2 deletions StRoot/RTS/src/rtsmakefile.def
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ ifeq ($(HOST_NAME),daqman.starp.bnl.gov)
endif


HOSTDOMAIN = $(shell hostname -d)

# jml... TARGET_CPU_STRING to mean the full string...

# go from "uname" to gcc -mcpu=TARGET_CPU variant
Expand Down Expand Up @@ -372,8 +374,41 @@ endif
DEFINES = -D_REENTRANT ${RTS_DAQMAN_FLAGS} -DRTS_HOST_NAME=\"${HOST_NAME}\" -DTARGET_SYSTEM=\"${TARGET_SYSTEM}\" -DPROJDIR=\"${PROJDIR}\" -DINSTALL_SUFFIX=\"${INSTALL_SUFFIX}\" -D${RTS_TYPE} ${HOW} ${HOSTDEFINES} -DRTS_ONLINE


BASEFLAGS = -O3 -Wall -pipe -fverbose-asm ${HOSTFLAGS}
#BASEFLAGS= -Wall -pipe -fverbose-asm ${HOSTFLAGS}
# Set strict errors in LINUX
BASEFLAGS = -O3 -Wall -Wno-error=strict-overflow -Wno-error=maybe-uninitialized -Wno-error=unused-label -Wno-error=unused-value -Wno-error=unused-variable -Wno-error=unused-function -Wno-unused-but-set-variable -pipe -fverbose-asm ${HOSTFLAGS}


#-O3
ifneq (${TARGET_SYSTEM}, LINUX)
BASEFLAGS = -Wall -pipe -fverbose-asm ${HOSTFLAGS}
endif

ifeq (${HOST_NAME},xvme01.daq.bnl.local)
BASEFLAGS = -O3 -Wall -Wno-error=strict-overflow -Wno-error=unused-label -Wno-error=unused-value -Wno-error=unused-variable -Wno-error=unused-function -Wno-unused-but-set-variable -pipe -fverbose-asm ${HOSTFLAGS}
endif

# if not compiling on one of the standard domains, then
# use the default log destination of std_err
# if compiling on local domain, write to daqman
#
# if compiling somewhere else for writing to daqman these defines
ifeq (${HOSTDOMAIN},starp.bnl.gov)
DEFINES += -DRTS_LOG_DEFAULT_NET
DEFINES += -DRTS_ENABLE_LOG
else ifeq (${HOSTDOMAIN},daq.bnl.local)
DEFINES += -DRTS_LOG_DEFAULT_NET
DEFINES += -DRTS_ENABLE_LOG
else ifeq (${HOSTDOMAIN},daq2.bnl.local)
DEFINES += -DRTS_LOG_DEFAULT_NET
DEFINES += -DRTS_ENABLE_LOG
else ifeq (${HOSTDOMAIN},trg.bnl.local)
DEFINES += -DRTS_LOG_DEFAULT_NET
DEFINES += -DRTS_ENABLE_LOG
else ifeq (${HOSTDOMAIN},l4.bnl.local)
DEFINES += -DRTS_LOG_DEFAULT_NET
DEFINES += -DRTS_ENABLE_LOG
endif

CCFLAGS = ${BASEFLAGS} ${USRCCFLAGS} ${DEFINES} ${INCLUDES}
CXXFLAGS = ${BASEFLAGS} ${USRCXXFLAGS} ${DEFINES} ${INCLUDES}
CFLAGS = ${BASEFLAGS} ${USRCFLAGS} ${DEFINES} ${INCLUDES}
Expand All @@ -387,6 +422,10 @@ ifeq ($(RTS_PROJECT),PP2PP)
endif
endif





# noticed problems on Linux where the default linker gcc doesn't work well for g++ compiled
# files
LINK.o = $(CXX) $(LDFLAGS) $(TARGET_ARCH)
Expand Down
Loading