the only module depending on log4c is org.glite.lbjp-common.log
authorJan Pospíšil <honik@ntc.zcu.cz>
Mon, 15 Mar 2010 07:40:20 +0000 (07:40 +0000)
committerJan Pospíšil <honik@ntc.zcu.cz>
Mon, 15 Mar 2010 07:40:20 +0000 (07:40 +0000)
other modules (server, logger, server-bones) depends on org.glite.lbjp-common.log only

org.glite.lb.logger/Makefile
org.glite.lb.logger/src/logd.c
org.glite.lb.logger/src/logd_proto.c
org.glite.lb.server/Makefile
org.glite.lb.server/src/lb_http.c
org.glite.lb.server/src/notification.c
org.glite.lb/configure
org.glite.lbjp-common.log/src/log.h
org.glite.lbjp-common.server-bones/Makefile
org.glite.lbjp-common.server-bones/src/srvbones.c

index 2274247..856aa9a 100644 (file)
@@ -6,7 +6,6 @@ lbprefix=lb
 package=glite-lb-client
 version=0.0.0
 PREFIX=/opt/glite
-log4c_prefix=/usr
 
 nothrflavour=gcc32
 thrflavour=gcc32pthr
@@ -44,7 +43,7 @@ endif
 
 DEBUG:=-g -O0
 CFLAGS:=${DEBUG} \
-       -I${stagedir}/include -I${top_srcdir}/src -I${log4c_prefix}/include \
+       -I${stagedir}/include -I${top_srcdir}/src \
        -D_GNU_SOURCE \
        ${COVERAGE_FLAGS} \
        ${VERSION} ${LB_STANDALONE_FLAGS} ${LB_PERF_FLAGS} 
index e925011..3f3993e 100644 (file)
@@ -284,7 +284,7 @@ doit(int socket, edg_wll_GssCred cred_handle, char *file_name_prefix, int noipc,
                                (int)timeout.tv_sec, (int) timeout.tv_usec);
                        continue;
                default:
-                       SYSTEM_ERROR("select");
+                       glite_common_log_SYS_ERROR("select");
                        timeout.tv_sec = 0;
                        break;
                }
@@ -478,7 +478,7 @@ This is LocalLogger, part of Workload Management System in EU DataGrid & EGEE.\n
        glite_common_log(LOG_CATEGORY_CONTROL,LOG_PRIORITY_INFO,"Running as daemon... [yes]\n");
        if (daemon(0,0) < 0) {
                glite_common_log(LOG_CATEGORY_CONTROL,LOG_PRIORITY_FATAL,"Failed to run as daemon. Exiting.\n");
-               SYSTEM_ERROR("daemon");
+               glite_common_log_SYS_ERROR("daemon");
                exit(1);
        }
    }
@@ -499,7 +499,7 @@ This is LocalLogger, part of Workload Management System in EU DataGrid & EGEE.\n
        if (client_fd < 0) {
                close(listener_fd);
                glite_common_log(LOG_CATEGORY_ACCESS,LOG_PRIORITY_FATAL,"Failed to accept incomming connections\n");
-               SYSTEM_ERROR("accept");
+               glite_common_log_SYS_ERROR("accept");
                edg_wll_gss_release_cred(&cred, NULL);
                exit(-1);
        } else {
@@ -536,7 +536,7 @@ This is LocalLogger, part of Workload Management System in EU DataGrid & EGEE.\n
        /* FORK - change next line if fork() is not needed (for debugging for example) */
 #if 1
        if ((childpid = fork()) < 0) {
-               SYSTEM_ERROR("fork");
+               glite_common_log_SYS_ERROR("fork");
                if (client_fd) close(client_fd);
        }
        if (childpid == 0) {
index 34df7e1..83b90bb 100644 (file)
@@ -81,7 +81,7 @@ static int handle_gss_failures(int code, edg_wll_GssStatus *gss_code, const char
                        ret = EAGAIN;
                        break;
                case EDG_WLL_GSS_ERROR_ERRNO: 
-                       SYSTEM_ERROR(func);
+                       glite_common_log_SYS_ERROR(func);
                        glite_common_log(LOG_CATEGORY_SECURITY,LOG_PRIORITY_WARN,"%s: %s, system error occured\n", func, text); 
                        ret = EAGAIN;
                        break;
@@ -152,7 +152,7 @@ int init_confirmation()
 
        /* create socket */
        if((confirm_sock=socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
-               SYSTEM_ERROR("socket");
+               glite_common_log_SYS_ERROR("socket");
                glite_common_log(LOG_CATEGORY_ACCESS,LOG_PRIORITY_ERROR,"init_confirmation(): error creating socket\n");
                return(-1);
        }
@@ -164,7 +164,7 @@ int init_confirmation()
 
        /* bind the socket */
        if(bind(confirm_sock, (struct sockaddr *)&saddr, sizeof(saddr.sun_path)) < 0) {
-               SYSTEM_ERROR("bind");
+               glite_common_log_SYS_ERROR("bind");
                glite_common_log(LOG_CATEGORY_ACCESS,LOG_PRIORITY_ERROR,"init_confirmation(): error binding socket\n");
                close(confirm_sock);
                unlink(confirm_sock_name);
@@ -173,7 +173,7 @@ int init_confirmation()
 
        /* and listen */
        if(listen(confirm_sock, 5) < 0) {
-               SYSTEM_ERROR("listen");
+               glite_common_log_SYS_ERROR("listen");
                glite_common_log(LOG_CATEGORY_ACCESS,LOG_PRIORITY_ERROR,"init_confirmation(): error listening on socket\n");
                close(confirm_sock);
                unlink(confirm_sock_name);
@@ -203,7 +203,7 @@ int wait_for_confirmation(struct timeval *timeout, int *code)
 
        /* wait for confirmation at most timeout seconds */
        if ((tmp=select(confirm_sock+1, &fds, NULL, NULL, timeout?&to:NULL)) < 0) {
-               SYSTEM_ERROR("select");
+               glite_common_log_SYS_ERROR("select");
                glite_common_log(LOG_CATEGORY_ACCESS,LOG_PRIORITY_ERROR,"wait_for_confirmation(): error selecting socket\n");
                ret = -1;
        } else {
@@ -213,12 +213,12 @@ int wait_for_confirmation(struct timeval *timeout, int *code)
                        int nsd = accept(confirm_sock, NULL, NULL);
                        ret = 1;
                        if(nsd < 0) {
-                               SYSTEM_ERROR("accept");
+                               glite_common_log_SYS_ERROR("accept");
                                glite_common_log(LOG_CATEGORY_ACCESS,LOG_PRIORITY_ERROR,"wait_for_confirmation(): error accepting a connection on a socket\n");
                                ret = -1;
                        } else {
                                if(recv(nsd, code, sizeof(*code), MSG_NOSIGNAL) < 0) {
-                                       SYSTEM_ERROR("recv");
+                                       glite_common_log_SYS_ERROR("recv");
                                        glite_common_log(LOG_CATEGORY_ACCESS,LOG_PRIORITY_ERROR,"wait_for_confirmation(): error receiving a message from a socket\n");
                                        ret = -1;
                                }
@@ -266,7 +266,7 @@ int do_listen(int port)
 
        sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
        if (sock == -1) { 
-               SYSTEM_ERROR("socket"); 
+               glite_common_log_SYS_ERROR("socket"); 
                glite_common_log(LOG_CATEGORY_ACCESS,LOG_PRIORITY_ERROR,"do_listen(): error creating socket\n");
                return -1; 
        }
@@ -274,14 +274,14 @@ int do_listen(int port)
        setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
        ret = bind(sock, (struct sockaddr *)&my_addr, sizeof(my_addr));
        if (ret == -1) { 
-               SYSTEM_ERROR("bind"); 
+               glite_common_log_SYS_ERROR("bind"); 
                glite_common_log(LOG_CATEGORY_ACCESS,LOG_PRIORITY_ERROR,"do_listen(): error binding socket\n");
                return -1; 
        }
 
        ret = listen(sock, 5);
        if (ret == -1) { 
-               SYSTEM_ERROR("listen"); 
+               glite_common_log_SYS_ERROR("listen"); 
                glite_common_log(LOG_CATEGORY_ACCESS,LOG_PRIORITY_ERROR,"do_listen(): error listening on socket\n");
                close(sock); 
                return -1; 
@@ -353,7 +353,7 @@ int edg_wll_log_proto_server(edg_wll_GssConnection *con, struct timeval *timeout
                        if (errno == EEXIST) {
                                glite_common_log(LOG_CATEGORY_ACCESS,LOG_PRIORITY_WARN,"Warning: LLLID %ld already in use.\n",lllid);
                        } else {
-                               SYSTEM_ERROR("open");
+                               glite_common_log_SYS_ERROR("open");
                        }
                } else {
                        unique = 1;
@@ -432,7 +432,7 @@ int edg_wll_log_proto_server(edg_wll_GssConnection *con, struct timeval *timeout
 
        /* format the DG.LLLID string */
        if (asprintf(&dglllid,"DG.LLLID=%ld ",lllid) == -1) {
-               SYSTEM_ERROR("asprintf");
+               glite_common_log_SYS_ERROR("asprintf");
                glite_common_log(LOG_CATEGORY_ACCESS,LOG_PRIORITY_WARN,"edg_wll_log_proto_server(): nomem for DG.LLLID\n");
                answer = ENOMEM;
                goto edg_wll_log_proto_server_end;
@@ -442,7 +442,7 @@ int edg_wll_log_proto_server(edg_wll_GssConnection *con, struct timeval *timeout
        /* format the DG.USER string */
        name_esc = glite_lbu_EscapeULM(name);
        if (asprintf(&dguser,"DG.USER=\"%s\" ",name_esc) == -1) {
-               SYSTEM_ERROR("asprintf");
+               glite_common_log_SYS_ERROR("asprintf");
                glite_common_log(LOG_CATEGORY_ACCESS,LOG_PRIORITY_WARN,"edg_wll_log_proto_server(): nomem for DG.USER\n");
                answer = ENOMEM;
                goto edg_wll_log_proto_server_end;
@@ -452,7 +452,7 @@ int edg_wll_log_proto_server(edg_wll_GssConnection *con, struct timeval *timeout
        /* allocate enough memory for all data */
        msg_size = dglllid_size + dguser_size + size + 1;
        if ((msg = malloc(msg_size)) == NULL) {
-               SYSTEM_ERROR("malloc");
+               glite_common_log_SYS_ERROR("malloc");
                glite_common_log(LOG_CATEGORY_ACCESS,LOG_PRIORITY_WARN,"edg_wll_log_proto_server(): out of memory for allocating message\n");
                answer = ENOMEM;
                goto edg_wll_log_proto_server_end;
@@ -533,7 +533,7 @@ int edg_wll_log_proto_server(edg_wll_GssConnection *con, struct timeval *timeout
                if ( edg_wll_log_event_write(context, outfilename, msg, FCNTL_ATTEMPTS, FCNTL_TIMEOUT, &filepos) ) {
                        char *errd;
                        // FIXME: there is probably not a correct errno
-                       SYSTEM_ERROR("edg_wll_log_event_write");
+                       glite_common_log_SYS_ERROR("edg_wll_log_event_write");
                        answer = edg_wll_Error(context, NULL, &errd);
                        glite_common_log(LOG_CATEGORY_ACCESS,LOG_PRIORITY_WARN,"edg_wll_log_event_write error: %s\n",errd);
                        free(errd);
@@ -571,8 +571,8 @@ int edg_wll_log_proto_server(edg_wll_GssConnection *con, struct timeval *timeout
 
                if ( edg_wll_log_event_send(context, socket_path, filepos, msg, msg_size, CONNECT_ATTEMPTS, timeout) ) {
                        char *errd;
-                       // FIXME: probably also not a SYSTEM ERROR
-                       SYSTEM_ERROR("edg_wll_log_event_send");
+                       // XXX: probably not a SYSTEM ERROR
+                       // glite_common_log_SYS_ERROR("edg_wll_log_event_send");
                        answer = edg_wll_Error(context, NULL, &errd);
                        glite_common_log(LOG_CATEGORY_ACCESS,LOG_PRIORITY_WARN,"edg_wll_log_event_send error: %s\n",errd);
                        free(errd);
index 3ae9c9d..745828e 100644 (file)
@@ -68,7 +68,6 @@ GRIDSITE_CFLAGS = -I${gridsite_prefix}/include `xml2-config --cflags`
 GRIDSITE_LIBS = -L${gridsite_prefix}/${libdir} -L${gridsite_prefix}/lib -lgridsite_globus `xml2-config --libs`
 
 LCAS_CFLAGS=-I${lcas_prefix}/include
-LOG4C_CFLAGS=-I${log4c_prefix}/include
 
 CFLAGS:= \
        ${WS_CFLAGS} ${DEBUG} \
@@ -81,7 +80,7 @@ CFLAGS:= \
        -I${classads_prefix}/include -I${classads_prefix}/include/classad \
        -I${voms_prefix}/include \
        ${COVERAGE_FLAGS} \
-       $(GRIDSITE_CFLAGS) ${LCAS_CFLAGS} ${LOG4C_CFLAGS} \
+       $(GRIDSITE_CFLAGS) ${LCAS_CFLAGS} \
        -D_GNU_SOURCE ${LB_STANDALONE_FLAGS} ${LB_PERF_FLAGS} -DLB_EVENTS_BLOB \
        -I${globus_prefix}/include/${nothrflavour} #gridsite needs this
 
index 8c48ca3..b60f81a 100644 (file)
@@ -47,14 +47,14 @@ int edg_wll_AcceptHTTP(edg_wll_Context ctx, char **body, char **resp, char ***hd
 
        if (req)
                glite_common_log(LOG_CATEGORY_LB_SERVER_REQUEST, 
-                       LOG4C_PRIORITY_DEBUG, "[%d] request: %s", 
+                       LOG_PRIORITY_DEBUG, "[%d] request: %s", 
                        getpid(), req);
        else
                glite_common_log(LOG_CATEGORY_LB_SERVER_REQUEST, 
-                        LOG4C_PRIORITY_DEBUG, "no request");
+                        LOG_PRIORITY_DEBUG, "no request");
        if (body && *body) 
                glite_common_log(LOG_CATEGORY_LB_SERVER_REQUEST, 
-                        LOG4C_PRIORITY_DEBUG, "request body:\n%s",*body);
+                        LOG_PRIORITY_DEBUG, "request body:\n%s",*body);
 
        if (!err) {
                if ((err = edg_wll_Proto(ctx,req,hdr,*body,resp,hdrOut,bodyOut,httpErr)))
index 3e3757b..207062f 100644 (file)
@@ -694,7 +694,7 @@ static int update_notif(
        trio_asprintf(&aux, "%s where notifid='%|Ss'", stmt, nid_s);
        free(stmt);
        stmt = aux;
-       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG4C_PRIORITY_DEBUG, stmt);
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
 
        if ( (ret = edg_wll_ExecSQL(ctx, stmt, NULL)) < 0 )
                goto cleanup;
@@ -703,7 +703,7 @@ static int update_notif(
                free(stmt);
                trio_asprintf(&stmt,
                                "select notifid from notif_registrations where notifid='%|Ss'", nid_s);
-               glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG4C_PRIORITY_DEBUG, stmt);
+               glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
                ret = edg_wll_ExecSQL(ctx, stmt, NULL);
                if ( ret == 0 )
                        edg_wll_SetError(ctx, ENOENT, "Unknown notification ID");
index 4ee7639..838219a 100755 (executable)
@@ -301,8 +301,8 @@ BEGIN{
        'lb.client-java' => [ qw/ant:B jdk:B axis:B trustmanager/ ],
        'lb.common' => [ qw/expat cppunit:B classads/ ],
        'lb.doc' => [],
-       'lb.logger' => [ qw/cppunit:B log4c/ ],
-       'lb.server' => [ qw/globus_essentials:R globus:B expat cares mysql:R mysql-server:R mysql-devel:B cppunit:B gsoap:B classads voms lcas gridsite log4c/ ],
+       'lb.logger' => [ qw/cppunit:B/ ],
+       'lb.server' => [ qw/globus_essentials:R globus:B expat cares mysql:R mysql-server:R mysql-devel:B cppunit:B gsoap:B classads voms lcas gridsite/ ],
        'lb.state-machine' => [ qw/classads/ ],
        'lb.utils' => [ qw/cppunit:B/ ],
        'lb.ws-interface' => [],
@@ -310,9 +310,9 @@ BEGIN{
        'lb.types' => [ qw// ],
        'lb.harvester' => [ qw/postgresql:R/ ],
        'lbjp-common.db' => [ qw/mysql:B mysql-devel:B postgresql:B/ ],
-       'lbjp-common.log' => [ qw// ],
+       'lbjp-common.log' => [ qw/log4c/ ],
        'lbjp-common.maildir' => [ qw// ],
-       'lbjp-common.server-bones' => [ qw/log4c/ ],
+       'lbjp-common.server-bones' => [ qw// ],
        'lbjp-common.trio' => [ qw/cppunit:B/ ],
        'lbjp-common.jp-interface' => [ qw/cppunit:B/ ],
        'security.gss' =>  [ qw/globus_essentials:R globus:B cares cppunit:B/ ],
@@ -449,7 +449,7 @@ for my $ext (keys %deps_aux) {
        jpclient => 'jp.client',
 );
 
-my @t = qw/lb.client-java jobid.api-java lb.types lbjp-common.log/;
+my @t = qw/lb.client-java jobid.api-java lb.types/;
 @topbuild{@t} = (1) x ($#t+1);
 }
 
index a63bc9a..a8e3bae 100644 (file)
@@ -19,15 +19,13 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
-
-/* gLite common logging recommendations v1.1 https://twiki.cern.ch/twiki/pub/EGEE/EGEEgLite/logging.html */
+/* gLite common logging recommendations v1.1 
+   https://twiki.cern.ch/twiki/pub/EGEE/EGEEgLite/logging.html */
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include <log4c.h>
-
 /* default categories */
 #define LOG_CATEGORY_NAME              "root"
 #define LOG_CATEGORY_SECURITY          "SECURITY"
@@ -40,25 +38,15 @@ extern "C" {
 #define LOG_CATEGORY_LB_SERVER_DB      "LB.SERVER.DB"
 #define LOG_CATEGORY_LB_SERVER_REQUEST "LB.SERVER.REQUEST"
 
-/* default priorities */
-#define LOG_PRIORITY_FATAL      LOG4C_PRIORITY_FATAL
-#define LOG_PRIORITY_ERROR      LOG4C_PRIORITY_ERROR
-#define LOG_PRIORITY_WARN       LOG4C_PRIORITY_WARN
-#define LOG_PRIORITY_INFO       LOG4C_PRIORITY_INFO
-#define LOG_PRIORITY_DEBUG      LOG4C_PRIORITY_DEBUG
-#define LOG_PRIORITY_NOTSET     LOG4C_PRIORITY_NOTSET
-
-#define SYSTEM_ERROR(my_err) { \
-        if (errno !=0 ) \
-                glite_common_log(LOG_CATEGORY_CONTROL,LOG_PRIORITY_ERROR,"%s: %s\n",my_err,strerror(errno)); \
-        else \
-                glite_common_log(LOG_CATEGORY_CONTROL,LOG_PRIORITY_ERROR,"%s\n",my_err); }
-
-#define SYSTEM_FATAL(my_err) { \
-        if (errno !=0 ) \
-                glite_common_log(LOG_CATEGORY_CONTROL,LOG_PRIORITY_FATAL,"%s: %s\n",my_err,strerror(errno)); \
-        else \
-                glite_common_log(LOG_CATEGORY_CONTROL,LOG_PRIORITY_FATAL,"%s\n",my_err); }
+/* default priorities
+ * - follow LOG4C_PRIORITY_* defined in <log4c/priority.h> 
+ */
+#define LOG_PRIORITY_FATAL      000    // LOG4C_PRIORITY_FATAL
+#define LOG_PRIORITY_ERROR      300    // LOG4C_PRIORITY_ERROR
+#define LOG_PRIORITY_WARN       400    // LOG4C_PRIORITY_WARN
+#define LOG_PRIORITY_INFO       600    // LOG4C_PRIORITY_INFO
+#define LOG_PRIORITY_DEBUG      700    // LOG4C_PRIORITY_DEBUG
+#define LOG_PRIORITY_NOTSET     900    // LOG4C_PRIORITY_NOTSET
 
 /* logging functions */
 
@@ -98,6 +86,20 @@ extern void glite_common_log(char *catName,int a_priority, const char* a_format,
  */
 extern void glite_common_log_reread(void);
 
+
+/* simple wrappers around glite_common_log() that include also errno */
+#define glite_common_log_SYS_ERROR(my_err) { \
+        if (errno !=0 ) \
+                glite_common_log(LOG_CATEGORY_CONTROL,LOG_PRIORITY_ERROR,"%s: %s\n",my_err,strerror(errno)); \
+        else \
+                glite_common_log(LOG_CATEGORY_CONTROL,LOG_PRIORITY_ERROR,"%s\n",my_err); }
+
+#define glite_common_log_SYS_FATAL(my_err) { \
+        if (errno !=0 ) \
+                glite_common_log(LOG_CATEGORY_CONTROL,LOG_PRIORITY_FATAL,"%s: %s\n",my_err,strerror(errno)); \
+        else \
+                glite_common_log(LOG_CATEGORY_CONTROL,LOG_PRIORITY_FATAL,"%s\n",my_err); }
+
 #ifdef __cplusplus
 }
 #endif
index 89992c7..44854e0 100644 (file)
@@ -20,7 +20,6 @@ DEBUG:=-g -O0 -Wall
 CFLAGS:= ${DEBUG} \
        -I${top_srcdir}/interface \
        -I${stagedir}/include \
-       -I${log4c_prefix}/include \
        -D_GNU_SOURCE 
 LDFLAGS:=-L${stagedir}/${libdir}
 
index 96a3b41..92b7ef3 100644 (file)
@@ -401,7 +401,7 @@ static int dispatchit(int sock_slave, int sock, int sidx)
        if (ret)
        {
                glite_common_log(set_log_category,
-                         LOG4C_PRIORITY_WARN, "sendmsg()");
+                         LOG_PRIORITY_WARN, "sendmsg()");
        }