From a4ea8fd727ae6914939f5d238ffcdaf96b484c5f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Posp=C3=AD=C5=A1il?= Date: Fri, 12 Mar 2010 15:40:09 +0000 Subject: [PATCH] lbu/log now a library depends dynamically on log4c, logger, server and server-bones now depends on lbu.log --- org.glite.lb.logger/Makefile | 2 +- org.glite.lb.server/Makefile | 20 ++--- org.glite.lbjp-common.log/Makefile | 69 ++++++++++++++--- .../project/version.properties | 2 +- org.glite.lbjp-common.log/src/log.c | 88 ++++++++++++++++++++++ org.glite.lbjp-common.log/{ => src}/log.h | 56 ++------------ .../src/log4crc.example-debugging | 36 +++++++++ .../log4crc.example-production} | 0 org.glite.lbjp-common.server-bones/Makefile | 13 ++-- 9 files changed, 207 insertions(+), 79 deletions(-) create mode 100644 org.glite.lbjp-common.log/src/log.c rename org.glite.lbjp-common.log/{ => src}/log.h (63%) create mode 100644 org.glite.lbjp-common.log/src/log4crc.example-debugging rename org.glite.lbjp-common.log/{log4crc.example => src/log4crc.example-production} (100%) diff --git a/org.glite.lb.logger/Makefile b/org.glite.lb.logger/Makefile index 3b79c31..2274247 100644 --- a/org.glite.lb.logger/Makefile +++ b/org.glite.lb.logger/Makefile @@ -64,7 +64,7 @@ INSTALL:=libtool --mode=install install COMMON_LIB:=-lglite_lb_common -EXT_LIB:=-lglite_lbu_trio -L${log4c_prefix}/lib -llog4c +EXT_LIB:=-lglite_lbu_trio -lglite_lbu_log GLITE_GSS_LIB:=-lglite_security_gss diff --git a/org.glite.lb.server/Makefile b/org.glite.lb.server/Makefile index 1821750..3ae9c9d 100644 --- a/org.glite.lb.server/Makefile +++ b/org.glite.lb.server/Makefile @@ -97,7 +97,7 @@ else SRVBONES_LIB:= -L${stagedir}/lib -lglite_lbu_server_bones LB_COMMON_LIB:=-L${stagedir}/lib -lglite_lb_common_${nothrflavour} LB_UTILS_DB_LIB:=-L${stagedir}/lib -lglite_lbu_db - LDFLAGS:= -L${stagedir}/lib + LDFLAGS:= -L${stagedir}/lib -L${stagedir}/${libdir} endif # LB_MACHINE_LIB:=${stagedir}/lib/libglite_lb_statemachine.a @@ -140,7 +140,6 @@ ifeq (${nothrflavour},gcc32dbg) endif VOMS_LIBS:=-L${voms_prefix}/${libdir} -lvomsapi${vomsflavour} LCAS_LIBS:=-L${lcas_prefix}/${libdir} -llcas -LOG4C_LIBS:=-L${log4c_prefix}/lib -llog4c #EXT_LIBS:= \ # ${expatlib} -lexpat \ @@ -163,10 +162,9 @@ EXT_LIBS:= \ ${CLASSADS_LIBS} \ ${CARES_LIBS} \ ${LCAS_LIBS} \ - ${VOMS_LIBS} \ - ${LOG4C_LIBS} + ${VOMS_LIBS} -COMMON_LIBS:= -L${stagedir}/lib -lglite_lb_common_${nothrflavour} -lglite_security_gss_${nothrflavour} -lglite_lbu_trio -lglite_lbu_maildir +COMMON_LIBS:= -L${stagedir}/lib -lglite_lb_common_${nothrflavour} -lglite_security_gss_${nothrflavour} -lglite_lbu_trio -lglite_lbu_maildir -lglite_lbu_log BKSERVER_BASE_OBJS:= \ bkserverd.o il_lbproxy.o get_events.o index.o jobstat.o jobstat_supp.o \ @@ -180,10 +178,10 @@ BKSERVER_BASE_OBJS:= \ gsoap_version ?= ${gsoap_default_version} dotless_gsoap_ver:=${shell echo ${gsoap_version} | tr -d . } -ifeq ($(shell test -f ${stagedir}/lib/libglite_security_gsoap_plugin_${dotless_gsoap_ver}_${nothrflavour}_c.so && echo ok),ok) +ifeq ($(shell test -f ${stagedir}/${libdir}/libglite_security_gsoap_plugin_${dotless_gsoap_ver}_${nothrflavour}_c.so && echo ok),ok) langflavour:=_c endif -GSOAP_LIB:=-L${stagedir}/lib -lglite_security_gsoap_plugin_${dotless_gsoap_ver}_${nothrflavour}${langflavour} +GSOAP_LIB:=-L${stagedir}/${libdir} -lglite_security_gsoap_plugin_${dotless_gsoap_ver}_${nothrflavour}${langflavour} ifeq ($(GLITE_LB_SERVER_WITH_WS),yes) BKSERVER_OBJS:= \ @@ -199,7 +197,8 @@ ifeq ($(GLITE_LB_SERVER_WITH_WS),yes) ${GSOAP_LIB} \ ${EXT_LIBS} \ ${classadslib} \ - -lglite_lbu_maildir + -lglite_lbu_maildir \ + -lglite_lbu_log else BKSERVER_OBJS:= ${BKSERVER_BASE_OBJS} @@ -211,7 +210,8 @@ else -lglite_security_gss_${nothrflavour} \ ${EXT_LIBS} \ ${classadslib} \ - -lglite_lbu_maildir + -lglite_lbu_maildir \ + -lglite_lbu_log endif INDEX_OBJS:= index.o index_parse.o jobstat_supp.o openserver.o \ @@ -312,7 +312,7 @@ query_events_objs := test_query_events.o query.o get_events.o jobstat_supp.o ind test_query_events: ${query_events_objs} ${LINKXX} -o $@ ${query_events_objs} \ - ${TEST_LIBS} ${LB_COMMON_LIB} ${LB_MACHINE_LIB} ${classadslib} ${LOG4C_LIBS} + ${TEST_LIBS} ${LB_COMMON_LIB} ${LB_MACHINE_LIB} ${classadslib} -lglite_lbu_log test.soapconv: test_soap_conv ./test_soap_conv diff --git a/org.glite.lbjp-common.log/Makefile b/org.glite.lbjp-common.log/Makefile index 3fb2e5e..5c2c8e8 100644 --- a/org.glite.lbjp-common.log/Makefile +++ b/org.glite.lbjp-common.log/Makefile @@ -1,33 +1,84 @@ top_srcdir=.. -stagedir=../stage +builddir=build +top_builddir=${top_srcdir}/${builddir} +stagedir=. +distdir=. globalprefix=glite lbutilsprefix=lbu package=glite-lbu-log version=0.0.0 PREFIX=/opt/glite - log4c_prefix=/usr -include Makefile.inc --include ./project/version.properties +-include ../project/version.properties + +version=${module.version} + +CC=gcc +VPATH=${top_srcdir}/interface:${top_srcdir}/src + +LOG4C_CFLAGS:=-I${log4c_prefix}/include +LOG4C_LIBS:=-L${log4c_prefix}/${libdir} -L${log4c_prefix}/lib -llog4c + +DEBUG:=-g -O0 -W -Wall + +CFLAGS:= \ + ${DEBUG} \ + -I${stagedir}/include -I${top_srcdir}/src \ + -I${top_srcdir}/interface \ + ${LOG4C_CFLAGS} + +LDFLAGS:=-L${stagedir}/${libdir} -HEADER=log.h +COMPILE:=libtool --mode=compile ${CC} ${CFLAGS} +LINK:=libtool --mode=link ${CC} -rpath ${stagedir}/${libdir} ${LDFLAGS} +INSTALL:=libtool --mode=install install -default: compile +OBJS:=log.o +LOBJS:=${OBJS:.o=.lo} +LTLIB:=libglite_lbu_log.la -compile: +# In order to use libtool versioning correcty, we must have: +# +# current = major + minor + offset +# revision = patch +# age = minor +# +# where offset is a sum of maximal released minor's of all previous major's +# + +# counted minors: n/a +offset=0 + +version_info:=-version-info ${shell \ + perl -e '$$,=":"; @F=split "\\.","${version}"; print $$F[0]+$$F[1]+${offset},$$F[2],$$F[1]' } + +default all: compile + +compile: ${LTLIB} stage: compile $(MAKE) install PREFIX=${stagedir} install: compile mkdir -p ${PREFIX}/include/${globalprefix}/${lbutilsprefix} - install -m 644 ${HEADER} ${PREFIX}/include/${globalprefix}/${lbutilsprefix} + ${INSTALL} -m 644 ${top_srcdir}/src/log.h ${PREFIX}/include/${globalprefix}/${lbutilsprefix} mkdir -p ${PREFIX}/share/doc/${package}-${version} - install -m 644 LICENSE ${PREFIX}/share/doc/${package}-${version} + ${INSTALL} -m 644 ${top_srcdir}/LICENSE ${PREFIX}/share/doc/${package}-${version} mkdir -p ${PREFIX}/etc - install -m 644 log4crc.example ${PREFIX}/etc/glite-lb-log4crc + ${INSTALL} -m 644 ${top_srcdir}/src/log4crc.* ${PREFIX}/share/doc/${package}-${version} + ${INSTALL} -m 644 ${top_srcdir}/src/log4crc.example-production ${PREFIX}/etc/glite-lb-log4crc + ${INSTALL} -m 755 ${LTLIB} ${PREFIX}/${libdir}/${LTLIB} + clean: + rm -rvf *.o *.lo .libs lib* rm -rvf log.xml project/ rpmbuild/ RPMS/ tgz/ check: + +${LTLIB}: ${LOBJS} + ${LINK} ${version_info} -o $@ $+ ${LOG4C_LIBS} + +%.o %.lo: %.c + ${COMPILE} -c $< diff --git a/org.glite.lbjp-common.log/project/version.properties b/org.glite.lbjp-common.log/project/version.properties index 97368fe..45e3482 100644 --- a/org.glite.lbjp-common.log/project/version.properties +++ b/org.glite.lbjp-common.log/project/version.properties @@ -1,4 +1,4 @@ # $Header$ -module.version=0.0.0 +module.version=1.0.0 module.age=0 diff --git a/org.glite.lbjp-common.log/src/log.c b/org.glite.lbjp-common.log/src/log.c new file mode 100644 index 0000000..707067c --- /dev/null +++ b/org.glite.lbjp-common.log/src/log.c @@ -0,0 +1,88 @@ +#ident "$Header$" + +#include +#include +#include +#include "log.h" + +/** + * constructor + * + * @returns 0 for success + */ +int glite_common_log_init(void) { +#ifndef WITHOUT_LOG4C + return(log4c_init()); +#else + return 0; +#endif +} + +/** + * destructor + * + * @returns 0 for success + */ +int glite_common_log_fini(void) { +#ifndef WITHOUT_LOG4C + return(log4c_fini()); +#else + return 0; +#endif +} + +/** + * Log a message with the specified priority. + * @param catName category name + * @param a_priority The priority of this log message. + * @param msg message + **/ +void glite_common_log_msg(char *catName,int a_priority, char *msg) { +#ifndef WITHOUT_LOG4C + const log4c_category_t* a_category = log4c_category_get(catName); + + if (log4c_category_is_priority_enabled(a_category, a_priority)) { + log4c_category_log(log4c_category_get(catName), a_priority, msg); + } +#else + printf(msg); +#endif +} + +/** + * Log a message with the specified priority. + * @param catName category name + * @param a_priority The priority of this log message. + * @param a_format Format specifier for the string to write in the log file. + * @param ... The arguments for a_format + **/ +void glite_common_log(char *catName,int a_priority, const char* a_format,...) { +#ifndef WITHOUT_LOG4C + const log4c_category_t* a_category = log4c_category_get(catName); + + if (log4c_category_is_priority_enabled(a_category, a_priority)) { + va_list va; + + va_start(va, a_format); + log4c_category_vlog(a_category, a_priority, a_format, va); + va_end(va); + } +#else + va_list va; + + va_start(va, a_format); + vprintf(va, a_format); + va_end(va); +#endif +} + +/* + * Rereads any log4crc files that have changed + */ +void glite_common_log_reread(void) { +#ifndef WITHOUT_LOG4C + log4c_reread(); +#endif +} + + diff --git a/org.glite.lbjp-common.log/log.h b/org.glite.lbjp-common.log/src/log.h similarity index 63% rename from org.glite.lbjp-common.log/log.h rename to org.glite.lbjp-common.log/src/log.h index f37ca32..cf6f2de 100644 --- a/org.glite.lbjp-common.log/log.h +++ b/org.glite.lbjp-common.log/src/log.h @@ -9,8 +9,6 @@ extern "C" { #endif -#include -#include #include /* default categories */ @@ -52,26 +50,14 @@ extern "C" { * * @returns 0 for success */ -static inline int glite_common_log_init(void) { -#ifndef WITHOUT_LOG4C - return(log4c_init()); -#else - return 0; -#endif -} +extern int glite_common_log_init(void); /** * destructor * * @returns 0 for success */ -static inline int glite_common_log_fini(void) { -#ifndef WITHOUT_LOG4C - return(log4c_fini()); -#else - return 0; -#endif -} +extern int glite_common_log_fini(void); /** * Log a message with the specified priority. @@ -79,17 +65,7 @@ static inline int glite_common_log_fini(void) { * @param a_priority The priority of this log message. * @param msg message **/ -static inline void glite_common_log_msg(char *catName,int a_priority, char *msg) { -#ifndef WITHOUT_LOG4C - const log4c_category_t* a_category = log4c_category_get(catName); - - if (log4c_category_is_priority_enabled(a_category, a_priority)) { - log4c_category_log(log4c_category_get(catName), a_priority, msg); - } -#else - printf(msg); -#endif -} +extern void glite_common_log_msg(char *catName,int a_priority, char *msg); /** * Log a message with the specified priority. @@ -98,34 +74,12 @@ static inline void glite_common_log_msg(char *catName,int a_priority, char *msg) * @param a_format Format specifier for the string to write in the log file. * @param ... The arguments for a_format **/ -static inline void glite_common_log(char *catName,int a_priority, const char* a_format,...) { -#ifndef WITHOUT_LOG4C - const log4c_category_t* a_category = log4c_category_get(catName); - - if (log4c_category_is_priority_enabled(a_category, a_priority)) { - va_list va; - - va_start(va, a_format); - log4c_category_vlog(a_category, a_priority, a_format, va); - va_end(va); - } -#else - va_list va; - - va_start(va, a_format); - vprintf(va, a_format); - va_end(va); -#endif -} +extern void glite_common_log(char *catName,int a_priority, const char* a_format,...); /* * Rereads any log4crc files that have changed */ -static inline void glite_common_log_reread(void) { -#ifndef WITHOUT_LOG4C - log4c_reread(); -#endif -} +extern void glite_common_log_reread(void); #ifdef __cplusplus } diff --git a/org.glite.lbjp-common.log/src/log4crc.example-debugging b/org.glite.lbjp-common.log/src/log4crc.example-debugging new file mode 100644 index 0000000..068f801 --- /dev/null +++ b/org.glite.lbjp-common.log/src/log4crc.example-debugging @@ -0,0 +1,36 @@ + + + + + + + 0 + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.glite.lbjp-common.log/log4crc.example b/org.glite.lbjp-common.log/src/log4crc.example-production similarity index 100% rename from org.glite.lbjp-common.log/log4crc.example rename to org.glite.lbjp-common.log/src/log4crc.example-production diff --git a/org.glite.lbjp-common.server-bones/Makefile b/org.glite.lbjp-common.server-bones/Makefile index 207de7b..89992c7 100644 --- a/org.glite.lbjp-common.server-bones/Makefile +++ b/org.glite.lbjp-common.server-bones/Makefile @@ -22,7 +22,7 @@ CFLAGS:= ${DEBUG} \ -I${stagedir}/include \ -I${log4c_prefix}/include \ -D_GNU_SOURCE -LDFLAGS:= +LDFLAGS:=-L${stagedir}/${libdir} ifdef LB_PROF CFLAGS:= ${CFLAGS} -pg -g @@ -30,10 +30,9 @@ ifdef LB_PROF endif COMPILE:=libtool --mode=compile ${CC} ${CFLAGS} -LINK:=libtool --mode=link ${CC} -rpath ${stagedir}/lib ${LDFLAGS} ${LOG4C_LIBS} +LINK:=libtool --mode=link ${CC} -rpath ${stagedir}/${libdir} ${LDFLAGS} INSTALL:=libtool --mode=install install -LOG4C_LIBS:=-L${log4c_prefix}/lib -llog4c STATICLIB:=libglite_lbu_server_bones.a LTLIB:=libglite_lbu_server_bones.la @@ -66,7 +65,7 @@ ${STATICLIB}: ${OBJS} ranlib $@ ${LTLIB}: ${LOBJS} - ${LINK} ${version_info} -o $@ ${LOBJS} ${LOG4C_LIBS} + ${LINK} ${version_info} -o $@ ${LOBJS} -lglite_lbu_log stage: compile $(MAKE) install PREFIX=${stagedir} DOSTAGE=yes @@ -86,9 +85,9 @@ doc: install: mkdir -p ${PREFIX}/include/${globalprefix}/${lbutilsprefix} - mkdir -p ${PREFIX}/lib - ${INSTALL} -m 644 ${LTLIB} ${PREFIX}/lib - ${INSTALL} -m 644 ${STATICLIB} ${PREFIX}/lib ; \ + mkdir -p ${PREFIX}/${libdir} + ${INSTALL} -m 644 ${LTLIB} ${PREFIX}/${libdir} + ${INSTALL} -m 644 ${STATICLIB} ${PREFIX}/${libdir} ; \ cd ${top_srcdir}/interface && install -m 644 ${HDRS} ${PREFIX}/include/${globalprefix}/${lbutilsprefix} clean: -- 1.8.2.3