eq_s->tail = NULL;
while(p) {
if((*cmp_func)(p->msg, data)) {
- il_log(LOG_DEBUG, " moving event at offset %d(%d) from %s:%d to %s:%d\n",
- p->msg->offset, p->msg->generation, eq_s->dest_name, eq_s->dest_port,
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " moving event at offset %d(%d) from %s:%d to %s:%d",
+ p->msg->offset, p->msg->generation, eq_s->dest_name, eq_s->dest_port,
eq_d ? eq_d->dest_name : "trash", eq_d ? eq_d->dest_port : -1);
/* il_log(LOG_DEBUG, " current: %x, next: %x\n", p, p->prev); */
/* remove the message from the source list */
es->rotate_index = filename ? fname2index(filename) : 0;
IL_EVENT_ID_FREE(job_id);
- il_log(LOG_DEBUG, " creating event store for id %s, filename %s, rotate index %lld\n",
- job_id_s, es->event_file_name, es->rotate_index);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " creating event store for id %s, filename %s, rotate index %lld",
+ job_id_s, es->event_file_name, es->rotate_index);
if(pthread_rwlock_init(&es->commit_lock, NULL))
abort();
}
/* actually rename the file */
- il_log(LOG_DEBUG, " renaming damaged event file from %s to %s\n",
- es->event_file_name, newname);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_WARN,
+ " renaming damaged event file from %s to %s",
+ es->event_file_name, newname);
if(rename(es->event_file_name, newname) < 0) {
set_error(IL_SYS, errno, "event_store_quarantine: error renaming event file");
return(-1);
}
/* actually rename the file */
- il_log(LOG_DEBUG, " renaming too large event file from %s to %s\n",
- es->event_file_name, newname);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_INFO,
+ " renaming too large event file from %s to %s",
+ es->event_file_name, newname);
if(rename(es->event_file_name, newname) < 0) {
set_error(IL_SYS, errno, "event_store_rotate_file: error renaming event file");
return(-1);
if(pthread_rwlock_wrlock(&es->offset_lock))
abort();
- il_log(LOG_DEBUG, " reading events from %s\n", es->event_file_name);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " reading events from %s",
+ es->event_file_name);
/* open event file */
ef = fopen(es->event_file_name, "r");
/* check the file modification time and size to avoid unnecessary operations */
memset(&stbuf, 0, sizeof(stbuf));
if(fstat(fd, &stbuf) < 0) {
- il_log(LOG_ERR, " could not stat event file %s: %s\n", es->event_file_name, strerror(errno));
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_ERROR,
+ " could not stat event file %s: %s",
+ es->event_file_name, strerror(errno));
fclose(ef);
event_store_unlock(es);
if(pthread_rwlock_unlock(&es->offset_lock))
return -1;
} else {
if((es->offset == stbuf.st_size) && (es->last_modified == stbuf.st_mtime)) {
- il_log(LOG_DEBUG, " event file not modified since last visit, skipping\n");
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " event file not modified since last visit, skipping");
fclose(ef);
event_store_unlock(es);
if(pthread_rwlock_unlock(&es->offset_lock))
last = es->last_committed_bs;
}
- il_log(LOG_DEBUG, " setting starting file position to %ld\n", last);
- il_log(LOG_DEBUG, " bytes sent to logging server: %d\n", es->last_committed_ls);
- il_log(LOG_DEBUG, " bytes sent to bookkeeping server: %d\n", es->last_committed_bs);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " setting starting file position to %ld", last);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " bytes sent to logging server: %d", es->last_committed_ls);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " bytes sent to bookkeeping server: %d", es->last_committed_bs);
if(last > 0) {
int c;
even if the offset points at EOF */
if((c=fgetc(ef)) != EVENT_SEPARATOR) {
/* Houston, we have got a problem */
- il_log(LOG_WARNING,
- " file position %ld does not point at the beginning of event string, backing off!\n",
- last);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_WARN,
+ " file position %ld does not point at the beginning of event string, backing off!",
+ last);
/* now, where were we? */
if(es->offset) {
/* next try will be with
int r;
/* fpos holds the starting position of event_s in file */
- il_log(LOG_DEBUG, " reading event at %ld\n", fpos);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " reading event at %ld", fpos);
last_ls = es->last_committed_ls;
last_bs = es->last_committed_bs;
free(event_s);
}
if(msg == NULL) {
- il_log(LOG_ALERT, " event file corrupted! I will try to move it to quarantine (ie. rename it).\n");
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_WARN,
+ " event file corrupted! I will try to move it to quarantine (ie. rename it).");
/* actually do not bother if quarantine succeeded or not - we could not do more */
event_store_quarantine(es);
fclose(ef);
msg->generation = es->generation;
#ifdef IL_NOTIFICATIONS
- il_log(LOG_DEBUG, "DEBUG: message dest %s, last dest %s, known dest %s\n",
- msg->dest, last_dest, eq_b ? eq_b->dest : "none");
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ "message dest %s, last dest %s, known dest %s",
+ msg->dest, last_dest, eq_b ? eq_b->dest : "none");
/* check message destination */
if(msg->dest == NULL) {
/* the message does not have destination itself, use destination cached for notification id */
if(eq_b == NULL) {
/* no destination is known for notification id, commit it immediately */
- il_log(LOG_DEBUG, " message has no known destination, will not be sent\n");
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " message has no known destination, will not be sent");
event_store_commit(es, msg->ev_len, 0, msg->generation);
}
} else {
/* first enqueue to the LS */
if(!bs_only && (last >= last_ls)) {
- il_log(LOG_DEBUG, " queuing event at %ld to logging server\n", last);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " queuing event at %ld to logging server", last);
/* TODO: throttling for the log server queue? */
if(enqueue_msg(eq_l, msg) < 0) {
break;
} else if(r > 0) {
throttle = 1;
- il_log(LOG_DEBUG, " queue max length limit reached, event at %ld throttled\n", fpos);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_INFO,
+ " queue max length limit reached, event at %ld throttled", fpos);
} else {
- il_log(LOG_DEBUG, " queuing event at %ld to bookkeeping server\n", last);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " queuing event at %ld to bookkeeping server", last);
}
}
server_msg_free(msg);
#if defined(IL_NOTIFICATIONS)
/* check if we have to move events to new destination */
- il_log(LOG_DEBUG, " last destination %s, last known destination %s\n", last_dest, eq_b ? eq_b->dest : "none");
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " last destination %s, last known destination %s",
+ last_dest, eq_b ? eq_b->dest : "none");
if(last_dest && strcmp(last_dest, eq_b->dest)) {
struct event_queue *eq_dest = queue_list_get(last_dest);
/* move all events with this notif_id from eq_b to eq_dest */
event_queue_move_events(eq_b, eq_dest, cmp_jobid, es->job_id_s);
eq_b = eq_dest;
- il_log(LOG_DEBUG, " all messages for notif id %s are now destined to %s\n",
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_INFO,
+ " all messages for notif id %s are now destined to %s",
es->job_id_s, eq_b->dest);
if(event_queue_create_thread(eq_b) < 0) {
ret = -1;
es->offset = last;
es->last_modified = stbuf.st_mtime;
- il_log(LOG_DEBUG, " event store offset set to %ld\n", last);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " event store offset set to %ld", last);
if(msg)
server_msg_free(msg);
fclose(ef);
- il_log(LOG_DEBUG, " finished reading events with %d\n", ret);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " finished reading events with %d", ret);
if(pthread_rwlock_unlock(&es->offset_lock))
abort();
/* prevent sender threads from updating */
event_store_lock(es);
- il_log(LOG_DEBUG, " trying to cleanup event store %s\n", es->job_id_s);
- il_log(LOG_DEBUG, " bytes sent to logging server: %d\n", es->last_committed_ls);
- il_log(LOG_DEBUG, " bytes sent to bookkeeping server: %d\n", es->last_committed_bs);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " trying to cleanup event store %s", es->job_id_s);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " bytes sent to logging server: %d", es->last_committed_ls);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " bytes sent to bookkeeping server: %d", es->last_committed_bs);
/* preliminary check to avoid opening event file */
/* if the positions differ, some events still have to be sent */
if(es->last_committed_ls != es->last_committed_bs) {
event_store_unlock(es);
- il_log(LOG_DEBUG, " not all events sent, cleanup aborted\n");
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " not all events sent, cleanup aborted");
return(0);
}
if(fd = pthread_rwlock_wrlock(&es->offset_lock)) {
- fprintf(stderr, "Fatal locking error: %s\n", strerror(fd));
abort();
}
event_store_unlock(es);
if(pthread_rwlock_unlock(&es->offset_lock))
abort();
- il_log(LOG_ERR, " event_store_clean: error opening event file: %s\n", strerror(errno));
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_ERROR,
+ " event_store_clean: error opening event file: %s", strerror(errno));
return(1);
}
efl.l_start = 0;
efl.l_len = 0;
if(fcntl(fd, F_SETLK, &efl) < 0) {
- il_log(LOG_DEBUG, " could not lock event file, cleanup aborted\n");
+ glite_comon_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_WARN,
+ " could not lock event file, cleanup aborted");
fclose(ef);
event_store_unlock(es);
if(pthread_rwlock_unlock(&es->offset_lock))
}
last = ftell(ef);
- il_log(LOG_DEBUG, " total bytes in file: %d\n", last);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " total bytes in file: %d", last);
if(es->last_committed_ls < last) {
fclose(ef);
event_store_unlock(es);
if(pthread_rwlock_unlock(&es->offset_lock))
abort();
- il_log(LOG_DEBUG, " events still waiting in queue, cleanup aborted\n");
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " events still waiting in queue, cleanup aborted");
return(0);
} else if( es->last_committed_ls > last) {
- il_log(LOG_WARNING, " warning: event file seems to shrink!\n");
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_WARN,
+ " warning: event file seems to shrink!");
/* XXX - in that case we can not continue because there may be
some undelivered events referring to that event store */
fclose(ef);
}
/* now we are sure that all events were sent and the event queues are empty */
- il_log(LOG_INFO, " removing event file %s\n", es->event_file_name);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_INFO,
+ " removing event file %s", es->event_file_name);
/* remove the event file */
unlink(es->event_file_name);
if(pthread_rwlock_unlock(&es->use_lock))
abort();
- il_log(LOG_DEBUG, " released lock on %s (%s)\n", es->job_id_s, es->event_file_name);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " released lock on %s (%s)", es->job_id_s, es->event_file_name);
return(0);
}
#endif
- il_log(LOG_INFO, " attaching to event file: %s\n", filename);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_INFO,
+ " attaching to event file: %s", filename);
if(strstr(filename, "quarantine") != NULL) {
- il_log(LOG_INFO, " file name belongs to quarantine, not touching that.\n");
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG, " file name belongs to quarantine, not touching that.");
return(0);
}
#else
job_id_s = edg_wll_GetJobId(event_s);
#endif
- il_log(LOG_DEBUG, " event id: '%s'\n", job_id_s);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " event id: '%s'", job_id_s);
if(job_id_s == NULL) {
- il_log(LOG_NOTICE, " skipping file, could not parse event\n");
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " skipping file, could not parse event");
ret = 0;
goto out;
}
} else {
/* could not stat file, remove ctl */
strcat(ef, s);
- il_log(LOG_DEBUG, " removing stale file %s\n", ef);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " removing stale file %s", ef);
if(unlink(ef))
- il_log(LOG_ERR, " could not remove file %s: %s\n", ef, strerror(errno));
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_ERROR,
+ " could not remove file %s: %s\n", ef, strerror(errno));
}
free(ef);
/* recover this event store */
/* no need to lock use_lock in event_store, the store_list_lock is in place */
if(event_store_recover(sl->es) < 0) {
- il_log(LOG_ERR, " error recovering event store %s:\n %s\n", sl->es->event_file_name, error_get_msg());
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_ERROR,
+ " error recovering event store %s: %s",
+ sl->es->event_file_name, error_get_msg());
clear_error();
}
sl = sl->next;
switch(event_store_clean(es)) {
case 0:
- il_log(LOG_DEBUG, " event store not removed, still used\n");
- return(0);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " event store not removed, still used");
+ return(0);
case 1:
if(pthread_rwlock_wrlock(&store_list_lock) < 0) {
/* one event store at time */
ret = pthread_rwlock_trywrlock(&sl->es->use_lock);
if(ret == EBUSY) {
- il_log(LOG_DEBUG, " event_store %s is in use by another thread\n",
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_WARN,
+ " event_store %s is in use by another thread",
sl->es->job_id_s);
sl = slnext;
continue;
break;
case -1:
- il_log(LOG_ERR, " error removing event store %s (file %s):\n %s\n",
- sl->es->job_id_s, sl->es->event_file_name, error_get_msg());
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_ERROR,
+ " error removing event store %s (file %s): %s",
+ sl->es->job_id_s, sl->es->event_file_name, error_get_msg());
/* event_store_release(sl->es); */
clear_error();
/* go on to the next */
#endif
#include "glite/security/glite_gss.h"
-
#include "il_error.h"
-extern int log_level;
-
static pthread_key_t err_key;
static int IL_ERR_MSG_LEN = 1024;
int
-init_errors(int level)
+init_errors()
{
static pthread_once_t error_once = PTHREAD_ONCE_INIT;
struct error_inf *err;
if(err->msg == NULL)
return(-1);
- if(level)
- log_level = level;
-
#ifdef LB_PROF
monstartup((u_long)&_start, (u_long)&etext);
#endif
char *msg;
};
-int init_errors(int);
+int init_errors();
int set_error(int, long, char *);
int clear_error();
int error_get_maj();
long error_get_min();
char *error_get_msg();
-int il_log(int, char *, ...);
-
#endif
#if defined(INTERLOGD_FLUSH)
if(strcmp(++r, "\"flush\"")) {
#endif
- il_log(LOG_WARNING, " command %s not implemented\n", r);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_WARN, "command %s not implemented",
+ r);
ret = -1;
continue;
#if defined(INTERLOGD_FLUSH)
return(0);
#if defined(INTERLOGD_FLUSH)
- il_log(LOG_DEBUG, " received FLUSH command\n");
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG, "received FLUSH command");
/* catchup with all neccessary event files */
if(job_id_s) {
no need to lock the event_store at all */
event_store_release(es);
if(result < 0) {
- il_log(LOG_ERR, " error trying to catch up with event file: %s\n",
- error_get_msg());
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_ERROR,
+ " error trying to catch up with event file: %s",
+ error_get_msg());
clear_error();
}
} else
/* this call does not fail :-) */
event_store_recover_all();
- il_log(LOG_DEBUG, " alerting threads to report status\n");
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG, " alerting threads to report status");
/* prevent threads from reporting too early */
if(pthread_mutex_lock(&flush_lock) < 0) {
while(num_replies < num_threads) {
int ret;
if((ret=pthread_cond_timedwait(&flush_cond, &flush_lock, &endtime)) < 0) {
- il_log(LOG_ERR, " error waiting for thread reply: %s\n", strerror(errno));
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_ERROR,
+ " error waiting for thread reply: %s",
+ strerror(errno));
result = (ret == ETIMEDOUT) ? 0 : -1;
break;
}
if(eq->flushing == 2) {
eq->flushing = 0;
num_replies++;
- il_log(LOG_DEBUG, " thread reply: %d\n", eq->flush_result);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " thread reply: %d",
+ eq->flush_result);
result = ((result == 1) || (eq->flush_result < 0)) ?
eq->flush_result : result;
}
if(job_id_s) free(job_id_s);
result = send_confirmation(receipt, result);
if(result <= 0)
- il_log(LOG_ERR, "handle_cmd: error sending status: %s\n", error_get_msg());
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_ERROR,
+ "handle_cmd: error sending status: %s",
+ error_get_msg());
return(1);
/* convert event to message for server */
if((msg = server_msg_create(event, offset)) == NULL) {
- il_log(LOG_ERR, " handle_msg: error parsing event '%s':\n %s\n", event, error_get_msg());
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_WARN,
+ " handle_msg: error parsing event '%s': %s",
+ event, error_get_msg());
return(0);
}
il_log(LOG_DEBUG, " syncing event store at %d with event at %d, result %d\n", es->offset, offset, ret);
*/
if(ret < 0) {
- il_log(LOG_ERR, " handle_msg: error syncing event store:\n %s\n", error_get_msg());
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_ERROR,
+ " handle_msg: error syncing event store: %s",
+ error_get_msg());
/* XXX should error during event store recovery cause us to drop the message? */
/* Probably no, because the attempt to recover means we have missed some events,
and delivery of this one will not move offset ahead. So try our best and deliver it
eq_s = queue_list_get(msg->job_id_s);
#endif
if(eq_s == NULL) {
- il_log(LOG_ERR, " handle_msg: apropriate queue not found: %s\n", error_get_msg());
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_ERROR,
+ " handle_msg: apropriate queue not found: %s",
+ error_get_msg());
clear_error();
} else {
if(enqueue_msg(eq_s, msg) < 0)
if((ret = input_queue_get(&msg, &offset, INPUT_TIMEOUT)) < 0)
{
if(error_get_maj() == IL_PROTO) {
- il_log(LOG_DEBUG, " premature EOF while receiving event\n");
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " premature EOF while receiving event");
/* problems with socket input, try to catch up from files */
#ifndef PERF_EMPTY
event_store_recover_all();
return (ret);
break;
default:
- il_log(LOG_ERR, "Error: %s\n", error_get_msg());
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_ERROR,
+ "Error: %s",
+ error_get_msg());
break;
}
} /* while */
if(connect(sock, (struct sockaddr *)&saddr, sizeof(saddr.sun_path)) < 0) {
if(errno == ECONNREFUSED) {
/* socket present, but no one at the other end; remove it */
- il_log(LOG_WARNING, " removing stale input socket %s\n", socket_path);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO,
+ " removing stale input socket %s",
+ socket_path);
unlink(socket_path);
}
/* ignore other errors for now */
case -1: /* error */
switch(errno) {
case EINTR:
- il_log(LOG_DEBUG, " interrupted while waiting for event!\n");
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_WARN,
+ " interrupted while waiting for event!");
return(0);
default:
void handle_signal(int num) {
- il_log(LOG_DEBUG, "Received signal %d\n", num);
- killflg++;
+
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Received signal %d\n", num);
+
+ switch(num) {
+ case SIGHUP:
+ log4c_reread();
+ break;
+
+ case SIGUSR1:
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO,
+ "Logging priority is now %s for %s, %s for %s and %s for %s\n",
+ log4c_priority_to_string(log4c_category_get_priority(log4c_category_get(LOG_CATEGORY_SECURITY))),
+ LOG_CATEGORY_SECURITY,
+ log4c_priority_to_string(log4c_category_get_priority(log4c_category_get(LOG_CATEGORY_ACCESS))),
+ LOG_CATEGORY_ACCESS,
+ log4c_priority_to_string(log4c_category_get_priority(log4c_category_get(LOG_CATEGORY_CONTROL))),
+ LOG_CATEGORY_CONTROL);
+ break;
+
+ case SIGUSR2:
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO,
+ "Logging priority is now %s for %s, %s for %s, %s for %s and %s for %s\n",
+ log4c_priority_to_string(log4c_category_get_priority(log4c_category_get(LOG_CATEGORY_LB))),
+ LOG_CATEGORY_LB,
+ log4c_priority_to_string(log4c_category_get_priority(log4c_category_get(LOG_CATEGORY_LB_LOGD))),
+ LOG_CATEGORY_LB_LOGD,
+ log4c_priority_to_string(log4c_category_get_priority(log4c_category_get(LOG_CATEGORY_LB_IL))),
+ LOG_CATEGORY_LB_IL,
+ log4c_priority_to_string(log4c_category_get_priority(log4c_category_get(LOG_CATEGORY_LB_SERVER))),
+ LOG_CATEGORY_LB_SERVER);
+ break;
+
+ case SIGPIPE:
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Broken pipe, lost communication channel.\n");
+ break;
+
+ case SIGINT:
+ case SIGTERM:
+ case SIGQUIT:
+ killflg++;
+ break;
+
+ }
}
i = decode_switches (argc, argv);
+ if(glite_common_log_init()) {
+ fprintf(stderr, "glite_common_log_init() failed, exiting.\n");
+ exit(EXIT_FAILURE);
+ }
+
/* check for reasonable queue lengths */
if(queue_size_low == 0 && queue_size_high > 0 ||
queue_size_low > queue_size_high) {
- fprintf(stderr, "max queue length -Q must be greater than low queue length -q, both or none must be specified!\n");
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "max queue length -Q must be greater than low queue length -q, both or none must be specified!");
exit(EXIT_FAILURE);
}
bs_only = 1;
}
- if(init_errors(verbose ? LOG_DEBUG : LOG_WARNING)) {
- fprintf(stderr, "Failed to initialize error message subsystem. Exiting.\n");
- exit(EXIT_FAILURE);
+ /* initialize error reporting */
+ if(init_errors()) {
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "Failed to initialize error message subsystem. Exiting.");
+ exit(EXIT_FAILURE);
}
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR
|| signal(SIGABRT, handle_signal) == SIG_ERR
|| signal(SIGTERM, handle_signal) == SIG_ERR
|| signal(SIGINT, handle_signal) == SIG_ERR) {
- perror("signal");
- exit(EXIT_FAILURE);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "Failed to setup signal handlers: %s, exiting.",
+ strerror(errno));
+ exit(EXIT_FAILURE);
}
if(!debug &&
(daemon(0,0) < 0)) {
- perror("daemon");
- exit(EXIT_FAILURE);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "Failed to daemonize itself: %s, exiting.",
+ strerror(errno));
+ exit(EXIT_FAILURE);
}
#ifdef LB_PERF
njobs);
#endif
- il_log(LOG_INFO, "Initializing input queue...\n");
if(input_queue_attach() < 0) {
- il_log(LOG_CRIT, "Failed to initialize input queue: %s\n", error_get_msg());
- exit(EXIT_FAILURE);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "Failed to initialize input queue: %s",
+ error_get_msg());
+ exit(EXIT_FAILURE);
}
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Initialized input queue.");
/* initialize output queues */
- il_log(LOG_INFO, "Initializing event queues...\n");
if(queue_list_init(log_server) < 0) {
- il_log(LOG_CRIT, "Failed to initialize output event queues: %s\n", error_get_msg());
- exit(EXIT_FAILURE);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "Failed to initialize output event queues: %s",
+ error_get_msg());
+ exit(EXIT_FAILURE);
}
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Initialized event queues.");
if(lazy_close)
- il_log(LOG_DEBUG, " using lazy mode when closing connections, timeout %d\n",
- default_close_timeout);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, " using lazy mode when closing connections, timeout %d",
+ default_close_timeout);
/* get credentials */
if (CAcert_dir)
edg_wll_gss_watch_creds(cert_file,&cert_mtime);
cred_handle = malloc(sizeof(*cred_handle));
if(cred_handle == NULL) {
- il_log(LOG_CRIT, "Failed to allocate structure for credentials.\n");
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "Failed to allocate structure for credentials.");
exit(EXIT_FAILURE);
}
cred_handle->creds = NULL;
ret = edg_wll_gss_acquire_cred_gsi(cert_file, key_file, &cred_handle->creds, &gss_stat);
if (ret) {
char *gss_err = NULL;
- char *str;
if (ret == EDG_WLL_GSS_ERROR_GSS)
edg_wll_gss_get_error(&gss_stat, "edg_wll_gss_acquire_cred_gsi()", &gss_err);
- asprintf(&str, "Failed to load GSI credential: %s\n",
- (gss_err) ? gss_err : "edg_wll_gss_acquire_cred_gsi() failed");
- il_log(LOG_CRIT, str);
- free(str);
+ glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_FATAL, "Failed to load GSI credential: %s, exiting.",
+ (gss_err) ? gss_err : "edg_wll_gss_acquire_cred_gsi() failed");
if (gss_err)
free(gss_err);
exit(EXIT_FAILURE);
}
+ glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_INFO, "Using certificate %s", cred_handle->creds->name);
#ifndef PERF_EMPTY
/* find all unsent events waiting in files */
#ifdef LB_PERF
if(norecover) {
if(event_store_init(file_prefix) < 0) {
- il_log(LOG_CRIT, "Failed to init event stores: %s\n", error_get_msg());
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "Failed to initialize event stores: %s",
+ error_get_msg());
exit(EXIT_FAILURE);
}
} else
{
pthread_t rid;
- il_log(LOG_INFO, "Starting recovery thread...\n");
if(pthread_create(&rid, NULL, recover_thread, NULL) < 0) {
- il_log(LOG_CRIT, "Failed to start recovery thread: %s\n", strerror(errno));
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "Failed to start recovery thread: %s", strerror(errno));
exit(EXIT_FAILURE);
}
pthread_detach(rid);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Started recovery thread.");
}
#endif
- il_log(LOG_INFO, "Entering main loop...\n");
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Entering main loop.");
/* do the work */
if(loop() < 0) {
- il_log(LOG_CRIT, "Fatal error: %s\n", error_get_msg());
- if (killflg) {
- input_queue_detach();
- exit(EXIT_FAILURE);
- }
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "Fatal error: %s", error_get_msg());
+ if (killflg) {
+ input_queue_detach();
+ exit(EXIT_FAILURE);
+ }
}
- il_log(LOG_INFO, "Done!\n");
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Done!");
input_queue_detach();
exit (0);
#include "il_error.h"
#include "glite/security/glite_gss.h"
#include "glite/lb/il_msg.h"
+#include "glite/lbu/log.h"
#include <pthread.h>
#include <sys/time.h>
{
struct event_queue *eq = (struct event_queue *)q;
- il_log(LOG_WARNING, "thread %d exits\n", eq->thread_id);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN, "thread %d exits", eq->thread_id);
/* unlock all held locks */
/* FIXME: check that the thread always exits when holding these locks;
int exit_timeout = EXIT_TIMEOUT;
if(init_errors(0) < 0) {
- il_log(LOG_ERR, "Error initializing thread specific data, exiting!");
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR,
+ "Error initializing thread specific data, exiting!");
pthread_exit(NULL);
}
- il_log(LOG_DEBUG, " started new thread for delivery to %s:%d\n", eq->dest_name, eq->dest_port);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO,
+ " started new thread for delivery to %s:%d",
+ eq->dest_name, eq->dest_port);
pthread_cleanup_push(queue_thread_cleanup, q);
ret = event_queue_wait(eq, close_timeout);
if(ret == 1) {/* timeout? */
event_queue_close(eq);
- il_log(LOG_DEBUG, " connection to %s:%d closed\n",
- eq->dest_name, eq->dest_port);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " connection to %s:%d closed",
+ eq->dest_name, eq->dest_port);
}
close_timeout = 0;
} else {
ret = event_queue_wait(eq, exit_timeout);
if(ret == 1) {
- il_log(LOG_INFO, " thread idle for more than %d seconds, exiting\n", exit_timeout);
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO,
+ " thread idle for more than %d seconds, exiting",
+ exit_timeout);
event_queue_close(eq);
event_queue_cond_unlock(eq);
pthread_exit((void*)0);
}
if(ret < 0) {
/* error waiting */
- il_log(LOG_ERR, "queue_thread: %s\n", error_get_msg());
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_WARN,
+ "queue_thread: %s",
+ error_get_msg());
event_queue_cond_unlock(eq);
pthread_exit((void*)-1);
}
event_queue_cond_unlock(eq);
/* discard expired events */
- il_log(LOG_DEBUG, " discarding expired events\n");
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG, " discarding expired events");
now = time(NULL);
event_queue_move_events(eq, NULL, cmp_expires, &now);
if(!event_queue_empty(eq)) {
/* deliver pending events */
- il_log(LOG_DEBUG, " attempting delivery to %s:%d\n", eq->dest_name, eq->dest_port);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " attempting delivery to %s:%d",
+ eq->dest_name, eq->dest_port);
/* connect to server */
if((ret=event_queue_connect(eq)) == 0) {
/* not connected */
if(error_get_maj() != IL_OK)
- il_log(LOG_ERR, "queue_thread: %s\n", error_get_msg());
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_WARN,
+ "queue_thread: %s", error_get_msg());
#if defined(IL_NOTIFICATIONS)
- il_log(LOG_INFO, " could not connect to client %s, waiting for retry\n", eq->dest_name);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_INFO,
+ " could not connect to client %s, waiting for retry",
+ eq->dest_name);
#else
- il_log(LOG_INFO, " could not connect to bookkeeping server %s, waiting for retry\n", eq->dest_name);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_INFO,
+ " could not connect to bookkeeping server %s, waiting for retry",
+ eq->dest_name);
#endif
retrycnt++;
} else {
case 0:
/* there was an error and we still have events to send */
if(error_get_maj() != IL_OK)
- il_log(LOG_ERR, "queue_thread: %s\n", error_get_msg());
- il_log(LOG_DEBUG, " events still waiting\n");
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_WARN,
+ "queue_thread: %s",
+ error_get_msg());
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " events still waiting");
break;
case 1:
/* hey, we are done for now */
- il_log(LOG_DEBUG, " all events for %s sent\n", eq->dest_name);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " all events for %s sent",
+ eq->dest_name);
break;
default:
/* internal error */
- il_log(LOG_ERR, "queue_thread: %s\n", error_get_msg());
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_ERROR,
+ "queue_thread: %s",
+ error_get_msg());
exit = 1;
break;
close_timeout = default_close_timeout;
else {
event_queue_close(eq);
- il_log(LOG_DEBUG, " connection to %s:%d closed\n",
- eq->dest_name, eq->dest_port);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " connection to %s:%d closed",
+ eq->dest_name, eq->dest_port);
}
}
}
/* Check if we are flushing and if we are, report status to master */
if(eq->flushing == 1) {
- il_log(LOG_DEBUG, " flushing mode detected, reporting status\n");
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " flushing mode detected, reporting status");
/* 0 - events waiting, 1 - events sent, < 0 - some error */
eq->flush_result = ret;
eq->flushing = 2;
which may cure server kicking us out after given number of connections */
#ifndef LB_PERF
if((ret == 0) && (retrycnt > 0)) {
- il_log(LOG_WARNING, " sleeping\n");
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " sleeping");
event_queue_sleep(eq);
}
#endif
recover_thread(void *q)
{
if(init_errors(0) < 0) {
- il_log(LOG_ERR, "Error initializing thread specific data, exiting!");
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_ERROR,
+ "Error initializing thread specific data, exiting!");
pthread_exit(NULL);
}
while(1) {
- il_log(LOG_INFO, "Looking up event files...\n");
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ "Looking up event files.");
if(event_store_init(file_prefix) < 0) {
- il_log(LOG_ERR, "recover_thread: %s\n", error_get_msg());
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL,
+ "recover_thread: %s", error_get_msg());
exit(1);
}
if(event_store_recover_all() < 0) {
- il_log(LOG_ERR, "recover_thread: %s\n", error_get_msg());
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL,
+ "recover_thread: %s", error_get_msg());
exit(1);
}
if(event_store_cleanup() < 0) {
- il_log(LOG_ERR, "recover_thread: %s\n", error_get_msg());
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL,
+ "recover_thread: %s", error_get_msg());
exit(1);
}
- il_log(LOG_INFO, "Reloading certificate...\n");
+ glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_DEBUG, "Checking for new certificate.");
if (edg_wll_gss_watch_creds(cert_file, &cert_mtime) > 0) {
edg_wll_GssCred new_creds = NULL;
int ret;
if(cred_handle && cred_handle->counter == 0) {
edg_wll_gss_release_cred(&cred_handle->creds, NULL);
free(cred_handle);
- il_log(LOG_DEBUG, " freed old credentials\n");
+ glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_DEBUG,
+ " freed old credentials");
}
cred_handle = malloc(sizeof(*cred_handle));
if(cred_handle == NULL) {
- il_log(LOG_CRIT, "Failed to allocate structure for credentials.\n");
+ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL,
+ "Failed to allocate structure for credentials.");
exit(EXIT_FAILURE);
}
cred_handle->creds = new_creds;
cred_handle->counter = 0;
if(pthread_mutex_unlock(&cred_handle_lock) < 0)
abort();
- il_log(LOG_INFO, "New certificate found and deployed.\n");
+ glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_INFO,
+ "New certificate %s found and deployed.",
+ new_creds->name);
}
}
sleep(INPUT_TIMEOUT);
}
ret = 1;
- il_log(LOG_DEBUG, " sent code %d back to client\n", code);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " sent code %d back to client",
+ code);
out:
close(sock);
if(pthread_mutex_unlock(&cred_handle_lock) < 0)
abort();
- il_log(LOG_DEBUG, " trying to connect to %s:%d\n", eq->dest_name, eq->dest_port);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " trying to connect to %s:%d",
+ eq->dest_name, eq->dest_port);
ret = edg_wll_gss_connect(local_cred_handle->creds, eq->dest_name, eq->dest_port, &tv, &eq->gss, &gss_stat);
if(pthread_mutex_lock(&cred_handle_lock) < 0)
abort();
if(local_cred_handle != cred_handle && local_cred_handle->counter == 0) {
edg_wll_gss_release_cred(&local_cred_handle->creds, NULL);
free(local_cred_handle);
- il_log(LOG_DEBUG, " freed credentials, not used anymore\n");
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG, " freed credentials, not used anymore");
}
if(pthread_mutex_unlock(&cred_handle_lock) < 0)
abort();
if(event_queue_get(eq, &msg) < 0)
return(-1);
- il_log(LOG_DEBUG, " trying to deliver event at offset %d for job %s\n", msg->offset, msg->job_id_s);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " trying to deliver event at offset %d for job %s",
+ msg->offset, msg->job_id_s);
#ifdef LB_PERF
if(!nosend) {
eq->timeout = 1;
} else {
eq->timeout = TIMEOUT;
- il_log(LOG_ERR, " error reading server %s reply:\n %s\n", eq->dest_name, error_get_msg());
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_WARN, " error reading server %s reply: %s",
+ eq->dest_name, error_get_msg());
}
return(0);
}
}
#endif
- il_log(LOG_DEBUG, " event sent, server %s replied with %d, %s\n", eq->dest_name, code, rep);
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_DEBUG,
+ " event sent, server %s replied with %d, %s",
+ eq->dest_name, code, rep);
free(rep);
/* the reply is back here */
if((ret == 0) &&
(error_get_maj() != IL_OK))
- il_log(LOG_ERR, "send_event: %s\n", error_get_msg());
+ glite_common_log(LOG_CATEGORY_LB_IL, LOG_PRIORITY_ERROR,
+ "send_event: %s",
+ error_get_msg());
event_queue_remove(eq);
eq->first_event_sent = 1;