comlog for LB server (not finished yet)
authorJiří Filipovič <fila@ics.muni.cz>
Thu, 13 Aug 2009 14:24:42 +0000 (14:24 +0000)
committerJiří Filipovič <fila@ics.muni.cz>
Thu, 13 Aug 2009 14:24:42 +0000 (14:24 +0000)
21 files changed:
org.glite.lb.server/src/bkserverd.c
org.glite.lb.server/src/db_calls.c
org.glite.lb.server/src/db_supp.c
org.glite.lb.server/src/dump.c
org.glite.lb.server/src/il_lbproxy.c
org.glite.lb.server/src/il_notification.c
org.glite.lb.server/src/jobstat.c
org.glite.lb.server/src/lb_authz.c
org.glite.lb.server/src/lb_html.c
org.glite.lb.server/src/lb_http.c
org.glite.lb.server/src/lb_proto.c
org.glite.lb.server/src/load.c
org.glite.lb.server/src/notif_match.c
org.glite.lb.server/src/notification.c
org.glite.lb.server/src/query.c
org.glite.lb.server/src/seqcode.c
org.glite.lb.server/src/server_state.c
org.glite.lb.server/src/srv_purge.c
org.glite.lb.server/src/stats.c
org.glite.lb.server/src/userjobs.c
org.glite.lb.server/src/ws_query.c

index 6c78e9a..13b724e 100644 (file)
@@ -19,7 +19,6 @@
 #include <netdb.h>
 #include <limits.h>
 #include <assert.h>
-#include <syslog.h>
 #include <sys/time.h>
 #include <arpa/inet.h>
 #include <arpa/nameser.h>
@@ -40,6 +39,7 @@
 #include "glite/lb/context.h"
 #include "glite/lb/mini_http.h"
 #include "glite/lb/context-int.h"
+#include "glite/lbu/log.h"
 
 #ifdef LB_PERF
 #include "glite/lb/lb_perftest.h"
@@ -485,16 +485,20 @@ int main(int argc, char *argv[])
        setlinebuf(stdout);
        setlinebuf(stderr);
 
-       dprintf(("\n"));
-       if (mode & SERVICE_PROXY) dprintf(("Starting LB proxy service\n"));
-       if (mode & SERVICE_SERVER) dprintf(("Starting LB server service\n"));
-       dprintf(("\n"));
+       if (glite_common_log_init()) {
+               fprintf(stderr,"glite_common_log_init() failed, exiting.\n");
+               exit(1);
+       }
+       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Initializing...");
+
+       if (mode & SERVICE_PROXY) glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Starting LB proxy service");
+       if (mode & SERVICE_SERVER) glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Starting LB server service");
 
        // XXX: workaround for only preudoparallel job registration
        //      we need at least 2 slaves to avoid locking misbehaviour
        if ((mode == SERVICE_PROXY_SERVER) && (slaves == 1)) {
-               dprintf(("WARNING: Running both proxy and server services enforces at least 2 slaves\n"));
-               dprintf(("Starting 2 slaves\n"));
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "Running both proxy and server services enforces at least 2 slaves");
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "Starting 2 slaves");
                slaves = 2;
        }
 
@@ -510,7 +514,7 @@ int main(int argc, char *argv[])
                {
                        if ( !kill(opid,0) )
                        {
-                               fprintf(stderr,"%s: another instance running, pid = %d\n",argv[0],opid);
+                               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "%s: another instance running, pid = %d", argv[0], opid);
                                return 1;
                        }
                        else if (errno != ESRCH) { perror("kill()"); return 1; }
@@ -524,12 +528,17 @@ int main(int argc, char *argv[])
        if (fclose(fpid) != 0) { perror(pidfile); return 1; }
 
        if (mode & SERVICE_SERVER) {
-               if (check_mkdir(dumpStorage)) exit(1);
-               if (check_mkdir(purgeStorage)) exit(1);
+               if (check_mkdir(dumpStorage)){
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "Directory for dump files not redy!");
+                       exit(1);
+               }
+               if (check_mkdir(purgeStorage)){
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "Directory for purge files not redy!");
+                       exit(1);
+               }
                if ( jpreg ) {
                        if ( glite_lbu_MaildirInit(jpregDir) ) {
-                               dprintf(("[%d] glite_lbu_MaildirInit failed: %s\n", getpid(), lbm_errdesc));
-                               if (!debug) syslog(LOG_CRIT, "glite_lbu_MaildirInit failed: %s", lbm_errdesc);
+                               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "[%d] glite_lbu_MaildirInit failed: %s", getpid(), lbm_errdesc);
                                exit(1);
                        }
                }
@@ -552,54 +561,60 @@ int main(int argc, char *argv[])
                        fake_port = atoi(port); 
                }
 
-               dprintf(("Server address: %s:%d\n", fake_host, fake_port));
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Server address: %s:%d", fake_host, fake_port);
        }
        if ((mode & SERVICE_SERVER)) {
                service_table[SRV_SERVE].conn = socket(PF_INET, SOCK_STREAM, 0);
-               if ( service_table[SRV_SERVE].conn < 0 ) { perror("socket()"); return 1; }
+               if ( service_table[SRV_SERVE].conn < 0 ) { 
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "socket()");
+                       return 1; 
+               }
                a.sin_family = AF_INET;
                a.sin_port = htons(atoi(port));
                a.sin_addr.s_addr = INADDR_ANY;
                setsockopt(service_table[SRV_SERVE].conn, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
                if ( bind(service_table[SRV_SERVE].conn, (struct sockaddr *) &a, sizeof(a)) )
                { 
-                       char    buf[100];
-
-                       snprintf(buf,sizeof(buf),"bind(%d)",atoi(port));
-                       perror(buf);
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "bind(%d)",atoi(port));
                        return 1;
                }
-               if ( listen(service_table[SRV_SERVE].conn, CON_QUEUE) ) { perror("listen()"); return 1; }
+               if ( listen(service_table[SRV_SERVE].conn, CON_QUEUE) ) { 
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "listen()");
+                       return 1; 
+               }
 
                service_table[SRV_STORE].conn = socket(PF_INET, SOCK_STREAM, 0);
-               if ( service_table[SRV_STORE].conn < 0) { perror("socket()"); return 1; }
+               if ( service_table[SRV_STORE].conn < 0) { 
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "socket()");
+                       return 1; 
+               }
                a.sin_family = AF_INET;
                a.sin_port = htons(atoi(port)+1);
                a.sin_addr.s_addr = INADDR_ANY;
                setsockopt(service_table[SRV_STORE].conn, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
                if ( bind(service_table[SRV_STORE].conn, (struct sockaddr *) &a, sizeof(a)))
                {
-                       char    buf[100];
-
-                       snprintf(buf,sizeof(buf), "bind(%d)", atoi(port)+1);
-                       perror(buf);
+                        glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "bind(%d)", atoi(port)+1);
                        return 1;
                }
-               if ( listen(service_table[SRV_STORE].conn, CON_QUEUE) ) { perror("listen()"); return 1; }
+               if ( listen(service_table[SRV_STORE].conn, CON_QUEUE) ) { 
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "listen()"); 
+                       return 1; 
+               }
 
 #ifdef GLITE_LB_SERVER_WITH_WS
                service_table[SRV_WS].conn = socket(PF_INET, SOCK_STREAM, 0);
-               if ( service_table[SRV_WS].conn < 0) { perror("socket()"); return 1; }
+               if ( service_table[SRV_WS].conn < 0) { 
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "socket()");
+                       return 1; 
+               }
                a.sin_family = AF_INET;
                a.sin_port = htons(atoi(ws_port));
                a.sin_addr.s_addr = INADDR_ANY;
                setsockopt(service_table[SRV_WS].conn, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
                if ( bind(service_table[SRV_WS].conn, (struct sockaddr *) &a, sizeof(a)))
                {
-                       char    buf[100];
-
-                       snprintf(buf, sizeof(buf), "bind(%d)", atoi(ws_port));
-                       perror(buf);
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "bind(%d)", atoi(ws_port));
                        return 1;
                }
                if ( listen(service_table[SRV_WS].conn, CON_QUEUE) ) { perror("listen()"); return 1; }
@@ -607,8 +622,7 @@ int main(int argc, char *argv[])
 #endif /* GLITE_LB_SERVER_WITH_WS */
 
                if (!server_cert || !server_key)
-                       fprintf(stderr, "%s: key or certificate file not specified"
-                                                       " - unable to watch them for changes!\n", argv[0]);
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "%s: key or certificate file not specified  - unable to watch them for changes!", argv[0]);
 
                if ( cadir ) setenv("X509_CERT_DIR", cadir, 1);
                edg_wll_gss_watch_creds(server_cert, &cert_mtime);
@@ -616,7 +630,7 @@ int main(int argc, char *argv[])
                {
                        int     i;
 
-                       dprintf(("Server identity: %s\n",mycred->name));
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Server identity: %s", mycred->name);
                        server_subject = strdup(mycred->name);
                        for ( i = 0; super_users && super_users[i]; i++ ) ;
                        super_users = realloc(super_users, (i+2)*sizeof(*super_users));
@@ -624,15 +638,18 @@ int main(int argc, char *argv[])
                        super_users[i+1] = NULL;
                }
                else {
-                       dprintf(("Server running unauthenticated\n"));
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "Server running unauthenticated");
                        server_subject = strdup("anonymous LB");
                }
 
-               if ( noAuth ) dprintf(("Server in promiscuous mode\n"));
-               dprintf(("Server listening at %d,%d (accepting protocols: " COMP_PROTO " and compatible) ...\n",atoi(port),atoi(port)+1));
+               if ( noAuth ) 
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Server in promiscuous mode");
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, 
+                       "Server listening at %d,%d (accepting protocols: " COMP_PROTO " and compatible) ...", atoi(port), atoi(port)+1);
 
 #ifdef GLITE_LB_SERVER_WITH_WS
-               dprintf(("Server listening at %d (accepting web service protocol) ...\n", atoi(ws_port)));
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO,
+               "Server listening at %d (accepting web service protocol) ...", atoi(ws_port));
 #endif /* GLITE_LB_SERVER_WITH_WS */
 
        }
@@ -640,7 +657,10 @@ int main(int argc, char *argv[])
                struct sockaddr_un      a;
 
                service_table[SRV_SERVE_PROXY].conn = socket(PF_UNIX, SOCK_STREAM, 0);
-               if ( service_table[SRV_SERVE_PROXY].conn < 0 ) { perror("socket()"); return 1; }
+               if ( service_table[SRV_SERVE_PROXY].conn < 0 ) { 
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "socket()");
+                       return 1; 
+               }
                memset(&a, 0, sizeof(a));
                a.sun_family = AF_UNIX;
                sprintf(sock_serve, "%s%s", socket_path_prefix, "serve.sock");
@@ -648,23 +668,29 @@ int main(int argc, char *argv[])
 
                if( connect(service_table[SRV_SERVE_PROXY].conn, (struct sockaddr *)&a, sizeof(a.sun_path)) < 0) {
                        if( errno == ECONNREFUSED ) {
-                               dprintf(("removing stale input socket %s\n", sock_serve));
+                               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "removing stale input socket %s", sock_serve);
                                unlink(sock_serve);
                        }
-               } else { perror("another instance of lb-proxy is running"); return 1; }
+               } else { 
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "another instance of lb-proxy is running");
+                       return 1; 
+               }
 
                if ( bind(service_table[SRV_SERVE_PROXY].conn, (struct sockaddr *) &a, sizeof(a)) < 0 ) {
-                       char    buf[100];
-
-                       snprintf(buf, sizeof(buf), "bind(%s)", sock_serve);
-                       perror(buf);
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "bind(%s)", sock_serve);
                        return 1;
                }
 
-               if ( listen(service_table[SRV_SERVE_PROXY].conn, con_queue) ) { perror("listen()"); return 1; }
+               if ( listen(service_table[SRV_SERVE_PROXY].conn, con_queue) ) { 
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "listen()");
+                       return 1; 
+               }
 
                service_table[SRV_STORE_PROXY].conn = socket(PF_UNIX, SOCK_STREAM, 0);
-               if ( service_table[SRV_STORE_PROXY].conn < 0 ) { perror("socket()"); return 1; }
+               if ( service_table[SRV_STORE_PROXY].conn < 0 ) { 
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "socket()");
+                       return 1; 
+               }
                memset(&a, 0, sizeof(a));
                a.sun_family = AF_UNIX;
                sprintf(sock_store, "%s%s", socket_path_prefix, "store.sock");
@@ -672,21 +698,25 @@ int main(int argc, char *argv[])
 
                if( connect(service_table[SRV_STORE_PROXY].conn, (struct sockaddr *)&a, sizeof(a.sun_path)) < 0) {
                        if( errno == ECONNREFUSED ) {
-                               dprintf(("removing stale input socket %s\n", sock_store));
+                               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "removing stale input socket %s", sock_store);
                                unlink(sock_store);
                        }
-               } else { perror("another instance of lb-proxy is running"); return 1; }
+               } else { 
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "another instance of lb-proxy is running");
+                       return 1; 
+               }
 
                if ( bind(service_table[SRV_STORE_PROXY].conn, (struct sockaddr *) &a, sizeof(a))) {
-                       char    buf[100];
-
-                       snprintf(buf, sizeof(buf), "bind(%s)", sock_store);
-                       perror(buf);
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "bind(%s)", sock_store);
+                       
                        return 1;
                }
-               if ( listen(service_table[SRV_STORE_PROXY].conn, con_queue) ) { perror("listen()"); return 1; }
+               if ( listen(service_table[SRV_STORE_PROXY].conn, con_queue) ) { 
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "listen()");
+                       return 1; 
+               }
 
-               dprintf(("Proxy listening at %s, %s ...\n", sock_store, sock_serve));
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Proxy listening at %s, %s ...", sock_store, sock_serve);
        }
 
        if (!dbstring) dbstring = getenv("LBDB");
@@ -704,22 +734,22 @@ int main(int argc, char *argv[])
                char    *et,*ed;
                glite_lbu_DBError(ctx->dbctx,&et,&ed);
 
-               fprintf(stderr,"%s: open database: %s (%s)\n",argv[0],et,ed);
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "%s: open database: %s (%s)", argv[0], et, ed);
                free(et); free(ed);
                return 1;
        }
        edg_wll_Close(ctx);
        ctx->dbctx = NULL;
-       fprintf(stderr, "[%d]: DB '%s'\n", getpid(), dbstring);
+       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "[%d]: DB '%s'", getpid(), dbstring);
 
        if ((ctx->dbcaps & GLITE_LBU_DB_CAP_INDEX) == 0) {
-               fprintf(stderr,"%s: missing index support in DB layer\n",argv[0]);
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "%s: missing index support in DB layer", argv[0]);
                return 1;
        }
        if ((ctx->dbcaps & GLITE_LBU_DB_CAP_TRANSACTIONS) == 0)
-               fprintf(stderr, "[%d]: transactions aren't supported!\n", getpid());
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "[%d]: transactions aren't supported!", getpid());
        if (transactions >= 0) {
-               fprintf(stderr, "[%d]: transactions forced from %d to %d\n", getpid(), ctx->dbcaps & GLITE_LBU_DB_CAP_TRANSACTIONS ? 1 : 0, transactions);
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "[%d]: transactions forced from %d to %d", getpid(), ctx->dbcaps & GLITE_LBU_DB_CAP_TRANSACTIONS ? 1 : 0, transactions);
                ctx->dbcaps &= ~GLITE_LBU_DB_CAP_TRANSACTIONS;
                ctx->dbcaps |= transactions ? GLITE_LBU_DB_CAP_TRANSACTIONS : 0;
        }
@@ -730,7 +760,7 @@ int main(int argc, char *argv[])
 
        if ( !debug ) {
                if (daemon(1,0) == -1) {
-                       perror("deamon()");
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "deamon()");
                        exit(1);
                }
 #ifdef LB_PERF
@@ -741,8 +771,6 @@ int main(int argc, char *argv[])
                if (!fpid) { perror(pidfile); return 1; }
                fprintf(fpid,"%d",getpid());
                fclose(fpid);
-
-               openlog(name,LOG_PID,LOG_DAEMON);
        } else {
                setpgid(0, getpid());
        }
@@ -856,7 +884,7 @@ int bk_clnt_data_init(void **data)
                return -1;
        }
 
-       dprintf(("[%d] opening database ...\n", getpid()));
+       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "[%d] opening database ...", getpid());
        wait_for_open(ctx, dbstring);
        glite_lbu_DBSetCaps(ctx->dbctx, use_dbcaps);
        cdata->dbctx = ctx->dbctx;
@@ -867,8 +895,8 @@ int bk_clnt_data_init(void **data)
                char       *et, *ed;
 
                edg_wll_Error(ctx,&et,&ed);
-               dprintf(("[%d]: query_job_indices(): %s: %s, no custom indices available\n",getpid(),et,ed));
-               if (!debug) syslog(LOG_ERR,"[%d]: query_job_indices(): %s: %s, no custom indices available\n",getpid(),et,ed);
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "[%d]: query_job_indices(): %s: %s, no custom indices available", getpid(), et, ed);
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_DEBUG, "[%d]: query_job_indices(): %s: %s, no custom indices available", getpid(), et, ed);
                free(et);
                free(ed);
        }
@@ -879,7 +907,9 @@ int bk_clnt_data_init(void **data)
                char    *et,*ed;
                edg_wll_Error(ctx,&et,&ed);
 
-               dprintf(("[%d]: query notif indices: %s: %s\n",getpid(),et,ed));
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "[%d]: query notif indices: %s: %s", getpid(), et, ed);
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_DEBUG, "[%d]: query notif indices: %s: %s", getpid(), et, ed);      
+       
                free(et); free(ed);
        }
        cdata->notif_index = notif_index;
@@ -923,17 +953,22 @@ int bk_handle_connection(int conn, struct timeval *timeout, void *data)
        case 0: break;
        case 1:
                if ( !edg_wll_gss_acquire_cred_gsi(server_cert, server_key, &newcred, &gss_code) ) {
-                       dprintf(("[%d] reloading credentials successful\n", getpid()));
+                       glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_INFO, "[%d] reloading credentials successful", getpid());
                        edg_wll_gss_release_cred(&mycred, NULL);
                        mycred = newcred;
-               } else { dprintf(("[%d] reloading credentials failed, using old ones\n", getpid())); }
+               } else { 
+                       glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_ERROR, "[%d] reloading credentials failed, using old ones");
+               }
+               break;
+       case -1: 
+               glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_ERROR, "[%d] edg_wll_gss_watch_creds failed", getpid());
                break;
-       case -1: dprintf(("[%d] edg_wll_gss_watch_creds failed\n", getpid())); break;
        }
 
        if ( edg_wll_InitContext(&ctx) )
        {
-               fprintf(stderr, "Couldn't create context");
+               //fprintf(stderr, "Couldn't create context");
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "Couldn't create context");
                return -1;
        }
        cdata->ctx = ctx;
@@ -983,16 +1018,16 @@ int bk_handle_connection(int conn, struct timeval *timeout, void *data)
        switch ( h_errno )
        {
        case NETDB_SUCCESS:
-               if (name) dprintf(("[%d] connection from %s:%d (%s)\n",
-                                       getpid(), inet_ntoa(a.sin_addr), ntohs(a.sin_port), name));
+               if (name) 
+                       glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_INFO, "[%d] connection from %s:%d (%s)", getpid(), inet_ntoa(a.sin_addr), ntohs(a.sin_port), name); 
                free(ctx->connections->serverConnection->peerName);
                ctx->connections->serverConnection->peerName = name;
                name = NULL;
                break;
 
        default:
-               if (debug) fprintf(stderr, "gethostbyaddr(%s): %s", inet_ntoa(a.sin_addr), hstrerror(h_errno));
-               dprintf(("[%d] connection from %s:%d\n", getpid(), inet_ntoa(a.sin_addr), ntohs(a.sin_port)));
+               glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_DEBUG, "gethostbyaddr(%s): %s", inet_ntoa(a.sin_addr), hstrerror(h_errno));
+               glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_INFO,"[%d] connection from %s:%d", getpid(), inet_ntoa(a.sin_addr), ntohs(a.sin_port));
                free(ctx->connections->serverConnection->peerName);
                ctx->connections->serverConnection->peerName = strdup(inet_ntoa(a.sin_addr));
                break;
@@ -1001,8 +1036,7 @@ int bk_handle_connection(int conn, struct timeval *timeout, void *data)
        gettimeofday(&now, 0);
        if ( decrement_timeout(timeout, conn_start, now) )
        {
-               if (debug) fprintf(stderr, "gethostbyaddr() timeout");
-               else syslog(LOG_ERR, "gethostbyaddr(): timeout");
+               glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_ERROR, "gethostbyaddr() timeout"); 
                free(name);
 
                return -1;
@@ -1032,20 +1066,14 @@ int bk_handle_connection(int conn, struct timeval *timeout, void *data)
                        {
                                if ( strcmp(name, server_name))
                                {
-                                       if (debug) fprintf(stderr, "different server endpoint names (%s,%s),"
-                                                                                       " check DNS PTR records\n", name, server_name);
-                                       else syslog(LOG_ERR,"different server endpoint names (%s,%s),"
-                                                                                       " check DNS PTR records\n", name, server_name);
+                                       glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_ERROR, "different server endpoint names (%s,%s), check DNS PTR records", name, server_name);
                                }
                        }
                        else server_name = strdup(name);
                        break;
 
                default:
-                       if ( debug )
-                               fprintf(stderr, "gethostbyaddr(%s): %s", inet_ntoa(a.sin_addr), hstrerror(h_errno));
-                       else
-                               syslog(LOG_ERR,"gethostbyaddr(%s): %s", inet_ntoa(a.sin_addr), hstrerror(h_errno));
+                               glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_ERROR, "gethostbyaddr(%s): %s", inet_ntoa(a.sin_addr), hstrerror(h_errno));
                        if ( server_name != NULL )
                                ctx->srvName = strdup(server_name);
                        break;
@@ -1063,25 +1091,20 @@ int bk_handle_connection(int conn, struct timeval *timeout, void *data)
        {
                if ( ret == EDG_WLL_GSS_ERROR_TIMEOUT )
                {
-                       dprintf(("[%d] %s: Client authentication failed - timeout reached, closing.\n", getpid(),ctx->connections->serverConnection->peerName));
-                       if (!debug) syslog(LOG_ERR, "%s: Client authentication failed - timeout reached",ctx->connections->serverConnection->peerName);
+                       glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_WARN, "[%d] %s: Client authentication failed - timeout reached, closing.", getpid(),ctx->connections->serverConnection->peerName);
                }
                else if (ret == EDG_WLL_GSS_ERROR_GSS) {
                        edg_wll_SetErrorGss(ctx,"Client authentication",&gss_code);
                        if (strstr(ctx->errDesc,_EXPIRED_CERTIFICATE_MESSAGE)) {
-                               dprintf(("[%d] %s: false expired certificate: %s\n",getpid(),ctx->connections->serverConnection->peerName,ctx->errDesc));
-                               if (!debug) syslog(LOG_ERR,"[%d] %s: false expired certificate: %s",getpid(),ctx->connections->serverConnection->peerName,ctx->errDesc);
+                               glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_WARN, "[%d] %s: false expired certificate: %s",getpid(),ctx->connections->serverConnection->peerName,ctx->errDesc);
                                edg_wll_FreeContext(ctx);
                                return -1;
                        }
-                       dprintf(("[%d] %s: GSS error: %s, closing.\n", getpid(),ctx->connections->serverConnection->peerName,ctx->errDesc));
-                       if (!debug) syslog(LOG_ERR, "%s: GSS error: %s",ctx->connections->serverConnection->peerName,ctx->errDesc);
+                       glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_ERROR, "[%d] %s: GSS error: %s", getpid(), ctx->connections->serverConnection->peerName, ctx->errDesc);
                }
                else
                {
-                       dprintf(("[%d] %s: Client authentication failed, closing.\n", getpid(),ctx->connections->serverConnection->peerName));
-                       if (!debug) syslog(LOG_ERR, "%s: Client authentication failed",ctx->connections->serverConnection->peerName);
-
+                        glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_WARN, "[%d] %s: Client authentication failed", getpid(), ctx->connections->serverConnection->peerName);
                }
                edg_wll_FreeContext(ctx);
                return 1;
@@ -1089,14 +1112,13 @@ int bk_handle_connection(int conn, struct timeval *timeout, void *data)
 
        ret = edg_wll_gss_get_client_conn(&ctx->connections->serverConnection->gss, &client, NULL);
        if (ret || client->flags & EDG_WLL_GSS_FLAG_ANON) {
-               dprintf(("[%d] anonymous client\n",getpid()));
+               glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_INFO, "[%d] anonymous client",getpid());
                ctx->peerName = NULL;
        } else {
                if (ctx->peerName) free(ctx->peerName);
                ctx->peerName = strdup(client->name);
                edg_wll_gss_free_princ(client);
-
-               dprintf(("[%d] client DN: %s\n",getpid(),ctx->peerName));
+               glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_INFO, "[%d] client DN: %s",getpid(),ctx->peerName);
        }
 
        if ( edg_wll_SetVomsGroups(ctx, &ctx->connections->serverConnection->gss, server_cert, server_key, vomsdir, cadir) )
@@ -1104,25 +1126,25 @@ int bk_handle_connection(int conn, struct timeval *timeout, void *data)
                char *errt, *errd;
 
                edg_wll_Error(ctx, &errt, &errd);
-               dprintf(("[%d] %s (%s)\n[%d]\tignored, continuing without VOMS\n", getpid(), errt, errd,getpid()));
+               glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_INFO, "[%d] %s (%s)\n[%d]\tignored, continuing without VOMS", getpid(), errt, errd,getpid());
                free(errt); free(errd);
                edg_wll_ResetError(ctx); 
        }
-       if (debug && ctx->vomsGroups.len > 0)
+       if (ctx->vomsGroups.len > 0)
        {
                int i;
   
-               dprintf(("[%d] client's VOMS groups:\n",getpid()));
+                glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_DEBUG, "[%d] client's VOMS groups:",getpid());
                for ( i = 0; i < ctx->vomsGroups.len; i++ )
-                       dprintf(("\t%s:%s\n", ctx->vomsGroups.val[i].vo, ctx->vomsGroups.val[i].name));
+                       glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_DEBUG, "\t%s:%s", ctx->vomsGroups.val[i].vo, ctx->vomsGroups.val[i].name);
        }
-       if (debug && ctx->fqans && *(ctx->fqans))
+       if (ctx->fqans && *(ctx->fqans))
        {
                char **f;
 
-               dprintf(("[%d] client's FQANs:\n",getpid()));
+               glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_DEBUG, "[%d] client's FQANs:",getpid());
                for (f = ctx->fqans; f && *f; f++)
-                       dprintf(("\t%s\n", *f));
+                       glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_DEBUG, "\t%s", *f);
        }
        
        /* used also to reset start_time after edg_wll_ssl_accept! */
@@ -1151,24 +1173,28 @@ int bk_init_ws_connection(struct clnt_data_t *cdata)
        int err = 0;
 
        if ( glite_gsplugin_init_context(&gsplugin_ctx) ) {
-                fprintf(stderr, "Couldn't create gSOAP plugin context");
+               glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_ERROR, 
+                       "Couldn't create gSOAP plugin context");
                 return -1;
         }
 
         if ( !(soap = soap_new()) ) {
-                fprintf(stderr, "Couldn't create soap environment");
+               glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_ERROR,
+                       "Couldn't create soap environment");
                 goto err;
         }
 
         soap_init2(soap, SOAP_IO_KEEPALIVE, SOAP_IO_KEEPALIVE);
        if ( soap_set_namespaces(soap, namespaces) ) { 
                 soap_done(soap);
-                perror("Couldn't set soap namespaces");
+               glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_ERROR,
+                       "Couldn't set soap namespaces");
                 goto err;
         }
        if ( soap_register_plugin_arg(soap, glite_gsplugin, gsplugin_ctx) ) {
                 soap_done(soap);
-                perror("Couldn't set soap namespaces");
+               glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_ERROR,
+                       "Couldn't set soap namespaces");
                 goto err;
         }
 
@@ -1217,7 +1243,8 @@ int bk_handle_connection_proxy(int conn, struct timeval *timeout, void *data)
        struct timeval          conn_start, now;
 
         if ( edg_wll_InitContext(&ctx) ) {
-               dprintf(("Couldn't create context"));
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR,
+                       "Couldn't create context");
                return -1;
        }
        cdata->ctx = ctx;
@@ -1254,7 +1281,8 @@ int bk_handle_connection_proxy(int conn, struct timeval *timeout, void *data)
        
        ctx->connProxy = (edg_wll_ConnProxy *) calloc(1, sizeof(edg_wll_ConnProxy));
        if ( !ctx->connProxy ) {
-               perror("calloc");
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR,
+                       "calloc");
                edg_wll_FreeContext(ctx);
 
                return -1;
@@ -1262,7 +1290,8 @@ int bk_handle_connection_proxy(int conn, struct timeval *timeout, void *data)
 
        gettimeofday(&conn_start, 0);
        if ( edg_wll_plain_accept(conn, &ctx->connProxy->conn) ) {
-               perror("accept");
+               glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_ERROR,
+                       "accept");
                edg_wll_FreeContext(ctx);
 
                return -1;
@@ -1270,9 +1299,8 @@ int bk_handle_connection_proxy(int conn, struct timeval *timeout, void *data)
 
        gettimeofday(&now, 0);
        if ( decrement_timeout(timeout, conn_start, now) ) {
-               if (debug) fprintf(stderr, "edg_wll_plain_accept() timeout");
-               else syslog(LOG_ERR, "edg_wll_plain_accept(): timeout");
-
+               glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_WARN,
+                       "edg_wll_plain_accept(): timeout");
                return -1;
        }
 
@@ -1296,8 +1324,8 @@ static int handle_server_error(edg_wll_Context ctx)
        case EPIPE:
        case EIO:
        case EDG_WLL_IL_PROTO:
-               dprintf(("[%d] %s (%s)\n", getpid(), errt, errd));
-               if (!debug) syslog(LOG_ERR,"%s (%s)", errt, errd);
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN,
+                       "[%d] %s (%s)", getpid(), errt, errd);
                /*      fallthrough
                 */
        case ENOTCONN:
@@ -1313,7 +1341,8 @@ static int handle_server_error(edg_wll_Context ctx)
        case EEXIST:
        case EDG_WLL_ERROR_NOINDEX:
        case E2BIG:
-               dprintf(("[%d] %s (%s)\n", getpid(), errt, errd));
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR,
+                       "[%d] %s (%s)", getpid(), errt, errd);
                break;
        case EINVAL:
        case EDG_WLL_ERROR_PARSE_BROKEN_ULM:
@@ -1324,8 +1353,8 @@ static int handle_server_error(edg_wll_Context ctx)
        case EDG_WLL_ERROR_PARSE_OK_WITH_EXTRA_FIELDS:
        case EDG_WLL_ERROR_JOBID_FORMAT:
        case EDG_WLL_ERROR_MD5_CLASH:
-               dprintf(("[%d] %s (%s)\n", getpid(), errt, errd));
-               if ( !debug ) syslog(LOG_ERR,"%s (%s)", errt, errd);
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR,
+                       "[%d] %s (%s)", getpid(), errt, errd);
                /*
                 *      no action for non-fatal errors
                 */
@@ -1335,8 +1364,8 @@ static int handle_server_error(edg_wll_Context ctx)
        case EDG_WLL_ERROR_DB_CALL:
        case EDG_WLL_ERROR_SERVER_RESPONSE:
        default:
-               dprintf(("[%d] %s (%s)\n", getpid(), errt, errd));
-               if (!debug) syslog(LOG_CRIT,"%s (%s)",errt,errd);
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL,
+               "[%d] %s (%s)", getpid(), errt, errd);
                /*
                 *      unknown error - do rather return (<0) (slave will be killed)
                 */
@@ -1361,8 +1390,8 @@ int bk_accept_store(int conn, struct timeval *timeout, void *cdata)
 
        gettimeofday(&after, NULL);
        if ( decrement_timeout(timeout, before, after) ) {
-               if (debug) fprintf(stderr, "Serving store connection timed out");
-               else syslog(LOG_ERR, "Serving store connection timed out");
+               glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_WARN,
+                       "Serving store connection timed out");
                return ETIMEDOUT;
        }
 
@@ -1435,8 +1464,9 @@ int bk_accept_serve(int conn, struct timeval *timeout, void *cdata)
 
        gettimeofday(&after, NULL);
        if ( decrement_timeout(timeout, before, after) ) {
-               if (debug) fprintf(stderr, "Serving store connection timed out");
-               else syslog(LOG_ERR, "Serving store connection timed out");
+               glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_WARN,
+                       "Serving store connection timed out");
+               
                return ETIMEDOUT;
        }
 
@@ -1491,8 +1521,8 @@ int bk_accept_ws(int conn, struct timeval *timeout, void *cdata)
 
        if ( err ) {
                // soap_print_fault(struct soap *soap, FILE *fd) maybe useful here
-               dprintf(("[%d] SOAP error (bk_accept_ws) \n", getpid()));
-               if (!debug) syslog(LOG_CRIT,"SOAP error (bk_accept_ws)");
+               glite_common_log(LOG_CATEGORY_ACCESS, LOG_PRIORITY_ERROR,
+                       "[%d] SOAP error (bk_accept_ws)", getpid());
                return ECANCELED;
        }
 
@@ -1587,14 +1617,14 @@ static int wait_for_open(edg_wll_Context ctx, const char *dbstring)
        while (((err = edg_wll_Open(ctx, (char *) dbstring)) != EDG_WLL_ERROR_DB_INIT) && err) {
                if (dbfail_string1) free(dbfail_string1);
                edg_wll_Error(ctx,&errt,&errd);
-               asprintf(&dbfail_string1,"%s (%s)\n",errt,errd);
+               asprintf(&dbfail_string1,"%s (%s)",errt,errd);
                if (dbfail_string1 != NULL) {
                        if (dbfail_string2 == NULL || strcmp(dbfail_string1,dbfail_string2)) {
                                if (dbfail_string2) free(dbfail_string2);
                                dbfail_string2 = dbfail_string1;
                                dbfail_string1 = NULL;
-                               dprintf(("[%d]: %s\nStill trying ...\n",getpid(),dbfail_string2));
-                               if (!debug) syslog(LOG_ERR,dbfail_string2);
+                               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "[%d]: %s\nStill trying ...",getpid(),dbfail_string2);
+                               
                        }
                }
                sleep(5);
@@ -1603,15 +1633,15 @@ static int wait_for_open(edg_wll_Context ctx, const char *dbstring)
        if (dbfail_string1) free(dbfail_string1);
        if (dbfail_string2 != NULL) {
                free(dbfail_string2);
-               dprintf(("[%d]: DB connection established\n",getpid()));
-               if (!debug) syslog(LOG_INFO,"DB connection established\n");
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO,
+                       "[%d]: DB connection established",getpid());
        }
 
        if (err) {
                edg_wll_Error(ctx,&errt,&errd);
-               asprintf(&dbfail_string1,"%s (%s)\n",errt,errd);
-               dprintf(("[%d]: %s\n", getpid(), dbfail_string1));
-               if (!debug) syslog(LOG_ERR,dbfail_string1);
+               asprintf(&dbfail_string1,"%s (%s)",errt,errd);
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR,
+                       "[%d]: %s", getpid(), dbfail_string1);
                free(dbfail_string1);
        }
 
@@ -1772,8 +1802,8 @@ static int read_roots(const char *file)
        char    buf[BUFSIZ];
 
        if (!roots) {
-               syslog(LOG_WARNING,"%s: %m, continuing without --super-users-file",file);
-               dprintf(("%s: %s, continuing without --super-users-file\n",file,strerror(errno)));
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN,
+                       "%s: %s, continuing without --super-users-file",file,strerror(errno));
                return 0;
        }
 
@@ -1805,30 +1835,28 @@ static int check_mkdir(const char *dir)
                {
                        if ( mkdir(dir, S_IRWXU) )
                        {
-                               dprintf(("[%d] %s: %s\n", getpid(), dir, strerror(errno)));
-                               if (!debug) syslog(LOG_CRIT, "%s: %m", dir);
+                               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "[%d] %s: %s", getpid(), dir, strerror(errno));
                                return 1;
                        }
                }
                else
                {
-                       dprintf(("[%d] %s: %s\n", getpid(), dir, strerror(errno)));
-                       if (!debug) syslog(LOG_CRIT, "%s: %m", dir);
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "[%d] %s: %s", getpid(), dir, strerror(errno));
                        return 1;
                }
        }
 
        if (!S_ISDIR(sbuf.st_mode))
        {
-               dprintf(("[%d] %s: not a directory\n", getpid(),dir));
-               if (!debug) syslog(LOG_CRIT,"%s: not a directory",dir);
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN,
+                       "[%d] %s: not a directory", getpid(),dir);
                return 1;
        }
 
        if (access(dir, R_OK | W_OK))
        {
-               dprintf(("[%d] %s: directory is not readable/writable\n", getpid(),dir));
-               if (!debug) syslog(LOG_CRIT,"%s: directory is not readable/writable",dir);
+                glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN,
+                       "[%d] %s: directory is not readable/writable", getpid(),dir);
                return 1;
        }
                
index 4725cb6..ab1fab8 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "glite/jobid/cjobid.h"
 #include "glite/lbu/trio.h"
+#include "glite/lbu/log.h"
 
 #include "glite/lb/context-int.h"
 
@@ -26,10 +27,12 @@ int edg_wll_jobMembership(edg_wll_Context ctx, glite_jobid_const_t job)
         dbjob = edg_wlc_JobIdGetUnique(job);
 
         trio_asprintf(&stmt,"select proxy,server from jobs where jobid = '%|Ss' for update",dbjob);
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
         ret = edg_wll_ExecSQL(ctx,stmt,&q);
         if (ret <= 0) {
                 if (ret == 0) {
-                        fprintf(stderr,"%s: no such job\n",dbjob);
+                       glite_common_log(LOG_CATEGORY_CONTROL, 
+                               LOG_PRIORITY_WARN, "%s: no such job",dbjob);
                         edg_wll_SetError(ctx,ENOENT,dbjob);
                 }
                 goto clean;
@@ -42,7 +45,7 @@ int edg_wll_jobMembership(edg_wll_Context ctx, glite_jobid_const_t job)
                 if (strcmp(res[1],"0")) result += DB_SERVER_JOB;
         }
         else {
-               fprintf(stderr,"Error retrieving proxy&server fields of jobs table. Missing column?\n");
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "Error retrieving proxy&server fields of jobs table. Missing column?");
                 edg_wll_SetError(ctx,ENOENT,dbjob);
         }
         glite_lbu_FreeStmt(&q);
@@ -72,6 +75,7 @@ int edg_wll_LockJobRow(edg_wll_Context ctx, const char *job, int lock_mode)
        else
                trio_asprintf(&stmt, "select * from jobs where jobid='%|Ss' lock in share mode", job);
 
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
        if ((nr = edg_wll_ExecSQL(ctx,stmt,&sh)) < 0) goto cleanup;
        if (nr == 0) {
                char *err;
index 3577037..2ed512d 100644 (file)
@@ -4,9 +4,9 @@
 #include <unistd.h>
 #include <stdio.h>
 
-
 #include "glite/lbu/db.h"
 #include "glite/lb/context-int.h"
+#include "glite/lbu/log.h"
 
 extern int     debug;  // declared and set in bkserver.c
 
@@ -98,21 +98,18 @@ int edg_wll_TransNeedRetry(edg_wll_Context ctx) {
        ret = edg_wll_Error(ctx,NULL,NULL);
 
        if (ret == EDG_WLL_ERROR_DB_TRANS_DEADLOCK) {
-               if (debug)
-                       printf("[%d]: DB deadlock detected. Rolling back transaction and retrying... \n",getpid());
-               else 
-                       syslog(LOG_INFO,"[%d]: DB deadlock detected. Rolling back transaction and retrying... \n",getpid());
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, 
+                       "[%d]: DB deadlock detected. Rolling back transaction "
+                       "and retrying... \n", getpid());
 
                edg_wll_ResetError(ctx);
                return !edg_wll_Rollback(ctx);
        }
        if (ret == EDG_WLL_ERROR_DB_LOST_CONNECTION) {
-               if (debug)
-                       printf("[%d]: Lost connection to DB. "
-                               "Rolling back transaction and retrying... \n",getpid());
-               else 
-                       syslog(LOG_INFO,"[%d]: Lost connection to DB. "
-                               "Rolling back transaction and retrying... \n",getpid());
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, 
+                       "[%d]: Lost connection to DB. "
+                       "Rolling back transaction and retrying... \n",
+                       getpid());
 
                edg_wll_ResetError(ctx);
                return !edg_wll_Rollback(ctx);
index 1b6771e..e4889a8 100644 (file)
@@ -3,13 +3,13 @@
 #include <time.h>
 #include <stdio.h>
 #include <string.h>
-#include <syslog.h>
 #include <assert.h>
 #include <unistd.h>
 #include <errno.h>
 
 #include "glite/lbu/trio.h"
 #include "glite/jobid/cjobid.h"
+#include  "glite/lbu/log.h"
 
 #include "glite/lb/context-int.h"
 #include "glite/lb/events_parse.h"
@@ -68,7 +68,8 @@ int edg_wll_DumpEventsServer(edg_wll_Context ctx,const edg_wll_DumpRequest *req,
                        "order by arrived",
                        ctx->srvName,ctx->srvPort,
                        from_s,to_s);
-
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
+       
        if (edg_wll_ExecSQL(ctx,stmt,&q) < 0) goto clean;
 
        while ((ret = edg_wll_FetchRow(ctx,q,sizeof(res)/sizeof(res[0]),NULL,res)) > 0) {
@@ -85,8 +86,7 @@ int edg_wll_DumpEventsServer(edg_wll_Context ctx,const edg_wll_DumpRequest *req,
                 * Must not be fatal -- just complain
                 */
                        edg_wll_Error(ctx,&et,&ed);
-                       fprintf(stderr,"%s event %d: %s (%s)\n",res[1],event,et,ed);
-                       syslog(LOG_WARNING,"%s event %d: %s (%s)",res[1],event,et,ed);
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "%s event %d: %s (%s)", res[1], event, et, ed);
                        free(et); free(ed);
                        for (i=0; i<sizofa(res); i++) free(res[i]);
                        edg_wll_ResetError(ctx);
index 29ab93b..2dc4be0 100644 (file)
@@ -1,11 +1,12 @@
 #ident "$Header$"
 
-#include <syslog.h>
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>
+
 #include "glite/lb/context-int.h"
 #include "glite/lb/log_proto.h"
+#include "glite/lbu/log.h"
 
 #include "il_lbproxy.h"
 
@@ -61,7 +62,8 @@ edg_wll_EventSendProxy(
        
                edg_wll_UpdateError(ctx, EDG_WLL_IL_PROTO, "edg_wll_log_event_send()");
                edg_wll_Error(ctx, &errt, &errd);
-               syslog(LOG_ERR,"%s (%s)", errt, errd);
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, 
+                       "%s (%s)", errt, errd);
                free(errt); free(errd);
                _err(-1);
        }
index a9708db..8422242 100644 (file)
 #include <string.h>
 #include <errno.h>
 #include <stdio.h>
-#include <syslog.h>
 
 #include "glite/lbu/escape.h"
 #include "glite/lb/context-int.h"
 #include "glite/lb/notifid.h"
 #include "glite/lb/events_parse.h"
 #include "glite/lb/log_proto.h"
+#include "glite/lbu/log.h"
 
 #include "il_notification.h"
 #include "lb_xml_parse.h"
@@ -183,8 +183,8 @@ edg_wll_NotifJobStatus(edg_wll_Context      context,
 
                if(ret) edg_wll_UpdateError(context, ret, "edg_wll_NotifJobStatus()");
                edg_wll_Error(context,&et,&ed);
-               fprintf(stderr,"%s - %s\n", ed, et);
-               syslog(LOG_INFO,"%s - %s\n", ed, et);
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, 
+                       "%s - %s\n", ed, et);
                edg_wll_ResetError(context);
                free(et); 
                free(ed);
index 664c44d..761d305 100644 (file)
@@ -8,13 +8,13 @@
 #include <assert.h>
 #include <stdarg.h>
 #include <regex.h>
-#include <syslog.h>
 
 #include "glite/lbu/trio.h"
 #include "glite/lb/events.h"
 #include "glite/lb/context-int.h"
 #include "glite/lb/intjobstat.h"
 #include "glite/lb/process_event.h"
+#include "glite/lbu/log.h"
 
 #include "get_events.h"
 #include "store.h"
@@ -173,6 +173,7 @@ int edg_wll_JobStatusServer(
 
                                trio_asprintf(&stmt, "SELECT version,int_status,jobid FROM states WHERE parent_job='%|Ss'", md5_jobid);
                                if (stmt != NULL) {
+                                       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
                                        num_sub = edg_wll_ExecSQL(ctx, stmt, &sh);
                                        if (num_sub >=0 ) {
                                                i = 0;
@@ -260,6 +261,7 @@ int edg_wll_JobStatusServer(
                                        // Get child states from the database
                                        trio_asprintf(&stmt, "SELECT version,status,jobid FROM states WHERE parent_job='%|Ss'", md5_jobid);
                                        if (stmt != NULL) {
+                                               glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
                                                num_sub = edg_wll_ExecSQL(ctx, stmt, &sh);
                                                if (num_sub >=0 ) {
                                                        while ((num_f = edg_wll_FetchRow(ctx, sh, sizeof(out_stat)/sizeof(out_stat[0]), NULL, out_stat)) == 3 ) {
@@ -340,6 +342,7 @@ int edg_wll_JobStatusServer(
                                                "WHERE s.parent_job='%|Ss' AND s.jobid=j.jobid",
                                        md5_jobid);
                                if (stmt != NULL) {
+                                       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
                                        num_sub = edg_wll_ExecSQL(ctx, stmt, &sh);
                                        if (num_sub >=0 ) {
                                                while ((num_f = edg_wll_FetchRow(ctx, sh, sizeof(out)/sizeof(out[0]), NULL, out)) == 1 ) {
@@ -606,6 +609,7 @@ static char *job_owner(edg_wll_Context ctx,char *md5_jobid)
                edg_wll_SetError(ctx,ENOMEM, NULL);
                return NULL;
        }
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
        if (edg_wll_ExecSQL(ctx,stmt,&sh) >= 0) {
                f=edg_wll_FetchRow(ctx,sh,1,NULL,&out);
                if (f == 0) {
@@ -637,6 +641,7 @@ static edg_wll_ErrorCode get_job_parent(edg_wll_Context ctx, glite_jobid_const_t
                edg_wll_SetError(ctx,ENOMEM, NULL);
                goto err;
        }
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
 
        if (edg_wll_ExecSQL(ctx,stmt,&sh) < 0) goto err;
 
@@ -748,6 +753,9 @@ edg_wll_ErrorCode edg_wll_StoreIntState(edg_wll_Context ctx,
                                        "(jobid,seq,name,value) values "
                                        "('%|Ss',%d,'%|Ss','%|Ss')",
                                        jobid_md5, seq, (*tagp).tag, (*tagp).value);
+                       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, 
+                               LOG_PRIORITY_DEBUG, stmt);
+
                        if (edg_wll_ExecSQL(ctx,stmt,NULL) < 0) {
                                if (EEXIST == edg_wll_Error(ctx, NULL, NULL)) {
                                /* XXX: this should not happen */
@@ -779,6 +787,7 @@ edg_wll_ErrorCode edg_wll_StoreIntState(edg_wll_Context ctx,
                parent_md5, icvalues,
                jobid_md5);
        free(icvalues);
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
 
        if ((dbret = edg_wll_ExecSQL(ctx,stmt,NULL)) < 0) goto cleanup;
        free(stmt); stmt = NULL;
@@ -795,6 +804,8 @@ edg_wll_ErrorCode edg_wll_StoreIntState(edg_wll_Context ctx,
                        INTSTAT_VERSION, parent_md5, icvalues);
                free(icnames); free(icvalues);
 
+               glite_common_log(LOG_CATEGORY_LB_SERVER_DB, 
+                       LOG_PRIORITY_DEBUG, stmt);
                if (edg_wll_ExecSQL(ctx,stmt,NULL) < 0) goto cleanup;
                free(stmt); stmt = NULL;
        }
@@ -809,6 +820,8 @@ edg_wll_ErrorCode edg_wll_StoreIntState(edg_wll_Context ctx,
        if (update) {
                trio_asprintf(&stmt, "delete from status_tags "
                        "where jobid ='%|Ss' and seq<%d", jobid_md5, seq);
+               glite_common_log(LOG_CATEGORY_LB_SERVER_DB, 
+                       LOG_PRIORITY_DEBUG, stmt);
                if (edg_wll_ExecSQL(ctx,stmt,NULL) < 0) goto cleanup;
                free(stmt); stmt = NULL;
        }
@@ -838,7 +851,8 @@ edg_wll_ErrorCode edg_wll_StoreIntStateEmbryonic(edg_wll_Context ctx,
                        ",parent_job%s) "
                "values (%s)",
                icnames, values);
-
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
+       
        if (edg_wll_ExecSQL(ctx,stmt,NULL) < 0) goto cleanup;
 
 cleanup:
@@ -887,7 +901,8 @@ edg_wll_ErrorCode edg_wll_LoadIntState(edg_wll_Context ctx,
        if (stmt == NULL) {
                return edg_wll_SetError(ctx, ENOMEM, NULL);
        }
-
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
+       
        if ((nstates = edg_wll_ExecSQL(ctx,stmt,&sh)) < 0) goto cleanup;
        if (nstates == 0) {
                edg_wll_SetError(ctx,ENOENT,"no state in DB");
@@ -1250,6 +1265,7 @@ edg_wll_ErrorCode edg_wll_GetSubjobHistogram(edg_wll_Context ctx, glite_jobid_co
         if (stmt==NULL) {
                 return edg_wll_SetError(ctx,ENOMEM, NULL);
         }
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
 
         if (edg_wll_ExecSQL(ctx,stmt,&sh) >= 0) {
                 f=edg_wll_FetchRow(ctx,sh,1,NULL,&out);
@@ -1301,6 +1317,7 @@ edg_wll_ErrorCode edg_wll_StoreSubjobHistogram(edg_wll_Context ctx, glite_jobid_
        }
 
 //printf ("\n\n\n Would like to run SQL statament: %s\n\n\n\n", stmt);
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
 
         if ((dbret = edg_wll_ExecSQL(ctx,stmt,NULL)) < 0) goto cleanup;
 
@@ -1314,4 +1331,3 @@ cleanup:
 
 }
 
-
index 6b56493..48c5ea2 100644 (file)
@@ -3,10 +3,10 @@
 #include <string.h>
 #include <unistd.h>
 #include <errno.h>
-#include <syslog.h>
 
 #include "glite/lb/context-int.h"
 #include "lb_authz.h"
+#include "glite/lbu/log.h"
 
 #ifndef NO_VOMS
 
@@ -662,6 +662,8 @@ edg_wll_HandleCounterACL(edg_wll_Context ctx, edg_wll_Acl acl,
 
                for ( ; ; )
                {
+                        glite_common_log(LOG_CATEGORY_LB_SERVER_DB, 
+                               LOG_PRIORITY_DEBUG, q1);
                        if ( edg_wll_ExecSQL(ctx, q1, NULL) > 0 )
                                goto end;
 
@@ -675,6 +677,8 @@ edg_wll_HandleCounterACL(edg_wll_Context ctx, edg_wll_Acl acl,
                                                "update acls set refcnt = refcnt+%d "
                                                "where aclid = '%|Ss'",
                                                incr, aclid);
+                       glite_common_log(LOG_CATEGORY_LB_SERVER_DB,  
+                                LOG_PRIORITY_DEBUG, q2);
                        if ( edg_wll_ExecSQL(ctx, q2, NULL) < 0 )
                                continue;
 
@@ -688,18 +692,21 @@ edg_wll_HandleCounterACL(edg_wll_Context ctx, edg_wll_Acl acl,
                                "where aclid='%|Ss' and refcnt>=%d",
                                -incr, aclid, -incr);
 
+               glite_common_log(LOG_CATEGORY_LB_SERVER_DB,  
+                                LOG_PRIORITY_DEBUG, q1);
                if ( edg_wll_ExecSQL(ctx, q1, NULL) > 0 )
                {
                        trio_asprintf(&q2,
                                                "delete from acls "
                                                "where aclid='%|Ss' and refcnt=0",
                                                aclid);
+                       glite_common_log(LOG_CATEGORY_LB_SERVER_DB,  
+                                LOG_PRIORITY_DEBUG, q2);
                        edg_wll_ExecSQL(ctx, q2, NULL);
                }
                else
                {
-                       fprintf(stderr, "ACL with ID: %s has invalid reference count\n", aclid);
-                       syslog(LOG_WARNING, "ACL with ID: %s has invalid reference count\n", aclid);
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "ACL with ID: %s has invalid reference count", aclid);
                }
        }
 
@@ -775,6 +782,8 @@ edg_wll_UpdateACL(edg_wll_Context ctx, glite_jobid_const_t job,
         trio_asprintf(&stmt,
            "update jobs set aclid='%|Ss' where jobid='%|Ss' and ISNULL(aclid)",
            new_aclid, md5_jobid);
+      glite_common_log(LOG_CATEGORY_LB_SERVER_DB,
+         LOG_PRIORITY_DEBUG, stmt);
       updated = edg_wll_ExecSQL(ctx, stmt, NULL);
       free(stmt); stmt = NULL;
 
@@ -819,6 +828,8 @@ int edg_wll_GetACL(edg_wll_Context ctx, glite_jobid_const_t jobid, edg_wll_Acl *
        trio_asprintf(&q,
                "select aclid from jobs where jobid = '%|Ss'", jobstr);
 
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB,
+               LOG_PRIORITY_DEBUG, q);
        if (edg_wll_ExecSQL(ctx, q, &stmt) < 0 ||
                edg_wll_FetchRow(ctx, stmt, 1, NULL, &acl_id) < 0) {
                goto end;
@@ -835,6 +846,8 @@ int edg_wll_GetACL(edg_wll_Context ctx, glite_jobid_const_t jobid, edg_wll_Acl *
 
        trio_asprintf(&q,
                "select value from acls where aclid = '%|Ss'", acl_id);
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB,
+               LOG_PRIORITY_DEBUG, q);
        if (edg_wll_ExecSQL(ctx, q, &stmt) < 0 ||
                edg_wll_FetchRow(ctx, stmt, 1, NULL, &acl_str) < 0) {
                goto end;
index 30f3cad..72bd295 100644 (file)
@@ -265,3 +265,4 @@ char *edg_wll_ErrorToHTML(edg_wll_Context ctx,int code)
        free(et); free(ed);
        return out;
 }
+
index 2571f6f..62dc1c0 100644 (file)
@@ -9,6 +9,8 @@
 #include "glite/lb/mini_http.h"
 #include "glite/lb/context-int.h"
 
+#include "glite/lbu/log.h"
+
 #include "lb_http.h"
 #include "lb_proto.h"
 
@@ -26,12 +28,16 @@ int edg_wll_AcceptHTTP(edg_wll_Context ctx, char **body, char **resp, char ***hd
        if ( ctx->isProxy ) err = edg_wll_http_recv_proxy(ctx,&req,&hdr,body);
        else err = edg_wll_http_recv(ctx,&req,&hdr,body,ctx->connections->serverConnection);
 
-       if (req) {
-               dprintf(("[%d] request: %s\n",getpid(),req));
-       } else {
-               dprintf(("no request\n"));
-       }
-       if (body && *body) dprintf(("request body:\n%s\n\n",*body));
+       if (req)
+               glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, 
+                       LOG4C_PRIORITY_DEBUG, "[%d] request: %s", 
+                       getpid(), req);
+       else
+               glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, 
+                        LOG4C_PRIORITY_DEBUG, "no request");
+       if (body && *body) 
+               glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, 
+                        LOG4C_PRIORITY_DEBUG, "request body:\n%s",*body);
 
        if (!err) {
                if ((err = edg_wll_Proto(ctx,req,hdr,*body,resp,hdrOut,bodyOut,httpErr)))
index 4bff14c..6086e61 100644 (file)
@@ -13,6 +13,7 @@
 #include "glite/lb/xml_conversions.h"
 #include "glite/jobid/strmd5.h"
 #include "glite/lbu/trio.h"
+#include "glite/lbu/log.h"
 
 #include "lb_proto.h"
 #include "lb_text.h"
@@ -219,6 +220,7 @@ static int getUserNotifications(edg_wll_Context ctx, char *user, char ***notifid
                 "from notif_registrations "
                 "where userid='%s'",
                 user);
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, q);
         if (edg_wll_ExecSQL(ctx, q, &notifs) < 0) goto err;
         free(q); q = NULL;
 
@@ -228,7 +230,8 @@ static int getUserNotifications(edg_wll_Context ctx, char *user, char ***notifid
                 n++;
                 *notifids = realloc(*notifids, n*sizeof(**notifids));
                 (*notifids)[n-1] = strdup(notifc[n-1]);
-                printf("Notif %s found\n", notifc[n-1]);
+               glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG,
+                       "Notif %s found", notifc[n-1]);
         }
        if (n){
                *notifids = realloc(*notifids, (n+1)*sizeof(**notifids));
@@ -249,6 +252,7 @@ static int getNotifInfo(edg_wll_Context ctx, char *notifId, notifInfo *ni){
                 "from notif_registrations "
                 "where notifid='%s'",
                 notifId);
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, q);
        if (edg_wll_ExecSQL(ctx, q, &notif) < 0) goto err;
         free(q); q = NULL;
 
@@ -1196,3 +1200,4 @@ err:      asprintf(response,"HTTP/1.1 %d %s",ret,edg_wll_HTTPErrorMessage(ret));
 
        return edg_wll_Error(ctx,NULL,NULL);
 }
+
index 5774af9..a54c2b4 100644 (file)
@@ -3,7 +3,6 @@
 #include <time.h>
 #include <stdio.h>
 #include <string.h>
-#include <syslog.h>
 #include <assert.h>
 #include <unistd.h>
 #include <sys/types.h>
@@ -13,6 +12,7 @@
 #include <errno.h>
 
 #include "glite/lbu/trio.h"
+#include "glite/lbu/log.h"
 
 #include "glite/lb/context-int.h"
 #include "glite/lb/events_parse.h"
@@ -94,7 +94,7 @@ int edg_wll_LoadEventsServer(edg_wll_Context ctx,const edg_wll_LoadRequest *req,
                                        total = 0,
                                        written;
 
-                       fprintf(stderr, "Can't store event: %s\n", errdesc);
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "Can't store event: %s", errdesc);
                        if ( reject_fd == -1 )
                        {
                                char   *s, *s1;
@@ -113,7 +113,7 @@ int edg_wll_LoadEventsServer(edg_wll_Context ctx,const edg_wll_LoadRequest *req,
                                        reject_fd = edg_wll_CreateFileStorage(ctx,FILE_TYPE_LOAD,NULL,&(result->server_file));
                                if ( reject_fd == -1 )
                                        goto cycle_clean;
-                               printf("New reject file %s created\n", result->server_file);
+                               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "New reject file %s created", result->server_file);
                                free(s1);
                        }
                        /*      Save the line into "reject_file"
@@ -221,3 +221,4 @@ static int read_line(char **buff, size_t *maxsize, int fd)
                i++;
        }
 }
+
index f351605..91986d1 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "glite/lb/context-int.h"
 #include "glite/lbu/trio.h"
+#include "glite/lbu/log.h"
 
 #include "lb_authz.h"
 #include "lb_xml_parse.h"
@@ -88,14 +89,15 @@ int edg_wll_NotifMatch(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, cons
                ju = edg_wlc_JobIdGetUnique(stat->jobId),NOTIF_ALL_JOBS,cond_where ? cond_where : "",cond_and_where ? cond_and_where : "");
 
        free(ju); ju = NULL;
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, jobq);
 
        if (edg_wll_ExecSQL(ctx,jobq,&jobs) < 0) goto err;
 
        while ((ret = edg_wll_FetchRow(ctx,jobs,sizeof(jobc)/sizeof(jobc[0]),NULL,jobc)) > 0) {
                if (now > (expires = glite_lbu_DBToTime(jobc[2]))) {
                        edg_wll_NotifExpired(ctx,jobc[0]);
-                       if (debug) fprintf(stderr,"[%d] NOTIFY:%s expired at %s UTC\n",
-                                       getpid(),jobc[0],asctime(gmtime(&expires)));
+                       glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG, "[%d] NOTIFY:%s expired at %s UTC", 
+                               getpid(),jobc[0],asctime(gmtime(&expires)));
                }
                else if (notif_match_conditions(ctx,oldstat,stat,jobc[4]) &&
                                notif_check_acl(ctx,stat,jobc[3]))
@@ -103,11 +105,8 @@ int edg_wll_NotifMatch(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, cons
                        char                       *dest, *aux;
                        int                                     port;
 
-                       if (debug) {
-                               fprintf(stderr,"NOTIFY: %s, job %s\n",jobc[0],
-                                       ju = edg_wlc_JobIdGetUnique(stat->jobId));
-                               free(ju); ju = NULL;
-                       }
+                       glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG, "NOTIFY: %s, job %s", jobc[0], ju = edg_wlc_JobIdGetUnique(stat->jobId));
+                       free(ju); ju = NULL;
 
                        dest = strdup(jobc[1]);
                        if ( !(aux = strchr(dest, ':')) )
@@ -156,6 +155,8 @@ int edg_wll_NotifExpired(edg_wll_Context ctx,const char *notif)
 
        trio_asprintf(&dn,"delete from notif_registrations where notifid='%|Ss'",notif);
        trio_asprintf(&dj,"delete from notif_jobs where notifid='%|Ss'",notif);
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, dn);
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, dj);
 
        if (edg_wll_ExecSQL(ctx,dn,NULL) < 0 ||
                edg_wll_ExecSQL(ctx,dj,NULL) < 0)
@@ -163,7 +164,8 @@ int edg_wll_NotifExpired(edg_wll_Context ctx,const char *notif)
                char    *et,*ed;
                edg_wll_Error(ctx,&et,&ed);
 
-               syslog(LOG_WARNING,"delete notification %s: %s (%s)",notif,et,ed);
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, 
+                       "delete notification %s: %s (%s)", notif, et, ed);              
                free(et); free(ed);
        }
 
@@ -181,8 +183,9 @@ static int notif_match_conditions(edg_wll_Context ctx,const edg_wll_JobStat *old
        if (!cond) return 1;
 
        if (parseJobQueryRec(ctx,cond,strlen(cond),&c)) {
-               fputs("notif_match_conditions(): parseJobQueryRec failed\n",stderr);
-               syslog(LOG_ERR,"notif_match_conditions(): parseJobQueryRec failed");
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, 
+                       "notif_match_conditions(): parseJobQueryRec failed");
+
                return 1;
        }
 
index 024b932..f6fc2e9 100644 (file)
@@ -5,13 +5,13 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <errno.h>
-#include <syslog.h>
 #include <unistd.h>
 
 #include "glite/jobid/strmd5.h"
 #include "glite/lbu/trio.h"
 #include "glite/lb/context-int.h"
 #include "glite/lb/xml_parse.h"
+#include "glite/lbu/log.h"
 
 #include "il_notification.h"
 #include "query.h"
@@ -121,6 +121,8 @@ int edg_wll_NotifNewServer(
                                        "values ('%|Ss','%|Ss',%s,'%|Ss', '<and>%|Ss</and>', '%d')",
                                        nid_s, addr_s? addr_s: address_override, time_s, owner, xml_conds, flags);
 
+               glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG,
+                       q);
                if ( edg_wll_ExecSQL(ctx, q, NULL) < 0 )
                        goto rollback;
 
@@ -135,12 +137,16 @@ int edg_wll_NotifNewServer(
                        trio_asprintf(&q,
                                        "insert into notif_jobs(notifid,jobid) values ('%|Ss','%|Ss')",
                                        nid_s, jobs[i]);
+                       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, 
+                               LOG_PRIORITY_DEBUG, q);
                        if ( edg_wll_ExecSQL(ctx, q, NULL) < 0 )
                                goto rollback;
                }
                else {
                        trio_asprintf(&q,"insert into notif_jobs(notifid,jobid) values ('%|Ss','%|Ss')",
                                        nid_s,NOTIF_ALL_JOBS);
+                       glite_common_log(LOG_CATEGORY_LB_SERVER_DB,
+                               LOG_PRIORITY_DEBUG, q);
                        if ( edg_wll_ExecSQL(ctx, q, NULL) < 0 ) goto rollback;
 
                }
@@ -303,6 +309,8 @@ int edg_wll_NotifChangeServer(
                                /*      Format DB insert statement
                                 */
                                trio_asprintf(&q, "delete from  notif_jobs where notifid='%|Ss'", nid_s);
+                               glite_common_log(LOG_CATEGORY_LB_SERVER_DB,
+                                       LOG_PRIORITY_DEBUG, q);
                                if ( edg_wll_ExecSQL(ctx, q, NULL) < 0 )
                                        goto rollback;
 
@@ -312,6 +320,7 @@ int edg_wll_NotifChangeServer(
                                        trio_asprintf(&q,
                                                        "insert into notif_jobs(notifid,jobid) values ('%|Ss','%|Ss')",
                                                        nid_s, jobs[i]);
+                                       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, q);
                                        if ( edg_wll_ExecSQL(ctx, q, NULL) < 0 )
                                        {
                                                /*      XXX: Remove uncoplete registration?
@@ -319,9 +328,11 @@ int edg_wll_NotifChangeServer(
                                                 */
                                                free(q);
                                                trio_asprintf(&q, "delete from notif_jobs where notifid='%|Ss'", nid_s);
+                                               glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, q);
                                                edg_wll_ExecSQL(ctx, q, NULL);
                                                free(q);
                                                trio_asprintf(&q,"delete from notif_registrations where notifid='%|Ss'", nid_s);
+                                               glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, q);
                                                edg_wll_ExecSQL(ctx, q, NULL);
                                                goto rollback;
                                        }
@@ -435,8 +446,9 @@ static char *get_user(edg_wll_Context ctx, int create)
        }
        can_peername = edg_wll_gss_normalize_subj(ctx->peerName, 0);
        trio_asprintf(&q, "select userid from users where cert_subj='%|Ss'", can_peername);
-               if ( edg_wll_ExecSQL(ctx, q, &stmt) < 0 )
-                       goto cleanup;
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, q);
+       if ( edg_wll_ExecSQL(ctx, q, &stmt) < 0 )
+               goto cleanup;
 
        /*      returned value:
         *      0               no user find - continue only when 'create' parameter is set
@@ -454,6 +466,7 @@ static char *get_user(edg_wll_Context ctx, int create)
        free(q);
        trio_asprintf(&q, "insert into users(userid,cert_subj) values ('%|Ss','%|Ss')",
                        userid, can_peername);
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, q);
        if ( edg_wll_ExecSQL(ctx, q, NULL) < 0 )
        {
                if ( edg_wll_Error(ctx,NULL,NULL) != EEXIST )
@@ -502,6 +515,7 @@ static int check_notif_request(
                                "select destination from notif_registrations "
                                "where notifid='%|Ss' and userid='%|Ss' FOR UPDATE",
                                nid_s, user);
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
 
        if ( (ret = edg_wll_ExecSQL(ctx, stmt, &s)) < 0 )
                goto cleanup;
@@ -510,6 +524,8 @@ static int check_notif_request(
                free(stmt);
                trio_asprintf(&stmt,
                                        "select notifid from notif_registrations where notifid='%|Ss'", nid_s);
+               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");
@@ -661,6 +677,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);
 
        if ( (ret = edg_wll_ExecSQL(ctx, stmt, NULL)) < 0 )
                goto cleanup;
@@ -669,6 +686,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);
                ret = edg_wll_ExecSQL(ctx, stmt, NULL);
                if ( ret == 0 )
                        edg_wll_SetError(ctx, ENOENT, "Unknown notification ID");
@@ -694,7 +712,7 @@ static int update_notif(
                        char *errt, *errd;
 
                        edg_wll_Error(ctx, &errt, &errd);
-                       fprintf(stderr,"edg_wll_NotifChangeIL(): %s (%s)\n", errt, errd);
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "edg_wll_NotifChangeIL(): %s (%s)");
                        free(errt);
                        free(errd);
                }
@@ -779,10 +797,12 @@ static int drop_notif_request(edg_wll_Context ctx, const edg_wll_NotifId nid) {
                goto rollback;
 
        trio_asprintf(&stmt, "delete from notif_registrations where notifid='%|Ss'", nid_s);
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
        if ( edg_wll_ExecSQL(ctx, stmt, NULL) < 0 )
                goto rollback;
        free(stmt);
        trio_asprintf(&stmt, "delete from notif_jobs where notifid='%|Ss'", nid_s);
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
        if ( edg_wll_ExecSQL(ctx, stmt, NULL) < 0 ) 
                goto rollback;
        edg_wll_NotifCancelRegId(ctx, nid);
@@ -790,10 +810,10 @@ static int drop_notif_request(edg_wll_Context ctx, const edg_wll_NotifId nid) {
                /* Let notification erase from DB, 
                 * on notif-IL side it will be autopurged later anyway */
 
-               fprintf(stderr,"[%d] edg_wll_NotifDropServer() - NotifID found and dropped,"\
-                       " however, connection to notif-IL was refused (notif-IL not running?)\n", getpid());
-               syslog(LOG_INFO,"edg_wll_NotifDropServer() - NotifID found and dropped,"\
-                       " however, connection to notif-IL was refused (notif-IL not running?)");
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR,
+                       "[%d] edg_wll_NotifDropServer() - NotifID found and " \
+                       "dropped, however, connection to notif-IL was " \
+                       " refused (notif-IL not running?)", getpid());
 
                edg_wll_ResetError(ctx);
        }
@@ -828,6 +848,7 @@ static int check_notif_age(edg_wll_Context ctx, const edg_wll_NotifId nid) {
        }
 
        trio_asprintf(&q, "select notifid from notif_registrations WHERE notifid='%|Ss' AND valid < %s", nid_s, time_s);
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, q);
        if ( (ret = edg_wll_ExecSQL(ctx, q, NULL)) < 0 )
                goto cleanup;
 
@@ -840,3 +861,4 @@ cleanup:
        free(time_s);
        return edg_wll_Error(ctx, NULL, NULL);
 }
+
index 2a959d1..79a7447 100644 (file)
@@ -17,6 +17,7 @@
 #include "glite/lb/context-int.h"
 #include "glite/lb/xml_conversions.h"
 
+#include "glite/lbu/log.h"
 
 #include "get_events.h"
 #include "index.h"
@@ -143,7 +144,8 @@ int edg_wll_QueryEventsServer(
                else if ( !q )
                        q = qbase;
 
-//             printf("\nquery: %s\n\n", q);
+               glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG,
+                       q);
                ret = edg_wll_ExecSQL(ctx, q, &sh);
                if ( limit )
                        free(q);
@@ -409,7 +411,8 @@ int edg_wll_QueryJobsServer(
                else if ( !q )
                        q = qbase;
 
-//             printf("\nquery: %s\n\n", q);
+               glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG,
+                       q);
                ret = edg_wll_ExecSQL(ctx, q, &sh);
                if ( limit )
                        free(q);
@@ -541,7 +544,8 @@ limit_cycle_cleanup:
                                                "(s.suffix_id = j.suffix_id) AND (p.prefix_id = j.prefix_id)) AS result "
                                                "WHERE %s", zomb_where);        
 
-
+                       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, 
+                               LOG_PRIORITY_DEBUG, zquery);
                        j = edg_wll_ExecSQL(ctx,zquery,&sh);
 
                        if (j > 0) {
@@ -1745,3 +1749,4 @@ static int is_all_query(const edg_wll_QueryRec **jc)
 
        return 0;
 }
+
index a9f18f3..4c7f2b0 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "glite/lbu/trio.h"
 #include "glite/lb/context-int.h"
+#include "glite/lbu/log.h"
 
 #include "get_events.h"
 #include "store.h"
@@ -36,6 +37,8 @@ int edg_wll_QuerySequenceCodeServer(edg_wll_Context ctx, edg_wlc_JobId jobid, co
 
        if ( stmt == NULL ) return edg_wll_SetError(ctx, ENOMEM, NULL);
 
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
+       
        if ( (nstates = edg_wll_ExecSQL(ctx, stmt, &sh)) < 0 ) goto cleanup;
        if ( nstates == 0 ) {
                edg_wll_SetError(ctx, ENOENT, "no state in DB");
@@ -63,3 +66,4 @@ cleanup:
 
        return edg_wll_Error(ctx, NULL, NULL);
 }
+
index c2bd7bf..22a7e7b 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "glite/lbu/trio.h"
 #include "glite/lb/context-int.h"
+#include "glite/lbu/log.h"
 
 #include "server_state.h"
 #include "db_supp.h"
@@ -17,6 +18,7 @@ int edg_wll_GetServerState(edg_wll_Context ctx,const char *name,char **val)
        trio_asprintf(&stmt,"select value from server_state "
                        "where prefix = 'https://%|Ss:%d' and name = '%|Ss'",
                        ctx->srvName,ctx->srvPort,name);
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
 
        switch (edg_wll_ExecSQL(ctx,stmt,&q)) {
                case 0: edg_wll_SetError(ctx,ENOENT,name); break;
@@ -36,6 +38,7 @@ int edg_wll_SetServerState(edg_wll_Context ctx,const char *name,const char *val)
        trio_asprintf(&stmt,"insert into server_state (prefix,name,value) "
                        "values ('https://%|Ss:%d','%|Ss','%|Ss')",
                        ctx->srvName,ctx->srvPort,name,val);
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
 
        switch(edg_wll_ExecSQL(ctx,stmt,NULL)) {
                case 1: break;
@@ -45,6 +48,8 @@ int edg_wll_SetServerState(edg_wll_Context ctx,const char *name,const char *val)
                                                 "where prefix = 'https://%|Ss:%d' "
                                                 "and name = '%|Ss'",
                                                 val,ctx->srvName,ctx->srvPort,name);
+                               glite_common_log(LOG_CATEGORY_LB_SERVER_DB, 
+                                       LOG_PRIORITY_DEBUG, stmt);
                                 edg_wll_ExecSQL(ctx,stmt,NULL);
                         }
                         break;
index a10cd0b..f3b2c8b 100644 (file)
@@ -13,6 +13,8 @@
 #include "glite/jobid/cjobid.h"
 #include "glite/lbu/trio.h"
 
+#include "glite/lbu/log.h"
+
 #include "glite/lb/context-int.h"
 #include "glite/lb/events_parse.h"
 #include "glite/lb/mini_http.h"
@@ -258,12 +260,12 @@ int edg_wll_PurgeServer(edg_wll_Context ctx,const edg_wll_PurgeRequest *request,
        for (jobs_to_exa=0; request->jobs[jobs_to_exa]; jobs_to_exa++);
        for (i=0; request->jobs[i]; i++) {
                if (edg_wlc_JobIdParse(request->jobs[i],&job)) {
-                       fprintf(stderr,"%s: parse error\n",request->jobs[i]);
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "%s: parse error\n", request->jobs[i]);
                        parse = 1;
                }
                else {
                        if (check_strict_jobid(ctx,job)) {
-                               fprintf(stderr,"%s: not my job\n",request->jobs[i]);
+                               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "%s: not my job\n", request->jobs[i]);
                                parse = 1;
                        }
                        else {
@@ -313,12 +315,17 @@ int edg_wll_PurgeServer(edg_wll_Context ctx,const edg_wll_PurgeRequest *request,
                        }
                        else timeout[i] = request->timeout[i]; //specific given
 
+               glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG,
+                       (ctx->isProxy) 
+                       ? "select dg_jobid from jobs where proxy='1'" 
+                       : "select dg_jobid from jobs where server='1'");
+
                if ((jobs_to_exa = edg_wll_ExecSQL(ctx, (ctx->isProxy) ? "select dg_jobid from jobs where proxy='1'" :
                        "select dg_jobid from jobs where server='1'", &s)) < 0) goto abort;
 
                while (edg_wll_FetchRow(ctx,s,1,NULL,&job_s) > 0) {
                        if (edg_wlc_JobIdParse(job_s,&job)) {
-                               fprintf(stderr,"%s: parse error (internal inconsistency !)\n",job_s);
+                               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "%s: parse error (internal inconsistency !)", job_s);
                                parse = 1;
                        }
                        else {
@@ -371,16 +378,10 @@ abort:
        if (parse && !edg_wll_Error(ctx,NULL,NULL))
        {
                if ( naffected_jobs ) {
-                       fprintf(stderr,"[%d] Found some jobs not matching server address/port;"\
-                               " these were not purged but other jobs purged.\n", getpid());
-                       syslog(LOG_INFO,"Found some jobs not matching server address/port;"\
-                               " these were not purged but other jobs purged");
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "[%d] Found only jobs not matching server address/port; these were not purged.", getpid());
                }
                else {
-                       fprintf(stderr,"[%d] Found only jobs not matching server address/port;"\
-                               " these were not purged.\n", getpid());
-                       syslog(LOG_INFO,"Found only jobs not matching server address/port;"\
-                               " these were not purged.");
+                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "[%d] Found only jobs not matching server address/port; these were not purged.", getpid());
                }
        }
 
@@ -435,8 +436,8 @@ static int dump_events(edg_wll_Context ctx, glite_jobid_const_t job, int dump, c
         */
                edg_wll_Error(ctx,&et,&ed);
                dbjob = edg_wlc_JobIdGetUnique(job);
-               fprintf(stderr,"%s event %d: %s (%s)\n",dbjob,event,et,ed);
-               syslog(LOG_WARNING,"%s event %d: %s (%s)",dbjob,event,et,ed);
+               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, 
+                       "%s event %d: %s (%s)", dbjob, event, et, ed);
                free(et); free(ed); free(dbjob);
                edg_wll_ResetError(ctx);
        }
@@ -468,8 +469,7 @@ static int dump_events(edg_wll_Context ctx, glite_jobid_const_t job, int dump, c
                while (total != len) {
                        written = write(dump,event_s+total,len-total);
                        if (written < 0 && errno != EAGAIN) {
-                               perror("dump to file");
-                               syslog(LOG_ERR,"dump to file: %m");
+                               glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR, "dump to file");
                                dump = -1; /* XXX: likely to be a permanent error
                                            * give up writing but do purge */
                                break;
@@ -748,10 +748,12 @@ int purge_one(edg_wll_Context ctx,glite_jobid_const_t job,int dump, int purge, i
                if ( purge )
                {
                        trio_asprintf(&stmt,"delete from jobs where jobid = '%|Ss'",dbjob);
+                       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
                        if (edg_wll_ExecSQL(ctx,stmt,NULL) < 0) goto rollback;
                        free(stmt); stmt = NULL;
 
                        trio_asprintf(&stmt,"delete from states where jobid = '%|Ss'",dbjob);
+                       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
                        if (edg_wll_ExecSQL(ctx,stmt,NULL) < 0) goto rollback; 
                        free(stmt); stmt = NULL;
                }
@@ -759,6 +761,7 @@ int purge_one(edg_wll_Context ctx,glite_jobid_const_t job,int dump, int purge, i
                if ( purge )
                {
                        trio_asprintf(&stmt,"delete from status_tags where jobid = '%|Ss'",dbjob);
+                       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
                        if (edg_wll_ExecSQL(ctx,stmt,NULL) < 0) goto rollback;
                        free(stmt); stmt = NULL;
                }
@@ -769,6 +772,7 @@ int purge_one(edg_wll_Context ctx,glite_jobid_const_t job,int dump, int purge, i
                
                        // See if that prefix is already stored in the database 
                        trio_asprintf(&stmt,"select prefix_id from zombie_prefixes where prefix = '%|Ss'", prefix);
+                       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
 
                        sql_retval = edg_wll_ExecSQL(ctx,stmt,&q);
                        free(stmt); stmt = NULL;
@@ -779,6 +783,7 @@ int purge_one(edg_wll_Context ctx,glite_jobid_const_t job,int dump, int purge, i
                                glite_lbu_FreeStmt(&q);
 
                                trio_asprintf(&stmt,"insert into zombie_prefixes (prefix) VALUES ('%|Ss')", prefix);
+                               glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
 
                                if (edg_wll_ExecSQL(ctx,stmt,&q) <= 0) goto rollback;
 
@@ -787,6 +792,7 @@ int purge_one(edg_wll_Context ctx,glite_jobid_const_t job,int dump, int purge, i
 
                                // The record should exist now, however we need to look up the prefix_id 
                                trio_asprintf(&stmt,"select prefix_id from zombie_prefixes where prefix = '%|Ss'", prefix);
+                               glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
 
                                if (edg_wll_ExecSQL(ctx,stmt,&q) <= 0) goto rollback;
                                free(stmt); stmt = NULL;
@@ -799,6 +805,7 @@ int purge_one(edg_wll_Context ctx,glite_jobid_const_t job,int dump, int purge, i
 
                        // See if that suffix is already stored in the database 
                        trio_asprintf(&stmt,"select suffix_id from zombie_suffixes where suffix = '%|Ss'", suffix);
+                       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
 
                        sql_retval = edg_wll_ExecSQL(ctx,stmt,&q);
                        free(stmt); stmt = NULL;
@@ -809,6 +816,7 @@ int purge_one(edg_wll_Context ctx,glite_jobid_const_t job,int dump, int purge, i
                                glite_lbu_FreeStmt(&q);
 
                                trio_asprintf(&stmt,"insert into zombie_suffixes (suffix) VALUES ('%|Ss')", suffix);
+                               glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
 
                                if (edg_wll_ExecSQL(ctx,stmt,&q) <= 0) goto rollback;
 
@@ -817,6 +825,7 @@ int purge_one(edg_wll_Context ctx,glite_jobid_const_t job,int dump, int purge, i
 
                                // The record should exist now, however we need to look up the suffix_id 
                                trio_asprintf(&stmt,"select suffix_id from zombie_suffixes where suffix = '%|Ss'", suffix);
+                               glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
 
                                if (edg_wll_ExecSQL(ctx,stmt,&q) <= 0) goto rollback;
                                free(stmt); stmt = NULL;
@@ -829,6 +838,7 @@ int purge_one(edg_wll_Context ctx,glite_jobid_const_t job,int dump, int purge, i
 
                        trio_asprintf(&stmt,"insert into zombie_jobs (jobid, prefix_id, suffix_id)"
                                        " VALUES ('%|Ss', '%|Ss', '%|Ss')", root, prefix_id, suffix_id);
+                       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
 
                        if (edg_wll_ExecSQL(ctx,stmt,&q) < 0) {
                                if (edg_wll_Error(ctx, NULL, NULL) == EEXIST) {
@@ -842,8 +852,7 @@ int purge_one(edg_wll_Context ctx,glite_jobid_const_t job,int dump, int purge, i
                                        
                                        asprintf(&msg,"Warning: erasing job %s that already existed in this LB "
                                                "(reused jobid or corruped DB) (%s: %s)",job_s,et,ed);
-                                       fprintf(stderr,"[%d] %s\n", getpid(), msg);
-                                       syslog(LOG_INFO,msg);
+                                       glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "[%d] %s\n", getpid(), msg);
                                        free(et); free(ed); free(msg); free(job_s);
                                        edg_wll_ResetError(ctx);
                                }
@@ -865,6 +874,8 @@ int purge_one(edg_wll_Context ctx,glite_jobid_const_t job,int dump, int purge, i
                                "where jobid='%|Ss' "
                                "order by event", dbjob);
 
+               glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
+
                if (edg_wll_ExecSQL(ctx,stmt,&q) < 0) goto rollback;
                free(stmt); stmt = NULL;
 
@@ -917,6 +928,7 @@ int unset_proxy_flag(edg_wll_Context ctx, glite_jobid_const_t job)
 
        dbjob = glite_jobid_getUnique(job);
        trio_asprintf(&stmt,"update jobs set proxy='0' where jobid='%|Ss'", dbjob);
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
        free(dbjob);
 
        return(edg_wll_ExecSQL(ctx,stmt,NULL));
@@ -932,6 +944,7 @@ int unset_server_flag(edg_wll_Context ctx, glite_jobid_const_t job)
 
        dbjob = glite_jobid_getUnique(job);
        trio_asprintf(&stmt,"update jobs set server='0' where jobid='%|Ss'", dbjob);
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
        free(dbjob);
 
        return(edg_wll_ExecSQL(ctx,stmt,NULL));
@@ -988,3 +1001,4 @@ static void purge_throttle(int jobs_to_exa, double purge_end, double *time_per_j
        }
 
 }
+
index 9ec12f4..b01c711 100644 (file)
@@ -13,6 +13,8 @@
 #include "glite/lb/jobstat.h"
 #include "glite/lb/context-int.h"
 
+#include "glite/lbu/log.h"
+
 #include "glite/jobid/strmd5.h"
 
 #include "stats.h"
@@ -71,7 +73,8 @@ int edg_wll_InitStatistics(edg_wll_Context ctx)
                stats[i].map = mmap(NULL,sizeof zero,PROT_READ|PROT_WRITE,MAP_SHARED,stats[i].fd,0);
                if (stats[i].map == MAP_FAILED) return edg_wll_SetError(ctx,errno,"mmap()");
 
-               dprintf(("stats: using %s\n",fname));
+               glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG, 
+                       "stats: using %s",fname);
                unlink(fname);
        }
        return 0;
@@ -135,8 +138,9 @@ static int stats_inc_counter(edg_wll_Context ctx,const edg_wll_JobStat *jobstat,
        if (!jobstat->destination) return 0;
        edg_wll_ResetError(ctx);
 
-       dprintf(("inc_counter: destination %s, stats %d\n",jobstat->destination,
-                       (int) (stats - (edg_wll_Stats *) default_stats)));
+       glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG,
+               "inc_counter: destination %s, stats %d\n",
+               jobstat->destination, (int) (stats - (edg_wll_Stats *) default_stats));
 
        if (flock(stats->fd,LOCK_EX)) return edg_wll_SetError(ctx,errno,"flock()");
 
@@ -165,7 +169,8 @@ static int stats_inc_counter(edg_wll_Context ctx,const edg_wll_JobStat *jobstat,
 
        /* not found, initialize new */
        if (i == stats->grpno) {
-               dprintf(("group %s not found\n",sig));
+               glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG,
+                       "group %s not found",sig);
                if (stats->grpno) {
                        char    *zero = calloc(1,stats->grpsize);
                        munmap(stats->map,stats->grpno * stats->grpsize);
@@ -182,7 +187,8 @@ static int stats_inc_counter(edg_wll_Context ctx,const edg_wll_JobStat *jobstat,
                }
                stats->grpno++;
                stats->map->grpno++;
-               dprintf(("allocated\n"));
+               glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG,
+                       "allocated");
 
                g = (struct edg_wll_stats_group *) (
                                ((char *) stats->map) + stats->grpsize * i);
@@ -197,7 +203,9 @@ static int stats_inc_counter(edg_wll_Context ctx,const edg_wll_JobStat *jobstat,
                strcpy(g->sig,sig);
                g->last_update = now;
        }
-       else dprintf(("group %s found at %d\n",sig,i));
+       else 
+               glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG,
+                       "group %s found at %d", sig, i);
 
        a = g->archive;
        for (i=0; stats->archives[i].interval; i++) {
@@ -223,7 +231,9 @@ static int stats_inc_counter(edg_wll_Context ctx,const edg_wll_JobStat *jobstat,
 
                /* now we can do IT */
                a->cells[a->ptr].cnt++;
-               dprintf(("update archive %d, cell %d to %d\n",i,a->ptr,a->cells[a->ptr].cnt));
+               glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG,
+                       "update archive %d, cell %d to %d",
+                       i, a->ptr, a->cells[a->ptr].cnt);
 
                /* go to next archive */
                a = archive_skip(a,stats->archives[i].length);
@@ -334,7 +344,8 @@ int edg_wll_StateRateServer(
                }
        }
 
-       dprintf(("best match: archive %d, interval %ld\n",matchi,match));
+       glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG, 
+               "best match: archive %d, interval %ld", matchi, match);
 
        if (matchi < 0) {
                if (*from > g->last_update) {
@@ -356,7 +367,8 @@ int edg_wll_StateRateServer(
        afrom = g->last_update - g->last_update % i
                        - (stats->archives[matchi].length-1)*i;
 
-       dprintf(("archive from %ld = %s",afrom,ctime(&afrom)));
+       glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG,
+               "archive from %ld = %s", afrom, ctime(&afrom));
 
        if (afrom > *from) *from = afrom;
        if (afrom + stats->archives[matchi].length * i < *to) *to = afrom + stats->archives[matchi].length * i;
@@ -368,30 +380,33 @@ int edg_wll_StateRateServer(
        for (j=0; j<stats->archives[matchi].length; j++,afrom += i) {
                struct edg_wll_stats_cell       *c = a->cells + ((a->ptr+j+1) % stats->archives[matchi].length);
 
-               dprintf(("cell %d (abs %d): ",j,(a->ptr+j+1) % stats->archives[matchi].length));
+                glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG,
+                       "cell %d (abs %d): ",
+                       j, (a->ptr+j+1) % stats->archives[matchi].length);
                if (c->cnt < 0) {
-                       dprintf(("invalid\n"));
+                       glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG, "invalid");
                        continue; /* invalid cell */
                }
 
-               dprintf(("search %ld in %ld, %ld\n",*from,afrom,afrom+i));
+               glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG,
+                       "search %ld in %ld, %ld\n", *from, afrom, afrom+i);
 
                if (*from >= afrom && *from < afrom+i) {
                        match += *from - afrom;
                        *rate += c->cnt * (1.0 - ((float) *from-afrom)/i);
-                       dprintf(("matched from: match %ld, rate %f\n",match,*rate));
+                       glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG, "matched from: match %ld, rate %f", match, *rate);
                }
                else if (*from < afrom && *to >= afrom) {
                        match += i;
                        *rate += c->cnt;
-                       dprintf(("matched in: match %ld, rate %f\n",match,*rate));
+                       glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG, "matched in: match %ld, rate %f", match, *rate);
                }
 
                if (*to >= afrom && *to < afrom+i) {
                        match -= i-(*to-afrom);
                        *rate -= c->cnt * (((float) i)-(*to - afrom))/i;
 
-                       dprintf(("matched to: match %ld, rate %f\n",match,*rate));
+                       glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG, "matched to: match %ld, rate %f", match, *rate);
 
                /* asi blbost 
                        if (j == stats->archives[matchi].length - 1
index 5d62105..10b0492 100644 (file)
@@ -9,6 +9,7 @@
 #include "glite/jobid/strmd5.h"
 #include "glite/lbu/trio.h"
 #include "glite/lb/context-int.h"
+#include "glite/lbu/log.h"
 
 #include "jobstat.h"
 #include "db_supp.h"
@@ -40,6 +41,7 @@ int edg_wll_UserJobsServer(
        free(can_peername);
 
        trio_asprintf(&stmt,"select cert_subj from users where userid = '%|Ss'",userid);
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
 
        switch (edg_wll_ExecSQL(ctx,stmt,&sth)) {
                case 0: edg_wll_SetError(ctx,ENOENT,ctx->peerName);
@@ -57,6 +59,7 @@ int edg_wll_UserJobsServer(
        free(res); res = NULL;
 
        trio_asprintf(&stmt,"select dg_jobid from jobs where userid = '%|Ss' and grey='0'",userid);
+       glite_common_log(LOG_CATEGORY_LB_SERVER_DB, LOG_PRIORITY_DEBUG, stmt);
        switch (njobs = edg_wll_ExecSQL(ctx,stmt,&sth)) {
                case 0: edg_wll_SetError(ctx,ENOENT,ctx->peerName);
                case -1: goto err;
@@ -117,3 +120,4 @@ err:
 
        return err;
 }
+
index cc8812b..7a4066c 100644 (file)
@@ -5,6 +5,7 @@
 #include "glite/lb/xml_parse.h"
 #include "glite/lb/xml_conversions.h"
 
+#include "glite/lbu/log.h"
 
 #include "soap_version.h"
 #include "glite/security/glite_gsplugin.h"
@@ -40,7 +41,8 @@ SOAP_FMAC5 int SOAP_FMAC6 __lb__GetVersion(
        struct _lbe__GetVersion *in,
        struct _lbe__GetVersionResponse *out)
 {
-       dprintf(("[%d] WS call %s\n",getpid(),__FUNCTION__));
+       glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, LOG_PRIORITY_DEBUG, 
+               "[%d] WS call %s", getpid(), __FUNCTION__);
 
        out->version = soap_strdup(soap, VERSION);
 
@@ -59,7 +61,8 @@ SOAP_FMAC5 int SOAP_FMAC6 __lb__JobStatus(
        int     flags;
 
 
-       dprintf(("[%d] WS call %s\n",getpid(),__FUNCTION__));
+       glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, LOG_PRIORITY_DEBUG,
+               "[%d] WS call %s", getpid(), __FUNCTION__);
 
        if ( edg_wlc_JobIdParse(in->jobid, &j) )
        {
@@ -75,7 +78,10 @@ SOAP_FMAC5 int SOAP_FMAC6 __lb__JobStatus(
 
                cjobid = edg_wlc_JobIdUnparse(j);
                cflags = edg_wll_stat_flags_to_string(flags);
-               dprintf(("[%d] \n\t<flags>%s</flags>\n\t<jobId>%s</jobId>\n\n",getpid(),cflags,cjobid));
+               glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, 
+                       LOG_PRIORITY_DEBUG, 
+                       "[%d] \n\t<flags>%s</flags>\n\t<jobId>%s</jobId>\n",
+                       getpid(), cflags, cjobid);
                free(cjobid);
                free(cflags);
        }
@@ -106,7 +112,8 @@ SOAP_FMAC5 int SOAP_FMAC6 __lb__QueryJobs(
        int                ret = SOAP_FAULT;
 
 
-       dprintf(("[%d] WS call %s\n",getpid(),__FUNCTION__));
+       glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, LOG_PRIORITY_DEBUG,
+               "[%d] WS call %s", getpid(), __FUNCTION__);
 
        out->states = soap_malloc(soap, sizeof(*out->states));
        out->jobs = soap_malloc(soap, sizeof(*out->jobs));
@@ -129,10 +136,10 @@ SOAP_FMAC5 int SOAP_FMAC6 __lb__QueryJobs(
                if (edg_wll_QueryJobsRequestToXML(ctx, 
                                (const edg_wll_QueryRec **) conditions, 
                                flags, &message)) {
-                       dprintf(("[%d] %s\n",getpid(),"edg_wll_QueryJobsRequestToXML() returned error"));
+                       glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, LOG_PRIORITY_DEBUG, "[%d] %s", getpid(), "edg_wll_QueryJobsRequestToXML() returned error");
                }
                else {
-                       dprintf(("[%d] \n%s\n\n",getpid(),message));
+                       glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, LOG_PRIORITY_DEBUG, "[%d] \n%s\n", getpid(), message);
                }
                free(message);
        }
@@ -163,7 +170,8 @@ SOAP_FMAC5 int SOAP_FMAC6 __lb__UserJobs(
        edg_wll_JobStat *states;
 
 
-       dprintf(("[%d] WS call %s\n",getpid(),__FUNCTION__));
+       glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, LOG_PRIORITY_DEBUG, 
+               "[%d] WS call %s", getpid(), __FUNCTION__);
 
        ctx = (edg_wll_Context) glite_gsplugin_get_udata(soap);
        memset(out, 0, sizeof *out);
@@ -196,7 +204,8 @@ SOAP_FMAC5 int SOAP_FMAC6 __lb__QueryEvents(
        int                     ret = SOAP_OK;
 
 
-       dprintf(("[%d] WS call %s\n",getpid(),__FUNCTION__));
+       glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, LOG_PRIORITY_DEBUG,
+               "[%d] WS call %s", getpid(), __FUNCTION__);
 
        edg_wll_ResetError(ctx);
        if ( edg_wll_SoapToQueryCondsExt(in->jobConditions, in->__sizejobConditions, 
@@ -224,10 +233,10 @@ SOAP_FMAC5 int SOAP_FMAC6 __lb__QueryEvents(
                                (const edg_wll_QueryRec **) job_conditions, 
                                (const edg_wll_QueryRec **) event_conditions,
                                &message)) {
-                       dprintf(("[%d] %s\n",getpid(),"edg_wll_QueryEventsRequestToXML() returned error"));
+                       glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, LOG_PRIORITY_DEBUG, "[%d] %s", getpid(), "edg_wll_QueryEventsRequestToXML() returned error");
                }
                else {
-                       dprintf(("[%d] \n%s\n\n",getpid(),message));
+                       glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, LOG_PRIORITY_DEBUG, "[%d] \n%s\n", getpid(), message);
                }
                free(message);
        }
@@ -298,7 +307,8 @@ SOAP_FMAC5 int SOAP_FMAC6 __lb__NotifNew(
        edg_wll_NotifId         nid = NULL;
        int                     ret = SOAP_OK;
 
-       dprintf(("[%d] WS call %s\n",getpid(),__FUNCTION__));
+       glite_common_log(LOG_CATEGORY_LB_SERVER_ACCESS, LOG_PRIORITY_DEBUG, 
+               "[%d] WS call %s\n", getpid(), __FUNCTION__);
 
        edg_wll_ResetError(ctx);
        if ( edg_wll_SoapToQueryCondsExt(in->conditions, in->__sizeconditions, &conditions) )
@@ -447,3 +457,4 @@ static void freeEvents(edg_wll_Event *events)
                free(events);
        }
 }
+