diff --git a/src/auth.c b/src/auth.c index 9e1007a7..e891ab1c 100644 --- a/src/auth.c +++ b/src/auth.c @@ -164,7 +164,7 @@ static void queue_auth_client (auth_client *auth_user) return; } auth = auth_user->client->auth; - ICECAST_LOG_DEBUG("...refcount on auth_t %s is now %d", auth->mount, (int)auth->refcount); + ICECAST_LOG_DDEBUG("...refcount on auth_t %s is now %d", auth->mount, (int)auth->refcount); if (auth->immediate) { __handle_auth_client(auth, auth_user); } else { @@ -189,7 +189,7 @@ void auth_release (auth_t *authenticator) { thread_mutex_lock(&authenticator->lock); authenticator->refcount--; - ICECAST_LOG_DEBUG("...refcount on auth_t %s is now %d", authenticator->mount, (int)authenticator->refcount); + ICECAST_LOG_DDEBUG("...refcount on auth_t %s is now %d", authenticator->mount, (int)authenticator->refcount); if (authenticator->refcount) { thread_mutex_unlock(&authenticator->lock); @@ -235,7 +235,7 @@ void auth_addref (auth_t *authenticator) { thread_mutex_lock (&authenticator->lock); authenticator->refcount++; - ICECAST_LOG_DEBUG("...refcount on auth_t %s is now %d", authenticator->mount, (int)authenticator->refcount); + ICECAST_LOG_DDEBUG("...refcount on auth_t %s is now %d", authenticator->mount, (int)authenticator->refcount); thread_mutex_unlock (&authenticator->lock); } @@ -418,7 +418,7 @@ static void *auth_run_thread (void *arg) thread_mutex_unlock (&auth->lock); continue; } - ICECAST_LOG_DEBUG("%d client(s) pending on %s (role %s)", auth->pending_count, auth->mount, auth->role); + ICECAST_LOG_DDEBUG("%d client(s) pending on %s (role %s)", auth->pending_count, auth->mount, auth->role); auth->head = auth_user->next; if (auth->head == NULL) auth->tailp = &auth->head; @@ -447,7 +447,7 @@ static void auth_add_client(auth_t *auth, client_t *client, void (*on_no_match)( const char *origin; size_t i; - ICECAST_LOG_DEBUG("Trying to add client %p to auth %p's (role %s) queue.", client, auth, auth->role); + ICECAST_LOG_DDEBUG("Trying to add client %p to auth %p's (role %s) queue.", client, auth, auth->role); /* TODO: replace that magic number */ if (auth->pending_count > 100) { @@ -525,7 +525,7 @@ static void auth_add_client(auth_t *auth, client_t *client, void (*on_no_match)( auth_user->on_no_match = on_no_match; auth_user->on_result = on_result; auth_user->userdata = userdata; - ICECAST_LOG_DEBUG("adding client %p for authentication on %p", client, auth); + ICECAST_LOG_DDEBUG("adding client %p for authentication on %p", client, auth); queue_auth_client(auth_user); } @@ -569,7 +569,7 @@ static int get_authenticator (auth_t *auth, config_options_t *options) } do { - ICECAST_LOG_DEBUG("type is %s", auth->type); + ICECAST_LOG_DDEBUG("type is %s", auth->type); if (strcmp(auth->type, AUTH_TYPE_URL) == 0) { #ifdef HAVE_CURL diff --git a/src/connection.c b/src/connection.c index e3640f22..63d32790 100644 --- a/src/connection.c +++ b/src/connection.c @@ -585,9 +585,9 @@ static void process_request_body_queue (void) time_t timeout; size_t body_size_limit; - ICECAST_LOG_DEBUG("Processing body queue."); + ICECAST_LOG_DDEBUG("Processing body queue."); - ICECAST_LOG_DEBUG("_body_queue=%p, &_body_queue=%p, _body_queue_tail=%p", _body_queue, &_body_queue, _body_queue_tail); + ICECAST_LOG_DDEBUG("_body_queue=%p, &_body_queue=%p, _body_queue_tail=%p", _body_queue, &_body_queue, _body_queue_tail); config = config_get_config(); timeout = time(NULL) - config->body_timeout; diff --git a/src/event_log.c b/src/event_log.c index cc52ee63..9a44717e 100644 --- a/src/event_log.c +++ b/src/event_log.c @@ -27,7 +27,8 @@ typedef struct event_log { static int event_log_emit(void *state, event_t *event) { event_log_t *self = state; - ICECAST_LOG(self->level, "%s%strigger=\"%s\" uri=\"%s\" " + ICECAST_LOG(self->level, ICECAST_LOGFLAG_NONE, + "%s%strigger=\"%s\" uri=\"%s\" " "connection_id=%lu connection_ip=\"%s\" connection_time=%lli " "client_role=\"%s\" client_username=\"%s\" client_useragent=\"%s\" client_admin_command=%i", self->prefix ? self->prefix : "", self->prefix ? ": " : "", diff --git a/src/fastevent.c b/src/fastevent.c index 5ab90b64..d8e80f3c 100644 --- a/src/fastevent.c +++ b/src/fastevent.c @@ -191,7 +191,7 @@ void fastevent_emit(fastevent_type_t type, fastevent_flag_t flags, fastevent_dat va_list ap, apx; size_t i; - ICECAST_LOG_DEBUG("event: type=%i, flags=%i, datatype=%i, ...", (int)type, (int)flags, (int)datatype); + ICECAST_LOG_DDEBUG("event: type=%i, flags=%i, datatype=%i, ...", (int)type, (int)flags, (int)datatype); thread_rwlock_rlock(&fastevent_lock); row = __get_row(type); diff --git a/src/logging.h b/src/logging.h index 9ffde1f7..b436c68e 100644 --- a/src/logging.h +++ b/src/logging.h @@ -35,15 +35,25 @@ extern int playlistlog; #define ICECAST_LOGLEVEL_INFO 3 #define ICECAST_LOGLEVEL_DEBUG 4 +/* Log flags */ +#define ICECAST_LOGFLAG_NONE 0 +#define ICECAST_LOGFLAG_DEVEL 1 + /* ** Variadic macros for logging */ -#define ICECAST_LOG(level,...) log_write(errorlog, (level), CATMODULE "/", __func__, __VA_ARGS__) -#define ICECAST_LOG_ERROR(...) ICECAST_LOG(ICECAST_LOGLEVEL_ERROR, __VA_ARGS__) -#define ICECAST_LOG_WARN(...) ICECAST_LOG(ICECAST_LOGLEVEL_WARN, __VA_ARGS__) -#define ICECAST_LOG_INFO(...) ICECAST_LOG(ICECAST_LOGLEVEL_INFO, __VA_ARGS__) -#define ICECAST_LOG_DEBUG(...) ICECAST_LOG(ICECAST_LOGLEVEL_DEBUG,__VA_ARGS__) +#define ICECAST_LOG(level,flags,...) log_write(errorlog, (level), CATMODULE "/", __func__, __VA_ARGS__) + +#define ICECAST_LOG_ERROR(...) ICECAST_LOG(ICECAST_LOGLEVEL_ERROR, ICECAST_LOGFLAG_NONE, __VA_ARGS__) +#define ICECAST_LOG_WARN(...) ICECAST_LOG(ICECAST_LOGLEVEL_WARN, ICECAST_LOGFLAG_NONE, __VA_ARGS__) +#define ICECAST_LOG_INFO(...) ICECAST_LOG(ICECAST_LOGLEVEL_INFO, ICECAST_LOGFLAG_NONE, __VA_ARGS__) +#define ICECAST_LOG_DEBUG(...) ICECAST_LOG(ICECAST_LOGLEVEL_DEBUG, ICECAST_LOGFLAG_NONE, __VA_ARGS__) +/* Currently only an alias for ICECAST_LOG_DEBUG() */ +#define ICECAST_LOG_DERROR(...) ICECAST_LOG(ICECAST_LOGLEVEL_ERROR, ICECAST_LOGFLAG_DEVEL, __VA_ARGS__) +#define ICECAST_LOG_DWARN(...) ICECAST_LOG(ICECAST_LOGLEVEL_WARN, ICECAST_LOGFLAG_DEVEL, __VA_ARGS__) +#define ICECAST_LOG_DINFO(...) ICECAST_LOG(ICECAST_LOGLEVEL_INFO, ICECAST_LOGFLAG_DEVEL, __VA_ARGS__) +#define ICECAST_LOG_DDEBUG(...) ICECAST_LOG(ICECAST_LOGLEVEL_DEBUG, ICECAST_LOGFLAG_DEVEL, __VA_ARGS__) /* CATMODULE is the category or module that logging messages come from. ** we set one here in cause someone forgets in the .c file. diff --git a/src/util.c b/src/util.c index 85368319..bca5d1c5 100644 --- a/src/util.c +++ b/src/util.c @@ -970,14 +970,14 @@ const char *util_http_select_best(const char *input, const char *first, ...) return first; } - ICECAST_LOG_DEBUG("--- DUMP ---"); + ICECAST_LOG_DDEBUG("--- DUMP ---"); for (i = 0; i < kv->kvlen; i++) { - ICECAST_LOG_DEBUG("kv[%zu] = {.key='%H', .value='%H'}", i, kv->kv[i].key, kv->kv[i].value); + ICECAST_LOG_DDEBUG("kv[%zu] = {.key='%H', .value='%H'}", i, kv->kv[i].key, kv->kv[i].value); } for (i = 0; i < kv->indexlen; i++) { - ICECAST_LOG_DEBUG("index[%zu] = %zu", i, kv->index[i]); + ICECAST_LOG_DDEBUG("index[%zu] = %zu", i, kv->index[i]); } - ICECAST_LOG_DEBUG("--- END OF DUMP ---"); + ICECAST_LOG_DDEBUG("--- END OF DUMP ---"); for (h = 0; h < arglen; h++) { for (i = 0; i < kv->indexlen; i++) { @@ -1224,7 +1224,7 @@ icecast_kva_t * util_parse_http_cn(const char *cnstr) case __TOKENIZER_RESULT_EQ: /* fall through */ case __TOKENIZER_RESULT_SEMICOLON: - ICECAST_LOG_DEBUG("OK from tokenizer."); + ICECAST_LOG_DDEBUG("OK from tokenizer."); /* no-op */ break; } @@ -1246,21 +1246,21 @@ icecast_kva_t * util_parse_http_cn(const char *cnstr) switch (res) { case __TOKENIZER_RESULT_EOS: - ICECAST_LOG_DEBUG("End of string from tokenizer."); + ICECAST_LOG_DDEBUG("End of string from tokenizer."); eos = 1; continue; break; case __TOKENIZER_RESULT_COMMA: - ICECAST_LOG_DEBUG("Comma from tokenizer."); + ICECAST_LOG_DDEBUG("Comma from tokenizer."); ret->index[ret->indexlen++] = ret->kvlen; ret->kvlen++; break; case __TOKENIZER_RESULT_EQ: - ICECAST_LOG_DEBUG("Eq from tokenizer."); + ICECAST_LOG_DDEBUG("Eq from tokenizer."); /* no-op */ break; case __TOKENIZER_RESULT_SEMICOLON: - ICECAST_LOG_DEBUG("Semicolon from tokenizer."); + ICECAST_LOG_DDEBUG("Semicolon from tokenizer."); ret->kvlen++; break; default: @@ -1269,7 +1269,7 @@ icecast_kva_t * util_parse_http_cn(const char *cnstr) break; } - ICECAST_LOG_DEBUG("next..."); + ICECAST_LOG_DDEBUG("next..."); } return ret; diff --git a/src/xslt.c b/src/xslt.c index 1d33fede..963c30f7 100644 --- a/src/xslt.c +++ b/src/xslt.c @@ -301,11 +301,11 @@ static xmlDocPtr custom_loader(const xmlChar *URI, /* Get the actual xmlDoc */ if (final_URI) { - ICECAST_LOG_DEBUG("Calling xslt_loader() for \"%s\" (was: \"%s\").", final_URI, URI); + ICECAST_LOG_DDEBUG("Calling xslt_loader() for \"%s\" (was: \"%s\").", final_URI, URI); ret = xslt_loader(final_URI, dict, options, ctxt, type); xmlFree(final_URI); } else { - ICECAST_LOG_DEBUG("Calling xslt_loader() for \"%s\".", URI); + ICECAST_LOG_DDEBUG("Calling xslt_loader() for \"%s\".", URI); ret = xslt_loader(URI, dict, options, ctxt, type); } return ret;