/** get_logbits sets global loglevel bits */ static void get_logbits(int force) { /* needs to be called after parsing cmd-line args that can set loglevels!*/ if (force || !logbits_set) { logbits_set = 1; log_session = yaz_log_module_level("session"); log_sessiondetail = yaz_log_module_level("sessiondetail"); log_server = yaz_log_module_level("server"); } }
http_sessions_t http_sessions_create(void) { http_sessions_t hs = xmalloc(sizeof(*hs)); hs->session_list = 0; hs->mutex = 0; pazpar2_mutex_create(&hs->mutex, "http_sessions"); hs->log_level = yaz_log_module_level("HTTP"); return hs; }
iochan_man_t iochan_man_create(int no_threads) { iochan_man_t man = xmalloc(sizeof(*man)); man->channel_list = 0; man->sel_thread = 0; /* can't create sel_thread yet because we may fork */ man->sel_fd = -1; man->no_threads = no_threads; man->log_level = yaz_log_module_level("iochan"); man->iochan_mutex = 0; yaz_mutex_create(&man->iochan_mutex); return man; }
IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags, int chan_id) { IOCHAN new_iochan; if (!log_level_initialized) { log_level=yaz_log_module_level("eventl"); log_level_initialized=1; } if (!(new_iochan = (IOCHAN)xmalloc(sizeof(*new_iochan)))) return 0; new_iochan->destroyed = 0; new_iochan->fd = fd; new_iochan->flags = flags; new_iochan->fun = cb; new_iochan->force_event = 0; new_iochan->last_event = new_iochan->max_idle = 0; new_iochan->next = NULL; new_iochan->chan_id = chan_id; return new_iochan; }
int main(int argc, char **argv) { char *arg; int i, ret; int level = YLOG_LOG; int number = 1; unsigned int wait_between_log = 0; while ((ret = options("f:p:v:l:m:n:r:w:Hh", argv, argc, &arg)) != -2) { switch (ret) { case 'r': yaz_log_init_max_size(atoi(arg)); break; case 'f': yaz_log_time_format(arg); break; case 'p': yaz_log_init_prefix(arg); break; case 'v': yaz_log_init_level(yaz_log_mask_str(arg)); break; case 'l': if (!strcmp(arg, "@")) yaz_log_init_file(0); else yaz_log_init_file(arg); break; case 'n': number = atoi(arg); break; case 'm': level = yaz_log_module_level(arg); break; case 'w': wait_between_log = atoi(arg); break; case 'H': yaz_log_set_handler(hook_func, 0); break; case 0: for (i = 0; i<number; i++) { yaz_log(level, "%d %s", i, arg); #if HAVE_UNISTD_H if (wait_between_log) sleep(wait_between_log); #endif } break; case 'h': default: fprintf(stderr, "tstlog [-f logformat] [-v level] [-l file] " "[-p prefix] [-m module] [-w sec] [-r max] [-n num] [-H] msg ..\n"); exit(1); } } exit(0); }