diff --git a/src/admin.c b/src/admin.c index 81e2b6c3..93974c37 100644 --- a/src/admin.c +++ b/src/admin.c @@ -300,7 +300,7 @@ void admin_send_response (xmlDocPtr doc, client_t *client, config->adminroot_dir, PATH_SEPARATOR, xslt_template); config_release_config(); - DEBUG1("Sending XSLT (%s)", fullpath_xslt_template); + LOG_DEBUG("Sending XSLT (%s)", fullpath_xslt_template); xslt_transform(doc, fullpath_xslt_template, client); free(fullpath_xslt_template); } @@ -312,10 +312,10 @@ void admin_handle_request(client_t *client, const char *uri) const char *mount, *command_string; int command; - DEBUG1("Admin request (%s)", uri); + LOG_DEBUG("Admin request (%s)", uri); if (!((strcmp(uri, "/admin.cgi") == 0) || (strncmp("/admin/", uri, 7) == 0))) { - ERROR0("Internal error: admin request isn't"); + LOG_ERROR("Internal error: admin request isn't"); client_send_401(client); return; } @@ -327,11 +327,11 @@ void admin_handle_request(client_t *client, const char *uri) command_string = uri + 7; } - DEBUG1("Got command (%s)", command_string); + LOG_DEBUG("Got command (%s)", command_string); command = admin_get_command(command_string); if(command < 0) { - ERROR1("Error parsing command string or unrecognised command: %s", + LOG_ERROR("Error parsing command string or unrecognised command: %s", command_string); client_send_400(client, "Unrecognised command"); return; @@ -383,7 +383,7 @@ void admin_handle_request(client_t *client, const char *uri) case 0: break; default: - INFO1("Bad or missing password on mount modification admin " + LOG_INFO("Bad or missing password on mount modification admin " "request (command: %s)", command_string); client_send_401(client); /* fall through */ @@ -397,7 +397,7 @@ void admin_handle_request(client_t *client, const char *uri) if (source == NULL) { - WARN2("Admin command %s on non-existent source %s", + LOG_WARN("Admin command %s on non-existent source %s", command_string, mount); avl_tree_unlock(global.source_tree); client_send_400(client, "Source does not exist"); @@ -407,7 +407,7 @@ void admin_handle_request(client_t *client, const char *uri) if (source->running == 0 && source->on_demand == 0) { avl_tree_unlock (global.source_tree); - INFO2("Received admin command %s on unavailable mount \"%s\"", + LOG_INFO("Received admin command %s on unavailable mount \"%s\"", command_string, mount); client_send_400 (client, "Source is not available"); return; @@ -416,12 +416,12 @@ void admin_handle_request(client_t *client, const char *uri) source->shoutcast_compat == 0) { avl_tree_unlock (global.source_tree); - ERROR0 ("illegal change of metadata on non-shoutcast " + LOG_ERROR("illegal change of metadata on non-shoutcast " "compatible stream"); client_send_400 (client, "illegal metadata call"); return; } - INFO2("Received admin command %s on mount \"%s\"", + LOG_INFO("Received admin command %s on mount \"%s\"", command_string, mount); admin_handle_mount_request(client, source, command); avl_tree_unlock(global.source_tree); @@ -434,7 +434,7 @@ void admin_handle_request(client_t *client, const char *uri) mounts from the master, so handle this request validating against the relay password */ if(!connection_check_relay_pass(client->parser)) { - INFO1("Bad or missing password on admin command " + LOG_INFO("Bad or missing password on admin command " "request (command: %s)", command_string); client_send_401(client); return; @@ -442,7 +442,7 @@ void admin_handle_request(client_t *client, const char *uri) } else { if(!connection_check_admin_pass(client->parser)) { - INFO1("Bad or missing password on admin command " + LOG_INFO("Bad or missing password on admin command " "request (command: %s)", command_string); client_send_401(client); return; @@ -481,7 +481,7 @@ static void admin_handle_general_request(client_t *client, int command) command_list_mounts(client, TRANSFORMED); break; default: - WARN0("General admin request not recognised"); + LOG_WARN("General admin request not recognised"); client_send_400(client, "Unknown admin request"); return; } @@ -549,7 +549,7 @@ static void admin_handle_mount_request(client_t *client, source_t *source, command_updatemetadata(client, source, RAW); break; default: - WARN0("Mount request not recognised"); + LOG_WARN("Mount request not recognised"); client_send_400(client, "Mount request unknown"); break; } @@ -594,11 +594,11 @@ static void command_move_clients(client_t *client, source_t *source, char buf[255]; int parameters_passed = 0; - DEBUG0("Doing optional check"); + LOG_DEBUG("Doing optional check"); if((COMMAND_OPTIONAL(client, "destination", dest_source))) { parameters_passed = 1; } - DEBUG1("Done optional check (%d)", parameters_passed); + LOG_DEBUG("Done optional check (%d)", parameters_passed); if (!parameters_passed) { doc = admin_build_sourcelist(source->mount); admin_send_response(doc, client, response, @@ -627,7 +627,7 @@ static void command_move_clients(client_t *client, source_t *source, return; } - INFO2 ("source is \"%s\", destination is \"%s\"", source->mount, dest->mount); + LOG_INFO("source is \"%s\", destination is \"%s\"", source->mount, dest->mount); doc = xmlNewDoc (XMLSTR("1.0")); node = xmlNewDocNode(doc, NULL, XMLSTR("iceresponse"), NULL); @@ -748,7 +748,7 @@ static void command_manageauth(client_t *client, source_t *source, { if (mountinfo == NULL || mountinfo->auth == NULL) { - WARN1 ("manage auth request for %s but no facility available", source->mount); + LOG_WARN("manage auth request for %s but no facility available", source->mount); break; } COMMAND_OPTIONAL(client, "action", action); @@ -764,7 +764,7 @@ static void command_manageauth(client_t *client, source_t *source, if (username == NULL || password == NULL) { - WARN1 ("manage auth request add for %s but no user/pass", source->mount); + LOG_WARN("manage auth request add for %s but no user/pass", source->mount); break; } ret = mountinfo->auth->adduser(mountinfo->auth, username, password); @@ -782,7 +782,7 @@ static void command_manageauth(client_t *client, source_t *source, { if (username == NULL) { - WARN1 ("manage auth request delete for %s but no username", source->mount); + LOG_WARN("manage auth request delete for %s but no username", source->mount); break; } ret = mountinfo->auth->deleteuser(mountinfo->auth, username); @@ -860,10 +860,10 @@ static void command_kill_client(client_t *client, source_t *source, doc = xmlNewDoc (XMLSTR("1.0")); node = xmlNewDocNode(doc, NULL, XMLSTR("iceresponse"), NULL); xmlDocSetRootElement(doc, node); - DEBUG1("Response is %d", response); + LOG_DEBUG("Response is %d", response); if(listener != NULL) { - INFO1("Admin request: client %d removed", id); + LOG_INFO("Admin request: client %d removed", id); /* This tags it for removal on the next iteration of the main source * loop @@ -891,7 +891,7 @@ static void command_fallback(client_t *client, source_t *source, const char *fallback; char *old; - DEBUG0("Got fallback request"); + LOG_DEBUG("Got fallback request"); COMMAND_REQUIRE(client, "fallback", fallback); @@ -916,7 +916,7 @@ static void command_metadata(client_t *client, source_t *source, node = xmlNewDocNode (doc, NULL, XMLSTR("iceresponse"), NULL); xmlDocSetRootElement(doc, node); - DEBUG0("Got metadata update request"); + LOG_DEBUG("Got metadata update request"); COMMAND_REQUIRE(client, "mode", action); COMMAND_OPTIONAL(client, "song", song); @@ -944,7 +944,7 @@ static void command_metadata(client_t *client, source_t *source, if (song) { plugin->set_tag (plugin, "song", song, charset); - INFO2 ("Metadata on mountpoint %s changed to \"%s\"", source->mount, song); + LOG_INFO("Metadata on mountpoint %s changed to \"%s\"", source->mount, song); } else { @@ -952,7 +952,7 @@ static void command_metadata(client_t *client, source_t *source, { plugin->set_tag (plugin, "title", title, charset); plugin->set_tag (plugin, "artist", artist, charset); - INFO3("Metadata on mountpoint %s changed to \"%s - %s\"", + LOG_INFO("Metadata on mountpoint %s changed to \"%s - %s\"", source->mount, artist, title); } } @@ -983,7 +983,7 @@ static void command_shoutcast_metadata(client_t *client, source_t *source) const char *value; int same_ip = 1; - DEBUG0("Got shoutcast metadata update request"); + LOG_DEBUG("Got shoutcast metadata update request"); COMMAND_REQUIRE(client, "mode", action); COMMAND_REQUIRE(client, "song", value); @@ -1002,7 +1002,7 @@ static void command_shoutcast_metadata(client_t *client, source_t *source) source->format->set_tag (source->format, "title", value, NULL); source->format->set_tag (source->format, NULL, NULL, NULL); - DEBUG2("Metadata on mountpoint %s changed to \"%s\"", + LOG_DEBUG("Metadata on mountpoint %s changed to \"%s\"", source->mount, value); html_success(client, "Metadata update successful"); } @@ -1015,7 +1015,7 @@ static void command_shoutcast_metadata(client_t *client, source_t *source) static void command_stats(client_t *client, const char *mount, int response) { xmlDocPtr doc; - DEBUG0("Stats request, sending xml stats"); + LOG_DEBUG("Stats request, sending xml stats"); doc = stats_get_xml(1, mount); admin_send_response(doc, client, response, STATS_TRANSFORMED_REQUEST); @@ -1025,7 +1025,7 @@ static void command_stats(client_t *client, const char *mount, int response) { static void command_list_mounts(client_t *client, int response) { - DEBUG0("List mounts request"); + LOG_DEBUG("List mounts request"); if (response == PLAINTEXT) { diff --git a/src/auth.c b/src/auth.c index a95594b4..81ad3df4 100644 --- a/src/auth.c +++ b/src/auth.c @@ -59,7 +59,7 @@ static auth_client *auth_client_setup (const char *mount, client_t *client) userpass = util_base64_decode (header+6); if (userpass == NULL) { - WARN1("Base64 decode of Authorization header \"%s\" failed", + LOG_WARN("Base64 decode of Authorization header \"%s\" failed", header+6); break; } @@ -79,7 +79,7 @@ static auth_client *auth_client_setup (const char *mount, client_t *client) free (userpass); break; } - INFO1 ("unhandled authorization header: %s", header); + LOG_INFO("unhandled authorization header: %s", header); } while (0); @@ -109,17 +109,17 @@ static void queue_auth_client (auth_client *auth_user, mount_proxy *mountinfo) { if (auth_user->client == NULL || auth_user->client->auth == NULL) { - WARN1 ("internal state is incorrect for %p", auth_user->client); + LOG_WARN("internal state is incorrect for %p", auth_user->client); return; } auth = auth_user->client->auth; thread_mutex_lock (&auth->lock); } - DEBUG2 ("...refcount on auth_t %s is now %d", auth->mount, auth->refcount); + LOG_DEBUG("...refcount on auth_t %s is now %d", auth->mount, auth->refcount); *auth->tailp = auth_user; auth->tailp = &auth_user->next; auth->pending_count++; - INFO2 ("auth on %s has %d pending", auth->mount, auth->pending_count); + LOG_INFO("auth on %s has %d pending", auth->mount, auth->pending_count); thread_mutex_unlock (&auth->lock); } @@ -134,7 +134,7 @@ void auth_release (auth_t *authenticator) thread_mutex_lock (&authenticator->lock); authenticator->refcount--; - DEBUG2 ("...refcount on auth_t %s is now %d", authenticator->mount, authenticator->refcount); + LOG_DEBUG("...refcount on auth_t %s is now %d", authenticator->mount, authenticator->refcount); if (authenticator->refcount) { thread_mutex_unlock (&authenticator->lock); @@ -198,7 +198,7 @@ static void auth_new_listener (auth_t *auth, auth_client *auth_user) * can be avoided if client has disconnected */ if (is_listener_connected (client) == 0) { - DEBUG0 ("listener is no longer connected"); + LOG_DEBUG("listener is no longer connected"); client->respcode = 400; auth_release (client->auth); client->auth = NULL; @@ -217,7 +217,7 @@ static void auth_new_listener (auth_t *auth, auth_client *auth_user) { auth_release (client->auth); client->auth = NULL; - INFO1 ("client %lu failed", client->con->id); + LOG_INFO("client %lu failed", client->con->id); } } @@ -252,7 +252,7 @@ static void stream_auth_callback (auth_t *auth, auth_client *auth_user) if (client->authenticated) auth_postprocess_source (auth_user); else - WARN1 ("Failed auth for source \"%s\"", auth_user->mount); + LOG_WARN("Failed auth for source \"%s\"", auth_user->mount); } @@ -283,7 +283,7 @@ static void *auth_run_thread (void *arg) { auth_t *auth = arg; - INFO0 ("Authentication thread started"); + LOG_INFO("Authentication thread started"); while (auth->running) { /* usually no clients are waiting, so don't bother taking locks */ @@ -299,7 +299,7 @@ static void *auth_run_thread (void *arg) thread_mutex_unlock (&auth->lock); continue; } - DEBUG2 ("%d client(s) pending on %s", auth->pending_count, auth->mount); + LOG_DEBUG("%d client(s) pending on %s", auth->pending_count, auth->mount); auth->head = auth_user->next; if (auth->head == NULL) auth->tailp = &auth->head; @@ -310,7 +310,7 @@ static void *auth_run_thread (void *arg) if (auth_user->process) auth_user->process (auth, auth_user); else - ERROR0 ("client auth process not set"); + LOG_ERROR("client auth process not set"); auth_client_free (auth_user); @@ -318,7 +318,7 @@ static void *auth_run_thread (void *arg) } thread_sleep (150000); } - INFO0 ("Authenication thread shutting down"); + LOG_INFO("Authenication thread shutting down"); return NULL; } @@ -379,7 +379,7 @@ static int add_listener_to_source (source_t *source, client_t *client) int loop = 10; do { - DEBUG3 ("max on %s is %ld (cur %lu)", source->mount, + LOG_DEBUG("max on %s is %ld (cur %lu)", source->mount, source->max_listeners, source->listeners); if (source->max_listeners == -1) break; @@ -390,12 +390,12 @@ static int add_listener_to_source (source_t *source, client_t *client) { source_t *next = source_find_mount (source->fallback_mount); if (!next) { - ERROR2("Fallback '%s' for full source '%s' not found", + LOG_ERROR("Fallback '%s' for full source '%s' not found", source->mount, source->fallback_mount); return -1; } - INFO1 ("stream full trying %s", next->mount); + LOG_INFO("stream full trying %s", next->mount); source = next; loop--; continue; @@ -418,10 +418,10 @@ static int add_listener_to_source (source_t *source, client_t *client) if (source->running == 0 && source->on_demand) { /* enable on-demand relay to start, wake up the slave thread */ - DEBUG0("kicking off on-demand relay"); + LOG_DEBUG("kicking off on-demand relay"); source->on_demand_req = 1; } - DEBUG1 ("Added client to %s", source->mount); + LOG_DEBUG("Added client to %s", source->mount); return 0; } @@ -442,7 +442,7 @@ static int add_authenticated_listener (const char *mount, mount_proxy *mountinfo if (util_check_valid_extension (mount) == XSLT_CONTENT) { /* If the file exists, then transform it, otherwise, write a 404 */ - DEBUG0("Stats request, sending XSL transformed stats"); + LOG_DEBUG("Stats request, sending XSL transformed stats"); stats_transform_xslt (client, mount); return 0; } @@ -468,7 +468,7 @@ static int add_authenticated_listener (const char *mount, mount_proxy *mountinfo ret = add_listener_to_source (source, client); avl_tree_unlock (global.source_tree); if (ret == 0) - DEBUG0 ("client authenticated, passed to source"); + LOG_DEBUG("client authenticated, passed to source"); } else { @@ -511,12 +511,12 @@ void auth_postprocess_source (auth_client *auth_user) client->authenticated = 1; if (strcmp (req, "/admin.cgi") == 0 || strncmp ("/admin/metadata", req, 15) == 0) { - DEBUG2 ("metadata request (%s, %s)", req, mount); + LOG_DEBUG("metadata request (%s, %s)", req, mount); admin_handle_request (client, "/admin/metadata"); } else { - DEBUG1 ("on mountpoint %s", mount); + LOG_DEBUG("on mountpoint %s", mount); source_startup (client, mount, 0); } } @@ -544,13 +544,13 @@ void auth_add_listener (const char *mount, client_t *client) if (mountinfo->auth->pending_count > 100) { config_release_config (); - WARN0 ("too many clients awaiting authentication"); + LOG_WARN("too many clients awaiting authentication"); client_send_403 (client, "busy, please try again later"); return; } auth_user = auth_client_setup (mount, client); auth_user->process = auth_new_listener; - INFO0 ("adding client for authentication"); + LOG_INFO("adding client for authentication"); queue_auth_client (auth_user, mountinfo); config_release_config (); } @@ -594,12 +594,12 @@ static int get_authenticator (auth_t *auth, config_options_t *options) { if (auth->type == NULL) { - WARN0 ("no authentication type defined"); + LOG_WARN("no authentication type defined"); return -1; } do { - DEBUG1 ("type is %s", auth->type); + LOG_DEBUG("type is %s", auth->type); if (strcmp (auth->type, "url") == 0) { @@ -608,7 +608,7 @@ static int get_authenticator (auth_t *auth, config_options_t *options) return -1; break; #else - ERROR0 ("Auth URL disabled"); + LOG_ERROR("Auth URL disabled"); return -1; #endif } @@ -619,7 +619,7 @@ static int get_authenticator (auth_t *auth, config_options_t *options) break; } - ERROR1("Unrecognised authenticator type: \"%s\"", auth->type); + LOG_ERROR("Unrecognised authenticator type: \"%s\"", auth->type); return -1; } while (0); @@ -668,7 +668,7 @@ auth_t *auth_get_authenticator (xmlNodePtr node) } else if (xmlStrcmp (current->name, XMLSTR("text")) != 0) - WARN1 ("unknown auth setting (%s)", current->name); + LOG_WARN("unknown auth setting (%s)", current->name); } auth->type = (char*)xmlGetProp (node, XMLSTR("type")); if (get_authenticator (auth, options) < 0) @@ -709,7 +709,7 @@ int auth_stream_authenticate (client_t *client, const char *mount, mount_proxy * auth_client *auth_user = auth_client_setup (mount, client); auth_user->process = stream_auth_callback; - INFO1 ("request source auth for \"%s\"", mount); + LOG_INFO("request source auth for \"%s\"", mount); queue_auth_client (auth_user, mountinfo); return 1; } @@ -763,6 +763,6 @@ void auth_initialise (void) void auth_shutdown (void) { - INFO0 ("Auth shutdown"); + LOG_INFO("Auth shutdown"); } diff --git a/src/auth_htpasswd.c b/src/auth_htpasswd.c index 3285e866..c06f2596 100644 --- a/src/auth_htpasswd.c +++ b/src/auth_htpasswd.c @@ -115,7 +115,7 @@ static void htpasswd_recheckfile (htpasswd_auth_state *htpasswd) return; if (stat (htpasswd->filename, &file_stat) < 0) { - WARN1 ("failed to check status of %s", htpasswd->filename); + LOG_WARN("failed to check status of %s", htpasswd->filename); /* Create a dummy users tree for things to use later */ thread_rwlock_wlock (&htpasswd->file_rwlock); @@ -131,11 +131,11 @@ static void htpasswd_recheckfile (htpasswd_auth_state *htpasswd) /* common case, no update to file */ return; } - INFO1 ("re-reading htpasswd file \"%s\"", htpasswd->filename); + LOG_INFO("re-reading htpasswd file \"%s\"", htpasswd->filename); passwdfile = fopen (htpasswd->filename, "rb"); if (passwdfile == NULL) { - WARN2("Failed to open authentication database \"%s\": %s", + LOG_WARN("Failed to open authentication database \"%s\": %s", htpasswd->filename, strerror(errno)); return; } @@ -155,7 +155,7 @@ static void htpasswd_recheckfile (htpasswd_auth_state *htpasswd) sep = strrchr (line, ':'); if (sep == NULL) { - WARN2("No separator on line %d (%s)", num, htpasswd->filename); + LOG_WARN("No separator on line %d (%s)", num, htpasswd->filename); continue; } entry = calloc (1, sizeof (htpasswd_user)); @@ -189,7 +189,7 @@ static auth_result htpasswd_auth (auth_client *auth_user) if (htpasswd->filename == NULL) { - ERROR0("No filename given in options for authenticator."); + LOG_ERROR("No filename given in options for authenticator."); return AUTH_FAILED; } htpasswd_recheckfile (htpasswd); @@ -209,10 +209,10 @@ static auth_result htpasswd_auth (auth_client *auth_user) return AUTH_OK; } free (hashed_pw); - DEBUG0 ("incorrect password for client"); + LOG_DEBUG("incorrect password for client"); return AUTH_FAILED; } - DEBUG1 ("no such username: %s", client->username); + LOG_DEBUG("no such username: %s", client->username); thread_rwlock_unlock (&htpasswd->file_rwlock); return AUTH_FAILED; } @@ -240,10 +240,10 @@ int auth_get_htpasswd_auth (auth_t *authenticator, config_options_t *options) } if (state->filename) - INFO1("Configured htpasswd authentication using password file \"%s\"", + LOG_INFO("Configured htpasswd authentication using password file \"%s\"", state->filename); else - ERROR0("No filename given in options for authenticator."); + LOG_ERROR("No filename given in options for authenticator."); authenticator->state = state; @@ -278,7 +278,7 @@ static auth_result htpasswd_adduser (auth_t *auth, const char *username, const c if (passwdfile == NULL) { thread_rwlock_unlock (&state->file_rwlock); - WARN2("Failed to open authentication database \"%s\": %s", + LOG_WARN("Failed to open authentication database \"%s\": %s", state->filename, strerror(errno)); return AUTH_FAILED; } @@ -312,7 +312,7 @@ static auth_result htpasswd_deleteuser(auth_t *auth, const char *username) passwdfile = fopen(state->filename, "rb"); if(passwdfile == NULL) { - WARN2("Failed to open authentication database \"%s\": %s", + LOG_WARN("Failed to open authentication database \"%s\": %s", state->filename, strerror(errno)); thread_rwlock_unlock (&state->file_rwlock); return AUTH_FAILED; @@ -322,7 +322,7 @@ static auth_result htpasswd_deleteuser(auth_t *auth, const char *username) snprintf (tmpfile, tmpfile_len, "%s.tmp", state->filename); if (stat (tmpfile, &file_info) == 0) { - WARN1 ("temp file \"%s\" exists, rejecting operation", tmpfile); + LOG_WARN("temp file \"%s\" exists, rejecting operation", tmpfile); free (tmpfile); fclose (passwdfile); thread_rwlock_unlock (&state->file_rwlock); @@ -332,7 +332,7 @@ static auth_result htpasswd_deleteuser(auth_t *auth, const char *username) tmp_passwdfile = fopen(tmpfile, "wb"); if(tmp_passwdfile == NULL) { - WARN2("Failed to open temporary authentication database \"%s\": %s", + LOG_WARN("Failed to open temporary authentication database \"%s\": %s", tmpfile, strerror(errno)); fclose(passwdfile); free(tmpfile); @@ -347,7 +347,7 @@ static auth_result htpasswd_deleteuser(auth_t *auth, const char *username) sep = strchr(line, ':'); if(sep == NULL) { - DEBUG0("No separator in line"); + LOG_DEBUG("No separator in line"); continue; } @@ -367,12 +367,12 @@ static auth_result htpasswd_deleteuser(auth_t *auth, const char *username) /* Windows won't let us rename a file if the destination file exists...so, lets remove the original first */ if (remove(state->filename) != 0) { - ERROR3("Problem moving temp authentication file to original \"%s\" - \"%s\": %s", + LOG_ERROR("Problem moving temp authentication file to original \"%s\" - \"%s\": %s", tmpfile, state->filename, strerror(errno)); } else { if (rename(tmpfile, state->filename) != 0) { - ERROR3("Problem moving temp authentication file to original \"%s\" - \"%s\": %s", + LOG_ERROR("Problem moving temp authentication file to original \"%s\" - \"%s\": %s", tmpfile, state->filename, strerror(errno)); } } diff --git a/src/auth_url.c b/src/auth_url.c index 00a26ac9..d6f0288e 100644 --- a/src/auth_url.c +++ b/src/auth_url.c @@ -109,7 +109,7 @@ static void auth_url_clear(auth_t *self) { auth_url *url; - INFO0 ("Doing auth URL cleanup"); + LOG_INFO("Doing auth URL cleanup"); url = self->state; self->state = NULL; curl_easy_cleanup (url->handle); @@ -263,7 +263,7 @@ static auth_result url_remove_listener (auth_client *auth_user) curl_easy_setopt (url->handle, CURLOPT_WRITEHEADER, auth_user); if (curl_easy_perform (url->handle)) - WARN2 ("auth to server %s failed with %s", url->removeurl, url->errormsg); + LOG_WARN("auth to server %s failed with %s", url->removeurl, url->errormsg); free (userpwd); @@ -394,13 +394,13 @@ static auth_result url_add_listener (auth_client *auth_user) if (res) { - WARN2 ("auth to server %s failed with %s", url->addurl, url->errormsg); + LOG_WARN("auth to server %s failed with %s", url->addurl, url->errormsg); return AUTH_FAILED; } /* we received a response, lets see what it is */ if (client->authenticated) return AUTH_OK; - INFO2 ("client auth (%s) failed with \"%s\"", url->addurl, url->errormsg); + LOG_INFO("client auth (%s) failed with \"%s\"", url->addurl, url->errormsg); return AUTH_FAILED; } @@ -452,7 +452,7 @@ static void url_stream_start (auth_client *auth_user) curl_easy_setopt (url->handle, CURLOPT_WRITEHEADER, auth_user); if (curl_easy_perform (url->handle)) - WARN2 ("auth to server %s failed with %s", stream_start_url, url->errormsg); + LOG_WARN("auth to server %s failed with %s", stream_start_url, url->errormsg); auth_release (auth); free (stream_start_url); @@ -504,7 +504,7 @@ static void url_stream_end (auth_client *auth_user) curl_easy_setopt (url->handle, CURLOPT_WRITEHEADER, auth_user); if (curl_easy_perform (url->handle)) - WARN2 ("auth to server %s failed with %s", stream_end_url, url->errormsg); + LOG_WARN("auth to server %s failed with %s", stream_end_url, url->errormsg); auth_release (auth); free (stream_end_url); @@ -554,7 +554,7 @@ static void url_stream_auth (auth_client *auth_user) client->authenticated = 0; if (curl_easy_perform (url->handle)) - WARN2 ("auth to server %s failed with %s", url->stream_auth, url->errormsg); + LOG_WARN("auth to server %s failed with %s", url->stream_auth, url->errormsg); } @@ -683,7 +683,7 @@ int auth_get_url_auth (auth_t *authenticator, config_options_t *options) snprintf (url_info->userpwd, len, "%s:%s", url_info->username, url_info->password); } - INFO0("URL based authentication setup"); + LOG_INFO("URL based authentication setup"); return 0; } diff --git a/src/cfgfile.c b/src/cfgfile.c index 61d7a927..a911b4f5 100644 --- a/src/cfgfile.c +++ b/src/cfgfile.c @@ -417,7 +417,7 @@ static void _parse_root(xmlDocPtr doc, xmlNodePtr node, _parse_authentication(doc, node->xmlChildrenNode, configuration); } else if (xmlStrcmp (node->name, XMLSTR("source-password")) == 0) { /* TODO: This is the backwards-compatibility location */ - WARN0(" defined outside . This is deprecated."); + LOG_WARN(" defined outside . This is deprecated."); if (configuration->source_password) xmlFree(configuration->source_password); configuration->source_password = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1); } else if (xmlStrcmp (node->name, XMLSTR("icelogin")) == 0) { @@ -572,7 +572,7 @@ static void _parse_mount(xmlDocPtr doc, xmlNodePtr node, mount->mounttype = MOUNT_TYPE_DEFAULT; } else { - WARN1("Unknown mountpoint type: %s", tmp); + LOG_WARN("Unknown mountpoint type: %s", tmp); config_clear_mount (mount); return; } @@ -718,7 +718,7 @@ static void _parse_mount(xmlDocPtr doc, xmlNodePtr node, } else if (mount->mountname != NULL && mount->mounttype == MOUNT_TYPE_DEFAULT) { - WARN1("Default mount %s has mount-name set. This is not supported. Behavior may not be consistent.", mount->mountname); + LOG_WARN("Default mount %s has mount-name set. This is not supported. Behavior may not be consistent.", mount->mountname); } if (mount->auth) mount->auth->mount = strdup ((char *)mount->mountname); @@ -729,7 +729,7 @@ static void _parse_mount(xmlDocPtr doc, xmlNodePtr node, if (!mount->fallback_mount && (mount->fallback_when_full || mount->fallback_override)) { - WARN1("Config for mount %s contains fallback options but no fallback mount.", mount->mountname); + LOG_WARN("Config for mount %s contains fallback options but no fallback mount.", mount->mountname); } if(last) @@ -893,7 +893,7 @@ static void _parse_authentication(xmlDocPtr doc, xmlNodePtr node, if (xmlStrcmp (node->name, XMLSTR("source-password")) == 0) { if (xmlGetProp(node, XMLSTR("mount"))) { - ERROR0("Mount level source password defined within global section."); + LOG_ERROR("Mount level source password defined within global section."); } else { if (configuration->source_password) @@ -931,7 +931,7 @@ static void _parse_directory(xmlDocPtr doc, xmlNodePtr node, char *tmp; if (configuration->num_yp_directories >= MAX_YP_DIRECTORIES) { - ERROR0("Maximum number of yp directories exceeded!"); + LOG_ERROR("Maximum number of yp directories exceeded!"); return; } do { diff --git a/src/client.c b/src/client.c index a911bcfc..2935db6e 100644 --- a/src/client.c +++ b/src/client.c @@ -65,7 +65,7 @@ int client_create (client_t **c_ptr, connection_t *con, http_parser_t *parser) global.clients++; if (config->client_limit < global.clients) - WARN2 ("server client limit reached (%d/%d)", config->client_limit, global.clients); + LOG_WARN("server client limit reached (%d/%d)", config->client_limit, global.clients); else ret = 0; @@ -178,7 +178,7 @@ int client_read_bytes (client_t *client, void *buf, unsigned len) bytes = client->con->read (client->con, buf, len); if (bytes == -1 && client->con->error) - DEBUG0 ("reading from connection has failed"); + LOG_DEBUG("reading from connection has failed"); return bytes; } @@ -235,7 +235,7 @@ int client_send_bytes (client_t *client, const void *buf, unsigned len) int ret = client->con->send (client->con, buf, len); if (client->con->error) - DEBUG0 ("Client connection died"); + LOG_DEBUG("Client connection died"); return ret; } diff --git a/src/connection.c b/src/connection.c index e94115e2..14547566 100644 --- a/src/connection.c +++ b/src/connection.c @@ -212,29 +212,29 @@ static void get_ssl_certificate (ice_config_t *config) break; if (SSL_CTX_use_certificate_chain_file (ssl_ctx, config->cert_file) <= 0) { - WARN1 ("Invalid cert file %s", config->cert_file); + LOG_WARN("Invalid cert file %s", config->cert_file); break; } if (SSL_CTX_use_PrivateKey_file (ssl_ctx, config->cert_file, SSL_FILETYPE_PEM) <= 0) { - WARN1 ("Invalid private key file %s", config->cert_file); + LOG_WARN("Invalid private key file %s", config->cert_file); break; } if (!SSL_CTX_check_private_key (ssl_ctx)) { - ERROR1 ("Invalid %s - Private key does not match cert public key", config->cert_file); + LOG_ERROR("Invalid %s - Private key does not match cert public key", config->cert_file); break; } if (SSL_CTX_set_cipher_list(ssl_ctx, config->cipher_list) <= 0) { - WARN1 ("Invalid cipher list: %s", config->cipher_list); + LOG_WARN("Invalid cipher list: %s", config->cipher_list); } ssl_ok = 1; - INFO1 ("SSL certificate found at %s", config->cert_file); - INFO1 ("SSL using ciphers %s", config->cipher_list); + LOG_INFO("SSL certificate found at %s", config->cert_file); + LOG_INFO("SSL using ciphers %s", config->cipher_list); return; } while (0); - INFO0 ("No SSL capability on any configured ports"); + LOG_INFO("No SSL capability on any configured ports"); } @@ -282,7 +282,7 @@ static int connection_send_ssl (connection_t *con, const void *buf, size_t len) static void get_ssl_certificate (ice_config_t *config) { ssl_ok = 0; - INFO0 ("No SSL capability"); + LOG_INFO("No SSL capability"); } #endif /* HAVE_OPENSSL */ @@ -340,7 +340,7 @@ static void recheck_ip_file (cache_file_contents *cache) } if (stat (cache->filename, &file_stat) < 0) { - WARN2 ("failed to check status of \"%s\": %s", cache->filename, strerror(errno)); + LOG_WARN("failed to check status of \"%s\": %s", cache->filename, strerror(errno)); return; } if (file_stat.st_mtime == cache->file_mtime) @@ -351,7 +351,7 @@ static void recheck_ip_file (cache_file_contents *cache) file = fopen (cache->filename, "r"); if (file == NULL) { - WARN2("Failed to open file \"%s\": %s", cache->filename, strerror (errno)); + LOG_WARN("Failed to open file \"%s\": %s", cache->filename, strerror (errno)); return; } @@ -368,7 +368,7 @@ static void recheck_ip_file (cache_file_contents *cache) avl_insert (new_ips, str); } fclose (file); - INFO2 ("%d entries read from file \"%s\"", count, cache->filename); + LOG_INFO("%d entries read from file \"%s\"", count, cache->filename); if (cache->contents) avl_tree_free (cache->contents, free_filtered_ip); cache->contents = new_ips; @@ -388,7 +388,7 @@ static int accept_ip_address (char *ip) { if (avl_get_by_key (banned_ip.contents, ip, &result) == 0) { - DEBUG1 ("%s is banned", ip); + LOG_DEBUG("%s is banned", ip); return 0; } } @@ -396,12 +396,12 @@ static int accept_ip_address (char *ip) { if (avl_get_by_key (allowed_ip.contents, ip, &result) == 0) { - DEBUG1 ("%s is allowed", ip); + LOG_DEBUG("%s is allowed", ip); return 1; } else { - DEBUG1 ("%s is not allowed", ip); + LOG_DEBUG("%s is not allowed", ip); return 0; } } @@ -469,7 +469,7 @@ static sock_t wait_for_serversock(int timeout) if (ufds[i].revents & (POLLHUP|POLLERR)) { sock_close (global.serversock[i]); - WARN0("Had to close a listening socket"); + LOG_WARN("Had to close a listening socket"); } global.serversock[i] = SOCK_ERROR; } @@ -553,7 +553,7 @@ static connection_t *_accept_connection(int duration) { if (!sock_recoverable(sock_error())) { - WARN2("accept() failed with error %d: %s", sock_error(), strerror(sock_error())); + LOG_WARN("accept() failed with error %d: %s", sock_error(), strerror(sock_error())); thread_sleep (500000); } } @@ -740,7 +740,7 @@ void connection_accept_loop (void) if (sock_set_blocking (client->con->sock, 0) || sock_set_nodelay (client->con->sock)) { global_unlock(); - WARN0 ("failed to set tcp options on client connection, dropping"); + LOG_WARN("failed to set tcp options on client connection, dropping"); client_destroy (client); continue; } @@ -798,7 +798,7 @@ int connection_complete_source (source_t *source, int response) ice_config_t *config; global_lock (); - DEBUG1 ("sources count is %d", global.sources); + LOG_DEBUG("sources count is %d", global.sources); config = config_get_config(); if (global.sources < config->source_limit) @@ -823,13 +823,13 @@ int connection_complete_source (source_t *source, int response) client_send_403 (source->client, "Content-type not supported"); source->client = NULL; } - WARN1("Content-type \"%s\" not supported, dropping source", contenttype); + LOG_WARN("Content-type \"%s\" not supported, dropping source", contenttype); return -1; } } else { - WARN0("No content-type header, falling back to backwards compatibility mode " + LOG_WARN("No content-type header, falling back to backwards compatibility mode " "for icecast 1.x relays. Assuming content is mp3."); format_type = FORMAT_TYPE_GENERIC; } @@ -843,7 +843,7 @@ int connection_complete_source (source_t *source, int response) client_send_403 (source->client, "internal format allocation problem"); source->client = NULL; } - WARN1 ("plugin format failed for \"%s\"", source->mount); + LOG_WARN("plugin format failed for \"%s\"", source->mount); return -1; } @@ -854,7 +854,7 @@ int connection_complete_source (source_t *source, int response) #ifdef HAVE_STRCASESTR if (strcasestr (expectcontinue, "100-continue") != NULL) #else - WARN0("OS doesn't support case insenestive substring checks..."); + LOG_WARN("OS doesn't support case insenestive substring checks..."); if (strstr (expectcontinue, "100-continue") != NULL) #endif { @@ -873,11 +873,11 @@ int connection_complete_source (source_t *source, int response) slave_rebuild_mounts(); source->shutdown_rwlock = &_source_shutdown_rwlock; - DEBUG0 ("source is ready to start"); + LOG_DEBUG("source is ready to start"); return 0; } - WARN1("Request to add source when maximum source limit " + LOG_WARN("Request to add source when maximum source limit " "reached %d", global.sources); global_unlock(); @@ -909,7 +909,7 @@ static int _check_pass_http(http_parser_t *parser, userpass = util_base64_decode(header+6); if(userpass == NULL) { - WARN1("Base64 decode of Authorization header \"%s\" failed", + LOG_WARN("Base64 decode of Authorization header \"%s\" failed", header+6); return 0; } @@ -1008,7 +1008,7 @@ int connection_check_pass (http_parser_t *parser, const char *user, const char * const char *protocol; if(!pass) { - WARN0("No source password set, rejecting source"); + LOG_WARN("No source password set, rejecting source"); return -1; } @@ -1025,7 +1025,7 @@ int connection_check_pass (http_parser_t *parser, const char *user, const char * { ret = _check_pass_ice(parser, pass); if(ret) - WARN0("Source is using deprecated icecast login"); + LOG_WARN("Source is using deprecated icecast login"); } } } @@ -1036,11 +1036,11 @@ int connection_check_pass (http_parser_t *parser, const char *user, const char * /* only called for native icecast source clients */ static void _handle_source_request (client_t *client, const char *uri) { - INFO1("Source logging in at mountpoint \"%s\"", uri); + LOG_INFO("Source logging in at mountpoint \"%s\"", uri); if (uri[0] != '/') { - WARN0 ("source mountpoint not starting with /"); + LOG_WARN("source mountpoint not starting with /"); client_send_401 (client); return; } @@ -1054,7 +1054,7 @@ static void _handle_source_request (client_t *client, const char *uri) break; default: /* failed */ - INFO1("Source (%s) attempted to login with invalid or missing password", uri); + LOG_INFO("Source (%s) attempted to login with invalid or missing password", uri); client_send_401(client); break; } @@ -1099,7 +1099,7 @@ void source_startup (client_t *client, const char *uri, int auth_style) else { client_send_403 (client, "Mountpoint in use"); - WARN1 ("Mountpoint %s in use", uri); + LOG_WARN("Mountpoint %s in use", uri); } } @@ -1111,7 +1111,7 @@ static void _handle_stats_request (client_t *client, char *uri) if (connection_check_admin_pass (client->parser) == 0) { client_send_401 (client); - ERROR0("Bad password for stats connection"); + LOG_ERROR("Bad password for stats connection"); return; } @@ -1157,7 +1157,7 @@ static void _handle_get_request (client_t *client, char *passed_uri) while(alias) { if(strcmp(uri, alias->source) == 0 && (alias->port == -1 || alias->port == serverport) && (alias->bind_address == NULL || (serverhost != NULL && strcmp(alias->bind_address, serverhost) == 0))) { uri = strdup (alias->destination); - DEBUG2 ("alias has made %s into %s", passed_uri, uri); + LOG_DEBUG("alias has made %s into %s", passed_uri, uri); break; } alias = alias->next; @@ -1249,7 +1249,7 @@ static void _handle_shoutcast_compatible (client_queue_t *node) return; } else - INFO1 ("password does not match \"%s\"", client->refbuf->data); + LOG_INFO("password does not match \"%s\"", client->refbuf->data); client_destroy (client); free (source_password); free (node->shoutcast_mount); @@ -1347,7 +1347,7 @@ static void _handle_connection(void) if (strcmp("ICE", httpp_getvar(parser, HTTPP_VAR_PROTOCOL)) && strcmp("HTTP", httpp_getvar(parser, HTTPP_VAR_PROTOCOL))) { - ERROR0("Bad HTTP protocol detected"); + LOG_ERROR("Bad HTTP protocol detected"); client_destroy (client); continue; } @@ -1370,7 +1370,7 @@ static void _handle_connection(void) _handle_get_request (client, uri); } else { - ERROR0("Wrong request type from client"); + LOG_ERROR("Wrong request type from client"); client_send_400 (client, "unknown request"); } @@ -1379,7 +1379,7 @@ static void _handle_connection(void) else { free (node); - ERROR0("HTTP request parsing failed"); + LOG_ERROR("HTTP request parsing failed"); client_destroy (client); } continue; @@ -1451,19 +1451,19 @@ int connection_setup_sockets (ice_config_t *config) if (successful == 0) { if (listener->bind_address) - ERROR2 ("Could not create listener socket on port %d bind %s", + LOG_ERROR("Could not create listener socket on port %d bind %s", listener->port, listener->bind_address); else - ERROR1 ("Could not create listener socket on port %d", listener->port); + LOG_ERROR("Could not create listener socket on port %d", listener->port); /* remove failed connection */ *prev = config_clear_listener (listener); listener = *prev; continue; } if (listener->bind_address) - INFO2 ("listener socket on port %d address %s", listener->port, listener->bind_address); + LOG_INFO("listener socket on port %d address %s", listener->port, listener->bind_address); else - INFO1 ("listener socket on port %d", listener->port); + LOG_INFO("listener socket on port %d", listener->port); prev = &listener->next; listener = listener->next; } @@ -1471,7 +1471,7 @@ int connection_setup_sockets (ice_config_t *config) global_unlock(); if (count == 0) - ERROR0 ("No listening sockets established"); + LOG_ERROR("No listening sockets established"); return count; } diff --git a/src/event.c b/src/event.c index c0851755..e5e3e938 100644 --- a/src/event.c +++ b/src/event.c @@ -40,20 +40,20 @@ void event_config_read(void *arg) xmlSetGenericErrorFunc ("config", log_parse_failure); ret = config_parse_file(config->config_filename, &new_config); if(ret < 0) { - ERROR0("Error parsing config, not replacing existing config"); + LOG_ERROR("Error parsing config, not replacing existing config"); switch(ret) { case CONFIG_EINSANE: - ERROR0("Config filename null or blank"); + LOG_ERROR("Config filename null or blank"); break; case CONFIG_ENOROOT: - ERROR1("Root element not found in %s", config->config_filename); + LOG_ERROR("Root element not found in %s", config->config_filename); break; case CONFIG_EBADROOT: - ERROR1("Not an icecast2 config file: %s", + LOG_ERROR("Not an icecast2 config file: %s", config->config_filename); break; default: - ERROR1("Parse error in reading %s", config->config_filename); + LOG_ERROR("Parse error in reading %s", config->config_filename); break; } config_release_config(); diff --git a/src/format.c b/src/format.c index 32d85365..6c4386d6 100644 --- a/src/format.c +++ b/src/format.c @@ -79,7 +79,7 @@ format_type_t format_get_type (const char *contenttype) /* We default to the Generic format handler, which can handle many more formats than just mp3. Let's warn that this is not well supported */ - WARN1("Unsupported or legacy stream type: \"%s\". Falling back to generic minimal handler for best effort.", contenttype); + LOG_WARN("Unsupported or legacy stream type: \"%s\". Falling back to generic minimal handler for best effort.", contenttype); return FORMAT_TYPE_GENERIC; } @@ -221,11 +221,11 @@ int format_check_http_buffer (source_t *source, client_t *client) if (client->respcode == 0) { - DEBUG0("processing pending client headers"); + LOG_DEBUG("processing pending client headers"); if (format_prepare_headers (source, client) < 0) { - ERROR0 ("internal problem, dropping client"); + LOG_ERROR("internal problem, dropping client"); client->con->error = 1; return -1; } diff --git a/src/format_ebml.c b/src/format_ebml.c index 28bd3376..ce5d3e9e 100644 --- a/src/format_ebml.c +++ b/src/format_ebml.c @@ -201,7 +201,7 @@ static refbuf_t *ebml_get_buffer (source_t *source) format->read_bytes += bytes; ret = ebml_wrote (ebml_source_state->ebml, bytes); if (ret != bytes) { - ERROR0 ("Problem processing stream"); + LOG_ERROR("Problem processing stream"); source->running = 0; return NULL; } @@ -244,7 +244,7 @@ static void ebml_free_client_data (client_t *client) static void ebml_write_buf_to_file_fail (source_t *source) { - WARN0 ("Write to dump file failed, disabling"); + LOG_WARN("Write to dump file failed, disabling"); fclose (source->dumpfile); source->dumpfile = NULL; } @@ -420,7 +420,7 @@ static int ebml_wrote(ebml_t *ebml, int len) { if ((ebml->header_position + len) > EBML_HEADER_MAX_SIZE) { - ERROR0("EBML Header too large, failing"); + LOG_ERROR("EBML Header too large, failing"); return -1; } diff --git a/src/format_flac.c b/src/format_flac.c index 949debdf..cdff609c 100644 --- a/src/format_flac.c +++ b/src/format_flac.c @@ -34,7 +34,7 @@ typedef struct source_tag source_t; static void flac_codec_free (ogg_state_t *ogg_info, ogg_codec_t *codec) { - DEBUG0 ("freeing FLAC codec"); + LOG_DEBUG("freeing FLAC codec"); stats_event (ogg_info->mount, "FLAC_version", NULL); ogg_stream_clear (&codec->os); free (codec); @@ -93,7 +93,7 @@ ogg_codec_t *initial_flac_page (format_plugin_t *plugin, ogg_page *page) ogg_stream_packetout (&codec->os, &packet); - DEBUG0("checking for FLAC codec"); + LOG_DEBUG("checking for FLAC codec"); do { unsigned char *parse = packet.packet; @@ -106,7 +106,7 @@ ogg_codec_t *initial_flac_page (format_plugin_t *plugin, ogg_page *page) if (memcmp (parse, "FLAC", 4) != 0) break; - INFO0 ("seen initial FLAC header"); + LOG_INFO("seen initial FLAC header"); parse += 4; stats_event_args (ogg_info->mount, "FLAC_version", "%d.%d", parse[0], parse[1]); diff --git a/src/format_kate.c b/src/format_kate.c index a5ee80c4..9af66724 100644 --- a/src/format_kate.c +++ b/src/format_kate.c @@ -54,7 +54,7 @@ static void kate_codec_free (ogg_state_t *ogg_info, ogg_codec_t *codec) { kate_codec_t *kate = codec->specific; - DEBUG0 ("freeing kate codec"); + LOG_DEBUG("freeing kate codec"); /* TODO: should i replace with something or just remove stats_event (ogg_info->mount, "video_bitrate", NULL); stats_event (ogg_info->mount, "video_quality", NULL); @@ -98,7 +98,7 @@ static refbuf_t *process_kate_page (ogg_state_t *ogg_info, ogg_codec_t *codec, o if (ret < 0) { ogg_info->error = 1; - WARN0 ("problem with kate header"); + LOG_WARN("problem with kate header"); return NULL; } header_page = 1; @@ -139,7 +139,7 @@ static refbuf_t *process_kate_page (ogg_state_t *ogg_info, ogg_codec_t *codec, o if (codec->headers < kate->num_headers) { ogg_info->error = 1; - ERROR0 ("Not enough header packets"); + LOG_ERROR("Not enough header packets"); return NULL; } } @@ -150,7 +150,7 @@ static refbuf_t *process_kate_page (ogg_state_t *ogg_info, ogg_codec_t *codec, o } refbuf = make_refbuf_with_page (page); - /* DEBUG3 ("refbuf %p has pageno %ld, %llu", refbuf, ogg_page_pageno (page), (uint64_t)granulepos); */ + /* LOG_DEBUG("refbuf %p has pageno %ld, %llu", refbuf, ogg_page_pageno (page), (uint64_t)granulepos); */ if (codec->possible_start) { @@ -196,7 +196,7 @@ ogg_codec_t *initial_kate_page (format_plugin_t *plugin, ogg_page *page) ogg_stream_packetout (&codec->os, &packet); - DEBUG0("checking for kate codec"); + LOG_DEBUG("checking for kate codec"); #ifdef HAVE_KATE if (kate_ogg_decode_headerin (&kate_codec->ki, &kate_codec->kc, &packet) < 0) { @@ -218,7 +218,7 @@ ogg_codec_t *initial_kate_page (format_plugin_t *plugin, ogg_page *page) } #endif - INFO0 ("seen initial kate header"); + LOG_INFO("seen initial kate header"); codec->specific = kate_codec; codec->process_page = process_kate_page; codec->codec_free = kate_codec_free; diff --git a/src/format_midi.c b/src/format_midi.c index 070416fe..32971357 100644 --- a/src/format_midi.c +++ b/src/format_midi.c @@ -34,7 +34,7 @@ typedef struct source_tag source_t; static void midi_codec_free (ogg_state_t *ogg_info, ogg_codec_t *codec) { - DEBUG0 ("freeing MIDI codec"); + LOG_DEBUG("freeing MIDI codec"); ogg_stream_clear (&codec->os); free (codec); } @@ -68,7 +68,7 @@ ogg_codec_t *initial_midi_page (format_plugin_t *plugin, ogg_page *page) ogg_stream_packetout (&codec->os, &packet); - DEBUG0("checking for MIDI codec"); + LOG_DEBUG("checking for MIDI codec"); do { if (packet.bytes < 9) @@ -78,7 +78,7 @@ ogg_codec_t *initial_midi_page (format_plugin_t *plugin, ogg_page *page) if (packet.bytes != 12) break; - INFO0 ("seen initial MIDI header"); + LOG_INFO("seen initial MIDI header"); codec->process_page = process_midi_page; codec->codec_free = midi_codec_free; codec->headers = 1; diff --git a/src/format_mp3.c b/src/format_mp3.c index 26dd6c39..1272d2ba 100644 --- a/src/format_mp3.c +++ b/src/format_mp3.c @@ -227,8 +227,8 @@ static void format_mp3_apply_settings (client_t *client, format_plugin_t *format if (format->charset == NULL) format->charset = strdup ("ISO8859-1"); - DEBUG1 ("sending metadata interval %d", source_mp3->interval); - DEBUG1 ("charset %s", format->charset); + LOG_DEBUG("sending metadata interval %d", source_mp3->interval); + LOG_DEBUG("charset %s", format->charset); } @@ -267,7 +267,7 @@ static void mp3_set_title (source_t *source) if (len > MAX_META_LEN) { thread_mutex_unlock (&source_mp3->url_lock); - WARN1 ("Metadata too long at %d chars", len); + LOG_WARN("Metadata too long at %d chars", len); return; } /* work out the metadata len byte */ @@ -302,7 +302,7 @@ static void mp3_set_title (source_t *source) else if (source_mp3->url) snprintf (p->data+r, size-r, "StreamUrl='%s';", source_mp3->url); } - DEBUG1 ("shoutcast metadata block setup with %s", p->data+1); + LOG_DEBUG("shoutcast metadata block setup with %s", p->data+1); filter_shoutcast_metadata (source, p->data, size); refbuf_release (source_mp3->metadata); @@ -621,7 +621,7 @@ static refbuf_t *mp3_get_filter_meta (source_t *source) memcpy (meta->data, source_mp3->build_metadata, source_mp3->build_metadata_len); - DEBUG2("shoutcast metadata %.*s", 4080, meta->data+1); + LOG_DEBUG("shoutcast metadata %.*s", 4080, meta->data+1); if (strncmp (meta->data+1, "StreamTitle=", 12) == 0) { filter_shoutcast_metadata (source, source_mp3->build_metadata, @@ -632,7 +632,7 @@ static refbuf_t *mp3_get_filter_meta (source_t *source) } else { - ERROR0 ("Incorrect metadata format, ending stream"); + LOG_ERROR("Incorrect metadata format, ending stream"); source->running = 0; refbuf_release (refbuf); refbuf_release (meta); @@ -724,7 +724,7 @@ static void write_mp3_to_file (struct source_tag *source, refbuf_t *refbuf) return; if (fwrite (refbuf->data, 1, refbuf->len, source->dumpfile) < (size_t)refbuf->len) { - WARN0 ("Write to dump file failed, disabling"); + LOG_WARN("Write to dump file failed, disabling"); fclose (source->dumpfile); source->dumpfile = NULL; } diff --git a/src/format_ogg.c b/src/format_ogg.c index 3f6018f9..ec8d4a72 100644 --- a/src/format_ogg.c +++ b/src/format_ogg.c @@ -92,7 +92,7 @@ void format_ogg_attach_header (ogg_state_t *ogg_info, ogg_page *page) if (ogg_page_bos (page)) { - DEBUG0 ("attaching BOS page"); + LOG_DEBUG("attaching BOS page"); if (*ogg_info->bos_end == NULL) ogg_info->header_pages_tail = refbuf; refbuf->next = *ogg_info->bos_end; @@ -100,7 +100,7 @@ void format_ogg_attach_header (ogg_state_t *ogg_info, ogg_page *page) ogg_info->bos_end = &refbuf->next; return; } - DEBUG0 ("attaching header page"); + LOG_DEBUG("attaching header page"); if (ogg_info->header_pages_tail) ogg_info->header_pages_tail->next = refbuf; ogg_info->header_pages_tail = refbuf; @@ -115,7 +115,7 @@ void format_ogg_free_headers (ogg_state_t *ogg_info) refbuf_t *header; /* release the header pages first */ - DEBUG0 ("releasing header pages"); + LOG_DEBUG("releasing header pages"); header = ogg_info->header_pages; while (header) { @@ -141,7 +141,7 @@ static void free_ogg_codecs (ogg_state_t *ogg_info) /* now free the codecs */ codec = ogg_info->codecs; - DEBUG0 ("freeing codecs"); + LOG_DEBUG("freeing codecs"); while (codec) { ogg_codec_t *next = codec->next; @@ -219,7 +219,7 @@ static int process_initial_page (format_plugin_t *plugin, ogg_page *page) { if (ogg_info->codec_count > 10) { - ERROR0 ("many codecs in stream, playing safe, dropping source"); + LOG_ERROR("many codecs in stream, playing safe, dropping source"); ogg_info->error = 1; return -1; } @@ -253,7 +253,7 @@ static int process_initial_page (format_plugin_t *plugin, ogg_page *page) break; /* any others */ - ERROR0 ("Seen BOS page with unknown type"); + LOG_ERROR("Seen BOS page with unknown type"); ogg_info->error = 1; return -1; } while (0); @@ -430,7 +430,7 @@ static refbuf_t *ogg_get_buffer (source_t *source) } if (ogg_info->error) { - ERROR0 ("Problem processing stream"); + LOG_ERROR("Problem processing stream"); source->running = 0; return NULL; } @@ -564,7 +564,7 @@ static int write_ogg_data (struct source_tag *source, refbuf_t *refbuf) if (fwrite (refbuf->data, 1, refbuf->len, source->dumpfile) != refbuf->len) { - WARN0 ("Write to dump file failed, disabling"); + LOG_WARN("Write to dump file failed, disabling"); fclose (source->dumpfile); source->dumpfile = NULL; ret = 0; diff --git a/src/format_opus.c b/src/format_opus.c index 441a7748..217cbf68 100644 --- a/src/format_opus.c +++ b/src/format_opus.c @@ -70,14 +70,14 @@ ogg_codec_t *initial_opus_page (format_plugin_t *plugin, ogg_page *page) ogg_stream_packetout (&codec->os, &packet); - DEBUG0("checking for opus codec"); + LOG_DEBUG("checking for opus codec"); if (strncmp((char *)packet.packet, "OpusHead", 8) != 0) { ogg_stream_clear (&codec->os); free (codec); return NULL; } - INFO0 ("seen initial opus header"); + LOG_INFO("seen initial opus header"); codec->process_page = process_opus_page; codec->codec_free = opus_codec_free; codec->headers = 1; diff --git a/src/format_skeleton.c b/src/format_skeleton.c index 1b82e8f5..9ab413f3 100644 --- a/src/format_skeleton.c +++ b/src/format_skeleton.c @@ -35,7 +35,7 @@ typedef struct source_tag source_t; static void skeleton_codec_free (ogg_state_t *ogg_info, ogg_codec_t *codec) { - DEBUG0 ("freeing skeleton codec"); + LOG_DEBUG("freeing skeleton codec"); ogg_stream_clear (&codec->os); free (codec); } @@ -79,7 +79,7 @@ ogg_codec_t *initial_skeleton_page (format_plugin_t *plugin, ogg_page *page) ogg_stream_packetout (&codec->os, &packet); - DEBUG0("checking for skeleton codec"); + LOG_DEBUG("checking for skeleton codec"); if ((packet.bytes<8) || memcmp(packet.packet, "fishead\0", 8)) { @@ -88,7 +88,7 @@ ogg_codec_t *initial_skeleton_page (format_plugin_t *plugin, ogg_page *page) return NULL; } - INFO0 ("seen initial skeleton header"); + LOG_INFO("seen initial skeleton header"); codec->process_page = process_skeleton_page; codec->codec_free = skeleton_codec_free; codec->headers = 1; diff --git a/src/format_speex.c b/src/format_speex.c index fd8de7f9..18f00f60 100644 --- a/src/format_speex.c +++ b/src/format_speex.c @@ -73,7 +73,7 @@ ogg_codec_t *initial_speex_page (format_plugin_t *plugin, ogg_page *page) ogg_stream_packetout (&codec->os, &packet); - DEBUG0("checking for speex codec"); + LOG_DEBUG("checking for speex codec"); header = speex_packet_to_header ((char*)packet.packet, packet.bytes); if (header == NULL) { @@ -82,7 +82,7 @@ ogg_codec_t *initial_speex_page (format_plugin_t *plugin, ogg_page *page) free (codec); return NULL; } - INFO0 ("seen initial speex header"); + LOG_INFO("seen initial speex header"); codec->process_page = process_speex_page; codec->codec_free = speex_codec_free; codec->headers = 1; diff --git a/src/format_theora.c b/src/format_theora.c index c009d88e..db2d780f 100644 --- a/src/format_theora.c +++ b/src/format_theora.c @@ -47,7 +47,7 @@ static void theora_codec_free (ogg_state_t *ogg_info, ogg_codec_t *codec) { theora_codec_t *theora = codec->specific; - DEBUG0 ("freeing theora codec"); + LOG_DEBUG("freeing theora codec"); stats_event (ogg_info->mount, "video_bitrate", NULL); stats_event (ogg_info->mount, "video_quality", NULL); stats_event (ogg_info->mount, "frame_rate", NULL); @@ -86,7 +86,7 @@ static refbuf_t *process_theora_page (ogg_state_t *ogg_info, ogg_codec_t *codec, if (theora_decode_header (&theora->ti, &theora->tc, &packet) < 0) { ogg_info->error = 1; - WARN0 ("problem with theora header"); + LOG_WARN("problem with theora header"); return NULL; } header_page = 1; @@ -109,7 +109,7 @@ static refbuf_t *process_theora_page (ogg_state_t *ogg_info, ogg_codec_t *codec, if (codec->headers < 3) { ogg_info->error = 1; - ERROR0 ("Not enough header packets"); + LOG_ERROR("Not enough header packets"); return NULL; } if (theora_packet_iskeyframe (&packet)) @@ -122,7 +122,7 @@ static refbuf_t *process_theora_page (ogg_state_t *ogg_info, ogg_codec_t *codec, } refbuf = make_refbuf_with_page (page); - /* DEBUG3 ("refbuf %p has pageno %ld, %llu", refbuf, ogg_page_pageno (page), (uint64_t)granulepos); */ + /* LOG_DEBUG("refbuf %p has pageno %ld, %llu", refbuf, ogg_page_pageno (page), (uint64_t)granulepos); */ if (granulepos != theora->prev_granulepos || granulepos == 0) { @@ -162,7 +162,7 @@ ogg_codec_t *initial_theora_page (format_plugin_t *plugin, ogg_page *page) ogg_stream_packetout (&codec->os, &packet); - DEBUG0("checking for theora codec"); + LOG_DEBUG("checking for theora codec"); if (theora_decode_header (&theora_codec->ti, &theora_codec->tc, &packet) < 0) { theora_info_clear (&theora_codec->ti); @@ -172,7 +172,7 @@ ogg_codec_t *initial_theora_page (format_plugin_t *plugin, ogg_page *page) free (codec); return NULL; } - INFO0 ("seen initial theora header"); + LOG_INFO("seen initial theora header"); codec->specific = theora_codec; codec->process_page = process_theora_page; codec->codec_free = theora_codec_free; diff --git a/src/format_vorbis.c b/src/format_vorbis.c index 269a932f..7a979862 100644 --- a/src/format_vorbis.c +++ b/src/format_vorbis.c @@ -84,7 +84,7 @@ static void vorbis_codec_free (ogg_state_t *ogg_info, ogg_codec_t *codec) { vorbis_codec_t *vorbis = codec->specific; - DEBUG0 ("freeing vorbis codec"); + LOG_DEBUG("freeing vorbis codec"); stats_event (ogg_info->mount, "audio_bitrate", NULL); stats_event (ogg_info->mount, "audio_channels", NULL); stats_event (ogg_info->mount, "audio_samplerate", NULL); @@ -195,7 +195,7 @@ static refbuf_t *get_buffer_finished (ogg_state_t *ogg_info, ogg_codec_t *codec) source_vorbis->prev_page_samples = ogg_page_granulepos (&page); refbuf = make_refbuf_with_page (&page); - DEBUG0 ("flushing page"); + LOG_DEBUG("flushing page"); return refbuf; } ogg_stream_clear (&source_vorbis->new_os); @@ -221,7 +221,7 @@ static void initiate_flush (vorbis_codec_t *source_vorbis) if (source_vorbis->prev_packet) { /* insert prev_packet with eos */ - DEBUG0 ("adding EOS packet"); + LOG_DEBUG("adding EOS packet"); source_vorbis->prev_packet->e_o_s = 1; add_audio_packet (source_vorbis, source_vorbis->prev_packet); source_vorbis->prev_packet->e_o_s = 0; @@ -318,7 +318,7 @@ static int process_vorbis_headers (ogg_state_t *ogg_info, ogg_codec_t *codec) if (source_vorbis->header [0] == NULL) return 0; - DEBUG0 ("Adding the 3 header packets"); + LOG_DEBUG("Adding the 3 header packets"); ogg_stream_packetin (&source_vorbis->new_os, source_vorbis->header [0]); /* NOTE: we could build a separate comment packet each time */ if (source_vorbis->rebuild_comment) @@ -373,7 +373,7 @@ ogg_codec_t *initial_vorbis_page (format_plugin_t *plugin, ogg_page *page) ogg_stream_packetout (&codec->os, &packet); - DEBUG0("checking for vorbis codec"); + LOG_DEBUG("checking for vorbis codec"); if (vorbis_synthesis_headerin (&vorbis->vi, &vorbis->vc, &packet) < 0) { ogg_stream_clear (&codec->os); @@ -383,7 +383,7 @@ ogg_codec_t *initial_vorbis_page (format_plugin_t *plugin, ogg_page *page) free (codec); return NULL; } - INFO0 ("seen initial vorbis header"); + LOG_INFO("seen initial vorbis header"); codec->specific = vorbis; codec->codec_free = vorbis_codec_free; codec->headers = 1; @@ -523,7 +523,7 @@ static refbuf_t *process_vorbis_page (ogg_state_t *ogg_info, while (codec->headers < 3) { /* now, lets extract the packets */ - DEBUG1 ("processing incoming header packet (%d)", codec->headers); + LOG_DEBUG("processing incoming header packet (%d)", codec->headers); if (ogg_stream_packetout (&codec->os, &header) <= 0) { @@ -536,14 +536,14 @@ static refbuf_t *process_vorbis_page (ogg_state_t *ogg_info, if (vorbis_synthesis_headerin (&source_vorbis->vi, &source_vorbis->vc, &header) < 0) { ogg_info->error = 1; - WARN0 ("Problem parsing ogg vorbis header"); + LOG_WARN("Problem parsing ogg vorbis header"); return NULL; } header.granulepos = 0; source_vorbis->header [codec->headers] = copy_ogg_packet (&header); codec->headers++; } - DEBUG0 ("we have the header packets now"); + LOG_DEBUG("we have the header packets now"); /* if vorbis is the only codec then allow rebuilding of the streams */ if (ogg_info->codecs->next == NULL) diff --git a/src/fserve.c b/src/fserve.c index bd44c0b7..dbbb35dc 100644 --- a/src/fserve.c +++ b/src/fserve.c @@ -106,7 +106,7 @@ void fserve_initialize(void) config_release_config(); stats_event (NULL, "file_connections", "0"); - INFO0("file serving started"); + LOG_INFO("file serving started"); } void fserve_shutdown(void) @@ -132,7 +132,7 @@ void fserve_shutdown(void) thread_spin_unlock (&pending_lock); thread_spin_destroy (&pending_lock); - INFO0("file serving stopped"); + LOG_INFO("file serving stopped"); } #ifdef HAVE_POLL @@ -330,7 +330,7 @@ static void *fserv_thread_function(void *arg) fclient = fclient->next; } } - DEBUG0 ("fserve handler exit"); + LOG_DEBUG("fserve handler exit"); return NULL; } @@ -412,7 +412,7 @@ int fserve_client_create (client_t *httpclient, const char *path) FILE *file; fullpath = util_get_path_from_normalised_uri (path); - INFO2 ("checking for file %H (%H)", path, fullpath); + LOG_INFO("checking for file %H (%H)", path, fullpath); if (strcmp (util_get_extension (fullpath), "m3u") == 0) m3u_requested = 1; @@ -429,7 +429,7 @@ int fserve_client_create (client_t *httpclient, const char *path) /* the m3u can be generated, but send an m3u file if available */ if (m3u_requested == 0 && xslt_playlist_requested == NULL) { - WARN2 ("req for file \"%H\" %s", fullpath, strerror (errno)); + LOG_WARN("req for file \"%H\" %s", fullpath, strerror (errno)); client_send_404 (httpclient, "The file you requested could not be found"); free (fullpath); return -1; @@ -499,7 +499,7 @@ int fserve_client_create (client_t *httpclient, const char *path) config = config_get_config(); if (config->fileserve == 0) { - DEBUG1 ("on demand file \"%H\" refused", fullpath); + LOG_DEBUG("on demand file \"%H\" refused", fullpath); client_send_404 (httpclient, "The file you requested could not be found"); config_release_config(); free (fullpath); @@ -510,7 +510,7 @@ int fserve_client_create (client_t *httpclient, const char *path) if (S_ISREG (file_buf.st_mode) == 0) { client_send_404 (httpclient, "The file you requested could not be found"); - WARN1 ("found requested file but there is no handler for it: %H", fullpath); + LOG_WARN("found requested file but there is no handler for it: %H", fullpath); free (fullpath); return -1; } @@ -518,7 +518,7 @@ int fserve_client_create (client_t *httpclient, const char *path) file = fopen (fullpath, "rb"); if (file == NULL) { - WARN1 ("Problem accessing file \"%H\"", fullpath); + LOG_WARN("Problem accessing file \"%H\"", fullpath); client_send_404 (httpclient, "File not readable"); free (fullpath); return -1; @@ -627,7 +627,7 @@ static void fserve_add_pending (fserve_t *fclient) if (run_fserv == 0) { run_fserv = 1; - DEBUG0 ("fserve handler waking up"); + LOG_DEBUG("fserve handler waking up"); thread_create("File Serving Thread", fserv_thread_function, NULL, THREAD_DETACHED); } thread_spin_unlock (&pending_lock); @@ -641,7 +641,7 @@ int fserve_add_client (client_t *client, FILE *file) { fserve_t *fclient = calloc (1, sizeof(fserve_t)); - DEBUG0 ("Adding client to file serving engine"); + LOG_DEBUG("Adding client to file serving engine"); if (fclient == NULL) { client_send_404 (client, "memory exhausted"); @@ -663,7 +663,7 @@ void fserve_add_client_callback (client_t *client, fserve_callback_t callback, v { fserve_t *fclient = calloc (1, sizeof(fserve_t)); - DEBUG0 ("Adding client to file serving engine"); + LOG_DEBUG("Adding client to file serving engine"); if (fclient == NULL) { client_send_404 (client, "memory exhausted"); @@ -708,7 +708,7 @@ void fserve_recheck_mime_types (ice_config_t *config) mimefile = fopen (config->mimetypes_fn, "r"); if (mimefile == NULL) { - WARN1 ("Cannot open mime types file %s", config->mimetypes_fn); + LOG_WARN("Cannot open mime types file %s", config->mimetypes_fn); return; } diff --git a/src/logging.h b/src/logging.h index 89c503fa..eabe3672 100644 --- a/src/logging.h +++ b/src/logging.h @@ -22,39 +22,19 @@ extern int errorlog; extern int accesslog; extern int playlistlog; -/* these are all ERRORx and WARNx where _x_ is the number of parameters -** it takes. it turns out most other copmilers don't have support for -** varargs macros. that totally sucks, but this is still pretty easy. -** -** feel free to add more here if needed. -*/ - #ifdef _WIN32 #include #define __func__ strrchr (__FILE__, '\\') ? strrchr (__FILE__, '\\') + 1 : __FILE__ #endif -#define ERROR0(y) log_write(errorlog, 1, CATMODULE "/", __func__, y) -#define ERROR1(y, a) log_write(errorlog, 1, CATMODULE "/", __func__, y, a) -#define ERROR2(y, a, b) log_write(errorlog, 1, CATMODULE "/", __func__, y, a, b) -#define ERROR3(y, a, b, c) log_write(errorlog, 1, CATMODULE "/", __func__, y, a, b, c) -#define ERROR4(y, a, b, c, d) log_write(errorlog, 1, CATMODULE "/", __func__, y, a, b, c, d) +/* +** Variadic macros for logging +*/ -#define WARN0(y) log_write(errorlog, 2, CATMODULE "/", __func__, y) -#define WARN1(y, a) log_write(errorlog, 2, CATMODULE "/", __func__, y, a) -#define WARN2(y, a, b) log_write(errorlog, 2, CATMODULE "/", __func__, y, a, b) -#define WARN3(y, a, b, c) log_write(errorlog, 2, CATMODULE "/", __func__, y, a, b, c) - -#define INFO0(y) log_write(errorlog, 3, CATMODULE "/", __func__, y) -#define INFO1(y, a) log_write(errorlog, 3, CATMODULE "/", __func__, y, a) -#define INFO2(y, a, b) log_write(errorlog, 3, CATMODULE "/", __func__, y, a, b) -#define INFO3(y, a, b, c) log_write(errorlog, 3, CATMODULE "/", __func__, y, a, b, c) - -#define DEBUG0(y) log_write(errorlog, 4, CATMODULE "/", __func__, y) -#define DEBUG1(y, a) log_write(errorlog, 4, CATMODULE "/", __func__, y, a) -#define DEBUG2(y, a, b) log_write(errorlog, 4, CATMODULE "/", __func__, y, a, b) -#define DEBUG3(y, a, b, c) log_write(errorlog, 4, CATMODULE "/", __func__, y, a, b, c) -#define DEBUG4(y, a, b, c, d) log_write(errorlog, 4, CATMODULE "/", __func__, y, a, b, c, d) +#define LOG_ERROR(...) log_write(errorlog, 1, CATMODULE "/", __func__, __VA_ARGS__) +#define LOG_WARN(...) log_write(errorlog, 2, CATMODULE "/", __func__, __VA_ARGS__) +#define LOG_INFO(...) log_write(errorlog, 3, CATMODULE "/", __func__, __VA_ARGS__) +#define LOG_DEBUG(...) log_write(errorlog, 4, CATMODULE "/", __func__, __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/main.c b/src/main.c index 9d555e8e..0022de0e 100644 --- a/src/main.c +++ b/src/main.c @@ -503,7 +503,7 @@ int main(int argc, char **argv) return 1; } - INFO1 ("%s server started", ICECAST_VERSION_STRING); + LOG_INFO("%s server started", ICECAST_VERSION_STRING); /* REM 3D Graphics */ @@ -519,7 +519,7 @@ int main(int argc, char **argv) _server_proc(); - INFO0("Shutting down"); + LOG_INFO("Shutting down"); #if !defined(_WIN32) || defined(_CONSOLE) || defined(__MINGW32__) || defined(__MINGW64__) shutdown_subsystems(); #endif diff --git a/src/refbuf.c b/src/refbuf.c index 70ebadd1..2bea6200 100644 --- a/src/refbuf.c +++ b/src/refbuf.c @@ -89,7 +89,7 @@ void refbuf_release(refbuf_t *self) { refbuf_release_associated (self->associated); if (self->next) - ERROR0 ("next not null"); + LOG_ERROR("next not null"); free(self->data); free(self); } diff --git a/src/sighandler.c b/src/sighandler.c index d31d5c9a..beee5a69 100644 --- a/src/sighandler.c +++ b/src/sighandler.c @@ -55,7 +55,7 @@ void _sig_ignore(int signo) void _sig_hup(int signo) { - INFO1("Caught signal %d, scheduling config re-read...", signo); + LOG_INFO("Caught signal %d, scheduling config re-read...", signo); global_lock(); global . schedule_config_reread = 1; @@ -67,7 +67,7 @@ void _sig_hup(int signo) void _sig_die(int signo) { - INFO1("Caught signal %d, shutting down...", signo); + LOG_INFO("Caught signal %d, shutting down...", signo); /* inform the server to start shutting down */ global.running = ICE_HALTING; diff --git a/src/slave.c b/src/slave.c index c0d7353f..bd35aac6 100644 --- a/src/slave.c +++ b/src/slave.c @@ -70,7 +70,7 @@ static mutex_t _slave_mutex; // protects update_settings, update_all_mounts, max relay_server *relay_free (relay_server *relay) { relay_server *next = relay->next; - DEBUG1("freeing relay %s", relay->localmount); + LOG_DEBUG("freeing relay %s", relay->localmount); if (relay->source) source_free_source (relay->source); xmlFree (relay->server); @@ -147,7 +147,7 @@ void slave_shutdown(void) if (!slave_running) return; slave_running = 0; - DEBUG0 ("waiting for slave thread"); + LOG_DEBUG("waiting for slave thread"); thread_join (_slave_thread_id); } @@ -195,12 +195,12 @@ static client_t *open_relay_connection (relay_server *relay) { sock_t streamsock; - INFO2 ("connecting to %s:%d", server, port); + LOG_INFO("connecting to %s:%d", server, port); streamsock = sock_connect_wto_bind (server, port, relay->bind, 10); if (streamsock == SOCK_ERROR) { - WARN2 ("Failed to connect to %s:%d", server, port); + LOG_WARN("Failed to connect to %s:%d", server, port); break; } con = connection_create (streamsock, -1, strdup (server)); @@ -224,14 +224,14 @@ static client_t *open_relay_connection (relay_server *relay) memset (header, 0, sizeof(header)); if (util_read_header (con->sock, header, 4096, READ_ENTIRE_HEADER) == 0) { - ERROR4 ("Header read failed for %s (%s:%d%s)", relay->localmount, server, port, mount); + LOG_ERROR("Header read failed for %s (%s:%d%s)", relay->localmount, server, port, mount); break; } parser = httpp_create_parser(); httpp_initialize (parser, NULL); if (! httpp_parse_response (parser, header, strlen(header), relay->localmount)) { - ERROR4("Error parsing relay request for %s (%s:%d%s)", relay->localmount, + LOG_ERROR("Error parsing relay request for %s (%s:%d%s)", relay->localmount, server, port, mount); break; } @@ -242,7 +242,7 @@ static client_t *open_relay_connection (relay_server *relay) int len; uri = httpp_getvar (parser, "location"); - INFO1 ("redirect received %s", uri); + LOG_INFO("redirect received %s", uri); if (strncmp (uri, "http://", 7) != 0) break; uri += 7; @@ -271,7 +271,7 @@ static client_t *open_relay_connection (relay_server *relay) if (httpp_getvar (parser, HTTPP_VAR_ERROR_MESSAGE)) { - ERROR2("Error from relay request: %s (%s)", relay->localmount, + LOG_ERROR("Error from relay request: %s (%s)", relay->localmount, httpp_getvar(parser, HTTPP_VAR_ERROR_MESSAGE)); break; } @@ -319,7 +319,7 @@ static void *start_relay_stream (void *arg) source_t *src = relay->source; client_t *client; - INFO1("Starting relayed source at mountpoint \"%s\"", relay->localmount); + LOG_INFO("Starting relayed source at mountpoint \"%s\"", relay->localmount); do { client = open_relay_connection (relay); @@ -333,7 +333,7 @@ static void *start_relay_stream (void *arg) if (connection_complete_source (src, 0) < 0) { - INFO0("Failed to complete source initialisation"); + LOG_INFO("Failed to complete source initialisation"); client_destroy (client); src->client = NULL; continue; @@ -363,7 +363,7 @@ static void *start_relay_stream (void *arg) { source_t *fallback_source; - DEBUG1 ("failed relay, fallback to %s", relay->source->fallback_mount); + LOG_DEBUG("failed relay, fallback to %s", relay->source->fallback_mount); avl_tree_rlock(global.source_tree); fallback_source = source_find_mount (relay->source->fallback_mount); @@ -395,7 +395,7 @@ static void check_relay_stream (relay_server *relay) { if (relay->localmount[0] != '/') { - WARN1 ("relay mountpoint \"%s\" does not start with /, skipping", + LOG_WARN("relay mountpoint \"%s\" does not start with /, skipping", relay->localmount); return; } @@ -403,7 +403,7 @@ static void check_relay_stream (relay_server *relay) relay->source = source_reserve (relay->localmount); if (relay->source) { - DEBUG1("Adding relay source at mountpoint \"%s\"", relay->localmount); + LOG_DEBUG("Adding relay source at mountpoint \"%s\"", relay->localmount); if (relay->on_demand) { ice_config_t *config = config_get_config (); @@ -419,7 +419,7 @@ static void check_relay_stream (relay_server *relay) { if (relay->start == 0) { - WARN1 ("new relay but source \"%s\" already exists", relay->localmount); + LOG_WARN("new relay but source \"%s\" already exists", relay->localmount); relay->start = 1; } return; @@ -443,7 +443,7 @@ static void check_relay_stream (relay_server *relay) fallback = source_find_mount (source->fallback_mount); if (fallback && fallback->running && fallback->listeners) { - DEBUG2 ("fallback running %d with %lu listeners", fallback->running, fallback->listeners); + LOG_DEBUG("fallback running %d with %lu listeners", fallback->running, fallback->listeners); source->on_demand_req = 1; } avl_tree_unlock (global.source_tree); @@ -464,7 +464,7 @@ static void check_relay_stream (relay_server *relay) { if (relay->thread) { - DEBUG1 ("waiting for relay thread for \"%s\"", relay->localmount); + LOG_DEBUG("waiting for relay thread for \"%s\"", relay->localmount); thread_join (relay->thread); relay->thread = NULL; } @@ -579,7 +579,7 @@ static void relay_check_streams (relay_server *to_start, if (to_free->running) { /* relay has been removed from xml, shut down active relay */ - DEBUG1 ("source shutdown request on \"%s\"", to_free->localmount); + LOG_DEBUG("source shutdown request on \"%s\"", to_free->localmount); to_free->running = 0; to_free->source->running = 0; thread_join (to_free->thread); @@ -633,7 +633,7 @@ static int update_from_master(ice_config_t *config) if (mastersock == SOCK_ERROR) { - WARN0("Relay slave failed to contact master server to fetch stream list"); + LOG_WARN("Relay slave failed to contact master server to fetch stream list"); break; } @@ -652,7 +652,7 @@ static int update_from_master(ice_config_t *config) strncmp (buf, "HTTP/1.0 200", 12) != 0) { sock_close (mastersock); - WARN0 ("Master rejected streamlist request"); + LOG_WARN("Master rejected streamlist request"); break; } @@ -666,10 +666,10 @@ static int update_from_master(ice_config_t *config) relay_server *r; if (!strlen(buf)) continue; - DEBUG2 ("read %d from master \"%s\"", count++, buf); + LOG_DEBUG("read %d from master \"%s\"", count++, buf); xmlURIPtr parsed_uri = xmlParseURI(buf); if (parsed_uri == NULL) { - DEBUG0("Error while parsing line from master. Ignoring line."); + LOG_DEBUG("Error while parsing line from master. Ignoring line."); continue; } r = calloc (1, sizeof (relay_server)); @@ -694,7 +694,7 @@ static int update_from_master(ice_config_t *config) r->mp3metadata = 1; r->on_demand = on_demand; r->next = new_relays; - DEBUG3 ("Added relay host=\"%s\", port=%d, mount=\"%s\"", r->server, r->port, r->mount); + LOG_DEBUG("Added relay host=\"%s\", port=%d, mount=\"%s\"", r->server, r->port, r->mount); new_relays = r; } xmlFreeURI(parsed_uri); @@ -761,7 +761,7 @@ static void *_slave_thread(void *arg) thread_mutex_lock(&_slave_mutex); if (max_interval <= interval) { - DEBUG0 ("checking master stream list"); + LOG_DEBUG("checking master stream list"); config = config_get_config(); if (max_interval == 0) @@ -799,11 +799,11 @@ static void *_slave_thread(void *arg) } thread_mutex_unlock(&_slave_mutex); } - INFO0 ("shutting down current relays"); + LOG_INFO("shutting down current relays"); relay_check_streams (NULL, global.relays, 0); relay_check_streams (NULL, global.master_relays, 0); - INFO0 ("Slave thread shutdown complete"); + LOG_INFO("Slave thread shutdown complete"); return NULL; } diff --git a/src/source.c b/src/source.c index 375c9ef1..12cd0a93 100644 --- a/src/source.c +++ b/src/source.c @@ -66,7 +66,7 @@ static int _free_client(void *key); static void _parse_audio_info (source_t *source, const char *s); static void source_shutdown (source_t *source); #ifdef _WIN32 -#define source_run_script(x,y) WARN0("on [dis]connect scripts disabled"); +#define source_run_script(x,y) LOG_WARN("on [dis]connect scripts disabled"); #else static void source_run_script (char *command, char *mountpoint); #endif @@ -80,7 +80,7 @@ source_t *source_reserve (const char *mount) source_t *src = NULL; if(mount[0] != '/') - WARN1("Source at \"%s\" does not start with '/', clients will be " + LOG_WARN("Source at \"%s\" does not start with '/', clients will be " "unable to connect", mount); do @@ -197,7 +197,7 @@ void source_clear_source (source_t *source) { int c; - DEBUG1 ("clearing source \"%s\"", source->mount); + LOG_DEBUG("clearing source \"%s\"", source->mount); avl_tree_wlock (source->pending_tree); client_destroy(source->client); @@ -211,7 +211,7 @@ void source_clear_source (source_t *source) if (source->dumpfile) { - INFO1 ("Closing dumpfile for %s", source->mount); + LOG_INFO("Closing dumpfile for %s", source->mount); fclose (source->dumpfile); source->dumpfile = NULL; } @@ -235,7 +235,7 @@ void source_clear_source (source_t *source) if (c) { stats_event_sub (NULL, "listeners", source->listeners); - INFO2 ("%d active listeners on %s released", c, source->mount); + LOG_INFO("%d active listeners on %s released", c, source->mount); } avl_tree_unlock (source->client_tree); @@ -296,7 +296,7 @@ void source_clear_source (source_t *source) /* Remove the provided source from the global tree and free it */ void source_free_source (source_t *source) { - DEBUG1 ("freeing source \"%s\"", source->mount); + LOG_DEBUG("freeing source \"%s\"", source->mount); avl_tree_wlock (global.source_tree); avl_delete (global.source_tree, source, NULL); avl_tree_unlock (global.source_tree); @@ -345,7 +345,7 @@ void source_move_clients (source_t *source, source_t *dest) unsigned long count = 0; if (strcmp (source->mount, dest->mount) == 0) { - WARN1 ("src and dst are the same \"%s\", skipping", source->mount); + LOG_WARN("src and dst are the same \"%s\", skipping", source->mount); return; } /* we don't want the two write locks to deadlock in here */ @@ -356,7 +356,7 @@ void source_move_clients (source_t *source, source_t *dest) avl_tree_wlock (dest->pending_tree); if (dest->running == 0 && dest->on_demand == 0) { - WARN1 ("destination mount %s not running, unable to move clients ", dest->mount); + LOG_WARN("destination mount %s not running, unable to move clients ", dest->mount); avl_tree_unlock (dest->pending_tree); thread_mutex_unlock (&move_clients_mutex); return; @@ -373,14 +373,14 @@ void source_move_clients (source_t *source, source_t *dest) if (source->on_demand == 0 && source->format == NULL) { - INFO1 ("source mount %s is not available", source->mount); + LOG_INFO("source mount %s is not available", source->mount); break; } if (source->format && dest->format) { if (source->format->type != dest->format->type) { - WARN2 ("stream %s and %s are of different types, ignored", source->mount, dest->mount); + LOG_WARN("stream %s and %s are of different types, ignored", source->mount, dest->mount); break; } } @@ -432,7 +432,7 @@ void source_move_clients (source_t *source, source_t *dest) avl_insert (dest->pending_tree, (void *)client); count++; } - INFO2 ("passing %lu listeners to \"%s\"", count, dest->mount); + LOG_INFO("passing %lu listeners to \"%s\"", count, dest->mount); source->listeners = 0; stats_event (source->mount, "listeners", "0"); @@ -487,7 +487,7 @@ static refbuf_t *get_next_buffer (source_t *source) { if (! sock_recoverable (sock_error())) { - WARN0 ("Error while waiting on socket, Disconnecting source"); + LOG_WARN("Error while waiting on socket, Disconnecting source"); source->running = 0; } break; @@ -497,9 +497,9 @@ static refbuf_t *get_next_buffer (source_t *source) thread_mutex_lock(&source->lock); if ((source->last_read + (time_t)source->timeout) < current) { - DEBUG3 ("last %ld, timeout %d, now %ld", (long)source->last_read, + LOG_DEBUG("last %ld, timeout %d, now %ld", (long)source->last_read, source->timeout, (long)current); - WARN0 ("Disconnecting source due to socket timeout"); + LOG_WARN("Disconnecting source due to socket timeout"); source->running = 0; } thread_mutex_unlock(&source->lock); @@ -509,7 +509,7 @@ static refbuf_t *get_next_buffer (source_t *source) refbuf = source->format->get_buffer (source); if (source->client->con && source->client->con->error) { - INFO1 ("End of Stream %s", source->mount); + LOG_INFO("End of Stream %s", source->mount); source->running = 0; continue; } @@ -538,7 +538,7 @@ static void send_to_listener (source_t *source, client_t *client, int deletion_e if (client->con->discon_time) if (time(NULL) >= client->con->discon_time) { - INFO1 ("time limit reached for client #%lu", client->con->id); + LOG_INFO("time limit reached for client #%lu", client->con->id); client->con->error = 1; } @@ -572,7 +572,7 @@ static void send_to_listener (source_t *source, client_t *client, int deletion_e * if so, check to see if this client is still referring to it */ if (deletion_expected && client->refbuf && client->refbuf == source->stream_data) { - INFO2 ("Client %lu (%s) has fallen too far behind, removing", + LOG_INFO("Client %lu (%s) has fallen too far behind, removing", client->con->id, client->con->ip); stats_event_inc (source->mount, "slow_listeners"); client->con->error = 1; @@ -641,7 +641,7 @@ static void source_init (source_t *source) source->dumpfile = source_open_dumpfile (source->dumpfilename); if (source->dumpfile == NULL) { - WARN2("Cannot open dump file \"%s\" for appending: %s, disabling.", + LOG_WARN("Cannot open dump file \"%s\" for appending: %s, disabling.", source->dumpfilename, strerror(errno)); } } @@ -658,7 +658,7 @@ static void source_init (source_t *source) stats_event_time (source->mount, "stream_start"); stats_event_time_iso8601 (source->mount, "stream_start_iso8601"); - DEBUG0("Source creation complete"); + LOG_DEBUG("Source creation complete"); source->last_read = time (NULL); source->prev_listeners = -1; source->running = 1; @@ -769,7 +769,7 @@ void source_main (source_t *source) stats_event_dec (NULL, "listeners"); avl_delete(source->client_tree, (void *)client, _free_client); source->listeners--; - DEBUG0("Client removed"); + LOG_DEBUG("Client removed"); continue; } client_node = avl_get_next(client_node); @@ -791,7 +791,7 @@ void source_main (source_t *source) client_node = avl_get_next(client_node); avl_delete(source->pending_tree, (void *)client, _free_client); - INFO0("Client deleted, exceeding maximum listeners for this " + LOG_INFO("Client deleted, exceeding maximum listeners for this " "mountpoint."); continue; } @@ -800,7 +800,7 @@ void source_main (source_t *source) avl_insert(source->client_tree, client_node->key); source->listeners++; - DEBUG0("Client added"); + LOG_DEBUG("Client added"); stats_event_inc(source->mount, "connections"); client_node = avl_get_next(client_node); @@ -820,7 +820,7 @@ void source_main (source_t *source) if (source->listeners != source->prev_listeners) { source->prev_listeners = source->listeners; - INFO2("listener count on %s now %lu", source->mount, source->listeners); + LOG_INFO("listener count on %s now %lu", source->mount, source->listeners); if (source->listeners > source->peak_listeners) { source->peak_listeners = source->listeners; @@ -846,7 +846,7 @@ void source_main (source_t *source) if (to_go->next == NULL || source->burst_point == to_go) { /* this should not happen */ - ERROR0 ("queue state is unexpected"); + LOG_ERROR("queue state is unexpected"); source->running = 0; break; } @@ -869,7 +869,7 @@ static void source_shutdown (source_t *source) mount_proxy *mountinfo; source->running = 0; - INFO1("Source \"%s\" exiting", source->mount); + LOG_INFO("Source \"%s\" exiting", source->mount); mountinfo = config_find_mount (config_get_config(), source->mount, MOUNT_TYPE_NORMAL); if (mountinfo) @@ -985,7 +985,7 @@ static void source_apply_mount (source_t *source, mount_proxy *mountinfo) int val; http_parser_t *parser = NULL; - DEBUG1("Applying mount information for \"%s\"", source->mount); + LOG_DEBUG("Applying mount information for \"%s\"", source->mount); avl_tree_rlock (source->client_tree); stats_event_args (source->mount, "listener_peak", "%lu", source->peak_listeners); @@ -1028,7 +1028,7 @@ static void source_apply_mount (source_t *source, mount_proxy *mountinfo) stats_event_args (source->mount, "public", "%d", val); if (source->yp_public != val) { - DEBUG1 ("YP changed to %d", val); + LOG_DEBUG("YP changed to %d", val); if (val) yp_add (source->mount); else @@ -1176,7 +1176,7 @@ static void source_apply_mount (source_t *source, mount_proxy *mountinfo) if (f) source->intro_file = f; else - WARN2 ("Cannot open intro file \"%s\": %s", path, strerror(errno)); + LOG_WARN("Cannot open intro file \"%s\": %s", path, strerror(errno)); free (path); } } @@ -1222,18 +1222,18 @@ void source_update_settings (ice_config_t *config, source_t *source, mount_proxy source_apply_mount (source, mountinfo); if (source->fallback_mount) - DEBUG1 ("fallback %s", source->fallback_mount); + LOG_DEBUG("fallback %s", source->fallback_mount); if (mountinfo && mountinfo->intro_filename) - DEBUG1 ("intro file is %s", mountinfo->intro_filename); + LOG_DEBUG("intro file is %s", mountinfo->intro_filename); if (source->dumpfilename) - DEBUG1 ("Dumping stream to %s", source->dumpfilename); + LOG_DEBUG("Dumping stream to %s", source->dumpfilename); if (mountinfo && mountinfo->on_connect) - DEBUG1 ("connect script \"%s\"", mountinfo->on_connect); + LOG_DEBUG("connect script \"%s\"", mountinfo->on_connect); if (mountinfo && mountinfo->on_disconnect) - DEBUG1 ("disconnect script \"%s\"", mountinfo->on_disconnect); + LOG_DEBUG("disconnect script \"%s\"", mountinfo->on_disconnect); if (source->on_demand) { - DEBUG0 ("on_demand set"); + LOG_DEBUG("on_demand set"); stats_event (source->mount, "on_demand", "1"); stats_event_args (source->mount, "listeners", "%ld", source->listeners); } @@ -1243,7 +1243,7 @@ void source_update_settings (ice_config_t *config, source_t *source, mount_proxy if (source->hidden) { stats_event_hidden (source->mount, NULL, 1); - DEBUG0 ("hidden from public"); + LOG_DEBUG("hidden from public"); } else stats_event_hidden (source->mount, NULL, 0); @@ -1256,12 +1256,12 @@ void source_update_settings (ice_config_t *config, source_t *source, mount_proxy snprintf (buf, sizeof (buf), "%ld", source->max_listeners); stats_event (source->mount, "max_listeners", buf); } - DEBUG1 ("public set to %d", source->yp_public); - DEBUG1 ("max listeners to %ld", source->max_listeners); - DEBUG1 ("queue size to %u", source->queue_size_limit); - DEBUG1 ("burst size to %u", source->burst_size); - DEBUG1 ("source timeout to %u", source->timeout); - DEBUG1 ("fallback_when_full to %u", source->fallback_when_full); + LOG_DEBUG("public set to %d", source->yp_public); + LOG_DEBUG("max listeners to %ld", source->max_listeners); + LOG_DEBUG("queue size to %u", source->queue_size_limit); + LOG_DEBUG("burst size to %u", source->burst_size); + LOG_DEBUG("source timeout to %u", source->timeout); + LOG_DEBUG("fallback_when_full to %u", source->fallback_when_full); thread_mutex_unlock(&source->lock); } @@ -1323,19 +1323,19 @@ static void source_run_script (char *command, char *mountpoint) switch (pid = fork ()) { case -1: - ERROR2 ("Unable to fork %s (%s)", command, strerror (errno)); + LOG_ERROR("Unable to fork %s (%s)", command, strerror (errno)); break; case 0: /* child */ - DEBUG1 ("Starting command %s", command); + LOG_DEBUG("Starting command %s", command); execl (command, command, mountpoint, (char *)NULL); - ERROR2 ("Unable to run command %s (%s)", command, strerror (errno)); + LOG_ERROR("Unable to run command %s (%s)", command, strerror (errno)); exit(0); default: /* parent */ break; } exit (0); case -1: - ERROR1 ("Unable to fork %s", strerror (errno)); + LOG_ERROR("Unable to fork %s", strerror (errno)); break; default: /* parent */ waitpid (external_pid, NULL, 0); @@ -1373,7 +1373,7 @@ static void *source_fallback_file (void *arg) file = fopen (path, "rb"); if (file == NULL) { - WARN1 ("unable to open file \"%s\"", path); + LOG_WARN("unable to open file \"%s\"", path); free (path); break; } @@ -1381,10 +1381,10 @@ static void *source_fallback_file (void *arg) source = source_reserve (mount); if (source == NULL) { - WARN1 ("mountpoint \"%s\" already reserved", mount); + LOG_WARN("mountpoint \"%s\" already reserved", mount); break; } - INFO1 ("mountpoint %s is reserved", mount); + LOG_INFO("mountpoint %s is reserved", mount); type = fserve_content_type (mount); parser = httpp_create_parser(); httpp_initialize (parser, NULL); diff --git a/src/stats.c b/src/stats.c index 3ad59c8a..c77535bb 100644 --- a/src/stats.c +++ b/src/stats.c @@ -160,7 +160,7 @@ void stats_shutdown(void) n = _stats_threads; thread_mutex_unlock(&_stats_mutex); } while (n > 0); - INFO0("stats thread finished"); + LOG_INFO("stats thread finished"); /* free the queues */ @@ -205,7 +205,7 @@ void stats_event(const char *source, const char *name, const char *value) if (value && xmlCheckUTF8 ((unsigned char *)value) == 0) { - WARN2 ("seen non-UTF8 data, probably incorrect metadata (%s, %s)", name, value); + LOG_WARN("seen non-UTF8 data, probably incorrect metadata (%s, %s)", name, value); return; } event = build_event (source, name, value); @@ -234,7 +234,7 @@ void stats_event_conv(const char *mount, const char *name, const char *value, co xmlCharEncCloseFunc (handle); } else - WARN1 ("No charset found for \"%s\"", charset); + LOG_WARN("No charset found for \"%s\"", charset); } stats_event (mount, name, metadata); @@ -273,7 +273,7 @@ void stats_event_args(const char *source, char *name, char *format, ...) if (ret < 0 || (unsigned int)ret >= sizeof (buf)) { - WARN2 ("problem with formatting %s stat %s", + LOG_WARN("problem with formatting %s stat %s", source==NULL ? "global" : source, name); return; } @@ -313,7 +313,7 @@ char *stats_get_value(const char *source, const char *name) void stats_event_inc(const char *source, const char *name) { stats_event_t *event = build_event (source, name, NULL); - /* DEBUG2("%s on %s", name, source==NULL?"global":source); */ + /* LOG_DEBUG("%s on %s", name, source==NULL?"global":source); */ if (event) { event->action = STATS_EVENT_INC; @@ -324,7 +324,7 @@ void stats_event_inc(const char *source, const char *name) void stats_event_add(const char *source, const char *name, unsigned long value) { stats_event_t *event = build_event (source, name, NULL); - /* DEBUG2("%s on %s", name, source==NULL?"global":source); */ + /* LOG_DEBUG("%s on %s", name, source==NULL?"global":source); */ if (event) { event->value = malloc (16); @@ -349,7 +349,7 @@ void stats_event_sub(const char *source, const char *name, unsigned long value) /* decrease the value in the provided stat by 1 */ void stats_event_dec(const char *source, const char *name) { - /* DEBUG2("%s on %s", name, source==NULL?"global":source); */ + /* LOG_DEBUG("%s on %s", name, source==NULL?"global":source); */ stats_event_t *event = build_event (source, name, NULL); if (event) { @@ -463,7 +463,7 @@ static void modify_node_event (stats_node_t *node, stats_event_t *event) value = atoll (node->value) - atoll (event->value); break; default: - WARN2 ("unhandled event (%d) for %s", event->action, event->source); + LOG_WARN("unhandled event (%d) for %s", event->action, event->source); break; } str = malloc (16); @@ -476,9 +476,9 @@ static void modify_node_event (stats_node_t *node, stats_event_t *event) free (node->value); node->value = str; if (event->source) - DEBUG3 ("update \"%s\" %s (%s)", event->source, node->name, node->value); + LOG_DEBUG("update \"%s\" %s (%s)", event->source, node->name, node->value); else - DEBUG2 ("update global %s (%s)", node->name, node->value); + LOG_DEBUG("update global %s (%s)", node->name, node->value); } @@ -486,7 +486,7 @@ static void process_global_event (stats_event_t *event) { stats_node_t *node; - /* DEBUG3("global event %s %s %d", event->name, event->value, event->action); */ + /* LOG_DEBUG("global event %s %s %d", event->name, event->value, event->action); */ if (event->action == STATS_EVENT_REMOVE) { /* we're deleting */ @@ -522,7 +522,7 @@ static void process_source_event (stats_event_t *event) snode = (stats_source_t *)calloc(1,sizeof(stats_source_t)); if (snode == NULL) return; - DEBUG1 ("new source stat %s", event->source); + LOG_DEBUG("new source stat %s", event->source); snode->source = (char *)strdup(event->source); snode->stats_tree = avl_tree_new(_compare_stats, NULL); if (event->action == STATS_EVENT_HIDDEN) @@ -542,7 +542,7 @@ static void process_source_event (stats_event_t *event) /* adding node */ if (event->value) { - DEBUG2 ("new node %s (%s)", event->name, event->value); + LOG_DEBUG("new node %s (%s)", event->name, event->value); node = (stats_node_t *)calloc(1,sizeof(stats_node_t)); node->name = (char *)strdup(event->name); node->value = (char *)strdup(event->value); @@ -554,7 +554,7 @@ static void process_source_event (stats_event_t *event) } if (event->action == STATS_EVENT_REMOVE) { - DEBUG1 ("delete node %s", event->name); + LOG_DEBUG("delete node %s", event->name); avl_delete(snode->stats_tree, (void *)node, _free_stats); return; } @@ -579,7 +579,7 @@ static void process_source_event (stats_event_t *event) } if (event->action == STATS_EVENT_REMOVE) { - DEBUG1 ("delete source node %s", event->source); + LOG_DEBUG("delete source node %s", event->source); avl_delete(_stats.source_tree, (void *)snode, _free_source_stats); } } @@ -642,7 +642,7 @@ static void *_stats_thread(void *arg) stats_event (NULL, "stats_connections", "0"); stats_event (NULL, "listener_connections", "0"); - INFO0 ("stats thread started"); + LOG_INFO("stats thread started"); while (_stats_running) { thread_mutex_lock(&_global_event_mutex); if (_global_event_queue.head != NULL) { @@ -865,7 +865,7 @@ void *stats_connection(void *arg) stats_event_t *event; event_listener_t listener; - INFO0 ("stats client starting"); + LOG_INFO("stats client starting"); event_queue_init (&listener.queue); /* increment the thread count */ @@ -901,7 +901,7 @@ void *stats_connection(void *arg) thread_mutex_destroy (&listener.mutex); client_destroy (client); - INFO0 ("stats client finished"); + LOG_INFO("stats client finished"); return NULL; } @@ -1062,7 +1062,7 @@ void stats_clear_virtual_mounts (void) { /* no source_t is reserved so remove them now */ snode = avl_get_next (snode); - DEBUG1 ("releasing %s stats", src->source); + LOG_DEBUG("releasing %s stats", src->source); avl_delete (_stats.source_tree, src, _free_source_stats); continue; } diff --git a/src/util.c b/src/util.c index 01a4e348..ac61d399 100644 --- a/src/util.c +++ b/src/util.c @@ -319,7 +319,7 @@ char *util_url_unescape (const char *src) done = 1; break; case 0: - ERROR0("Fatal internal logic error in util_url_unescape()"); + LOG_ERROR("Fatal internal logic error in util_url_unescape()"); free(decoded); return NULL; break; @@ -350,7 +350,7 @@ char *util_normalise_uri(const char *uri) { path = util_url_unescape(uri); if(path == NULL) { - WARN1("Error decoding URI: %s\n", uri); + LOG_WARN("Error decoding URI: %s\n", uri); return NULL; } @@ -358,7 +358,7 @@ char *util_normalise_uri(const char *uri) { if(verify_path(path)) return path; else { - WARN1("Rejecting invalid path \"%s\"", path); + LOG_WARN("Rejecting invalid path \"%s\"", path); free(path); return NULL; } @@ -617,7 +617,7 @@ int util_dict_set(util_dict *dict, const char *key, const char *val) util_dict *prev; if (!dict || !key) { - ERROR0("NULL values passed to util_dict_set()"); + LOG_ERROR("NULL values passed to util_dict_set()"); return 0; } @@ -632,7 +632,7 @@ int util_dict_set(util_dict *dict, const char *key, const char *val) if (!dict) { dict = util_dict_new(); if (!dict) { - ERROR0("unable to allocate new dictionary"); + LOG_ERROR("unable to allocate new dictionary"); return 0; } if (prev) @@ -646,13 +646,13 @@ int util_dict_set(util_dict *dict, const char *key, const char *val) prev->next = NULL; util_dict_free (dict); - ERROR0("unable to allocate new dictionary key"); + LOG_ERROR("unable to allocate new dictionary key"); return 0; } dict->val = strdup(val); if (!dict->val) { - ERROR0("unable to allocate new dictionary value"); + LOG_ERROR("unable to allocate new dictionary value"); return 0; } @@ -750,7 +750,7 @@ char *util_conv_string (const char *string, const char *in_charset, const char * xmlBufferPtr utf8 = xmlBufferCreate (); xmlBufferPtr conv = xmlBufferCreate (); - INFO2 ("converting metadata from %s to %s", in_charset, out_charset); + LOG_INFO("converting metadata from %s to %s", in_charset, out_charset); xmlBufferCCat (orig, string); if (xmlCharEncInFunc (in, utf8, orig) > 0) { diff --git a/src/xslt.c b/src/xslt.c index d8b5bcc4..379cfdf7 100644 --- a/src/xslt.c +++ b/src/xslt.c @@ -142,7 +142,7 @@ static xsltStylesheetPtr xslt_get_stylesheet(const char *fn) { struct stat file; if(stat(fn, &file)) { - WARN2("Error checking for stylesheet file \"%s\": %s", fn, + LOG_WARN("Error checking for stylesheet file \"%s\": %s", fn, strerror(errno)); return NULL; } @@ -164,7 +164,7 @@ static xsltStylesheetPtr xslt_get_stylesheet(const char *fn) { cache[i].stylesheet = xsltParseStylesheetFile (XMLSTR(fn)); cache[i].cache_age = time(NULL); } - DEBUG1("Using cached sheet %i", i); + LOG_DEBUG("Using cached sheet %i", i); return cache[i].stylesheet; } } @@ -202,7 +202,7 @@ void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client) if (cur == NULL) { thread_mutex_unlock(&xsltlock); - ERROR1 ("problem reading stylesheet \"%s\"", xslfilename); + LOG_ERROR("problem reading stylesheet \"%s\"", xslfilename); client_send_404 (client, "Could not parse XSLT file"); return; } @@ -252,7 +252,7 @@ void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client) } else { - WARN1 ("problem applying stylesheet \"%s\"", xslfilename); + LOG_WARN("problem applying stylesheet \"%s\"", xslfilename); client_send_404 (client, "XSLT problem"); } thread_mutex_unlock (&xsltlock); diff --git a/src/yp.c b/src/yp.c index 7cf30318..70a6f6f3 100644 --- a/src/yp.c +++ b/src/yp.c @@ -108,7 +108,7 @@ static int handle_returned_header (void *ptr, size_t size, size_t nmemb, void *s ypdata_t *yp = stream; unsigned bytes = size * nmemb; - /* DEBUG2 ("header from YP is \"%.*s\"", bytes, ptr); */ + /* LOG_DEBUG("header from YP is \"%.*s\"", bytes, ptr); */ if (strncasecmp (ptr, "YPResponse: 1", 13) == 0) yp->cmd_ok = 1; @@ -139,7 +139,7 @@ static int handle_returned_header (void *ptr, size_t size, size_t nmemb, void *s secs = 0; if (secs < 30) secs = 30; - DEBUG1 ("server touch interval is %u", secs); + LOG_DEBUG("server touch interval is %u", secs); yp->touch_interval = secs; } return (int)bytes; @@ -180,11 +180,11 @@ static void destroy_yp_server (struct yp_server *server) { if (server == NULL) return; - DEBUG1 ("Removing YP server entry for %s", server->url); + LOG_DEBUG("Removing YP server entry for %s", server->url); if (server->curl) curl_easy_cleanup (server->curl); - if (server->mounts) WARN0 ("active ypdata not freed up"); - if (server->pending_mounts) WARN0 ("pending ypdata not freed up"); + if (server->mounts) LOG_WARN("active ypdata not freed up"); + if (server->pending_mounts) LOG_WARN("pending ypdata not freed up"); free (server->url); free (server->server_id); free (server); @@ -211,7 +211,7 @@ void yp_recheck_config (ice_config_t *config) int i; struct yp_server *server; - DEBUG0("Updating YP configuration"); + LOG_DEBUG("Updating YP configuration"); thread_rwlock_rlock (&yp_lock); server = (struct yp_server *)active_yps; @@ -263,7 +263,7 @@ void yp_recheck_config (ice_config_t *config) curl_easy_setopt (server->curl, CURLOPT_ERRORBUFFER, &(server->curl_error[0])); server->next = (struct yp_server *)pending_yps; pending_yps = server; - INFO3 ("Adding new YP server \"%s\" (timeout %ds, default interval %ds)", + LOG_INFO("Adding new YP server \"%s\" (timeout %ds, default interval %ds)", server->url, server->url_timeout, server->touch_interval); } else @@ -298,7 +298,7 @@ static int send_to_yp (const char *cmd, ypdata_t *yp, char *post) int curlcode; struct yp_server *server = yp->server; - /* DEBUG2 ("send YP (%s):%s", cmd, post); */ + /* LOG_DEBUG("send YP (%s):%s", cmd, post); */ yp->cmd_ok = 0; curl_easy_setopt (server->curl, CURLOPT_POSTFIELDS, post); curl_easy_setopt (server->curl, CURLOPT_WRITEHEADER, yp); @@ -307,7 +307,7 @@ static int send_to_yp (const char *cmd, ypdata_t *yp, char *post) { yp->process = do_yp_add; yp->next_update = now + 1200; - ERROR2 ("connection to %s failed with \"%s\"", server->url, server->curl_error); + LOG_ERROR("connection to %s failed with \"%s\"", server->url, server->curl_error); return -2; } if (yp->cmd_ok == 0) @@ -316,7 +316,7 @@ static int send_to_yp (const char *cmd, ypdata_t *yp, char *post) yp->error_msg = strdup ("no response from server"); if (yp->process == do_yp_add) { - ERROR3 ("YP %s on %s failed: %s", cmd, server->url, yp->error_msg); + LOG_ERROR("YP %s on %s failed: %s", cmd, server->url, yp->error_msg); yp->next_update = now + 7200; } if (yp->process == do_yp_touch) @@ -331,14 +331,14 @@ static int send_to_yp (const char *cmd, ypdata_t *yp, char *post) yp->next_update = now + 1200; else yp->next_update = now + yp->touch_interval; - INFO3 ("YP %s on %s failed: %s", cmd, server->url, yp->error_msg); + LOG_INFO("YP %s on %s failed: %s", cmd, server->url, yp->error_msg); } yp->process = do_yp_add; free (yp->sid); yp->sid = NULL; return -1; } - DEBUG2 ("YP %s at %s succeeded", cmd, server->url); + LOG_DEBUG("YP %s at %s succeeded", cmd, server->url); return 0; } @@ -354,7 +354,7 @@ static int do_yp_remove (ypdata_t *yp, char *s, unsigned len) if (ret >= (signed)len) return ret+1; - INFO1 ("clearing up YP entry for %s", yp->mount); + LOG_INFO("clearing up YP entry for %s", yp->mount); ret = send_to_yp ("remove", yp, s); free (yp->sid); yp->sid = NULL; @@ -530,7 +530,7 @@ static void yp_process_server (struct yp_server *server) ypdata_t *yp; int state = 0; - /* DEBUG1("processing yp server %s", server->url); */ + /* LOG_DEBUG("processing yp server %s", server->url); */ yp = server->mounts; while (yp) { @@ -540,7 +540,7 @@ static void yp_process_server (struct yp_server *server) */ if (state == -2) { - DEBUG2 ("skiping %s on %s", yp->mount, server->url); + LOG_DEBUG("skiping %s on %s", yp->mount, server->url); yp->process = do_yp_add; yp->next_update += 900; } @@ -622,7 +622,7 @@ static void check_servers (void) if (server->remove) { struct yp_server *to_go = server; - DEBUG1 ("YP server \"%s\"removed", server->url); + LOG_DEBUG("YP server \"%s\"removed", server->url); *server_p = server->next; server = server->next; destroy_yp_server (to_go); @@ -639,7 +639,7 @@ static void check_servers (void) server = (struct yp_server *)pending_yps; pending_yps = server->next; - DEBUG1("Add pending yps %s", server->url); + LOG_DEBUG("Add pending yps %s", server->url); server->next = (struct yp_server *)active_yps; active_yps = server; @@ -653,7 +653,7 @@ static void check_servers (void) source_t *source = node->key; if (source->yp_public && (yp = create_yp_entry (source->mount)) != NULL) { - DEBUG1 ("Adding existing mount %s", source->mount); + LOG_DEBUG("Adding existing mount %s", source->mount); yp->server = server; yp->touch_interval = server->touch_interval; yp->next = server->mounts; @@ -685,7 +685,7 @@ static void add_pending_yp (struct yp_server *server) yp = yp->next; } yp->next = current; - DEBUG2 ("%u YP entries added to %s", count, server->url); + LOG_DEBUG("%u YP entries added to %s", count, server->url); } @@ -698,7 +698,7 @@ static void delete_marked_yp (struct yp_server *server) if (yp->remove) { ypdata_t *to_go = yp; - DEBUG2 ("removed %s from YP server %s", yp->mount, server->url); + LOG_DEBUG("removed %s from YP server %s", yp->mount, server->url); *prev = yp->next; yp = yp->next; yp_destroy_ypdata (to_go); @@ -712,7 +712,7 @@ static void delete_marked_yp (struct yp_server *server) static void *yp_update_thread(void *arg) { - INFO0("YP update thread started"); + LOG_INFO("YP update thread started"); yp_running = 1; while (yp_running) @@ -726,7 +726,7 @@ static void *yp_update_thread(void *arg) server = (struct yp_server *)active_yps; while (server) { - /* DEBUG1 ("trying %s", server->url); */ + /* LOG_DEBUG("trying %s", server->url); */ yp_process_server (server); server = server->next; } @@ -740,7 +740,7 @@ static void *yp_update_thread(void *arg) server = (struct yp_server *)active_yps; while (server) { - /* DEBUG1 ("Checking yps %s", server->url); */ + /* LOG_DEBUG("Checking yps %s", server->url); */ add_pending_yp (server); delete_marked_yp (server); server = server->next; @@ -891,7 +891,7 @@ void yp_add (const char *mount) yp = create_yp_entry (mount); if (yp) { - DEBUG2 ("Adding %s to %s", mount, server->url); + LOG_DEBUG("Adding %s to %s", mount, server->url); yp->server = server; yp->touch_interval = server->touch_interval; yp->next = server->pending_mounts; @@ -901,7 +901,7 @@ void yp_add (const char *mount) } } else - DEBUG1 ("YP entry %s already exists", mount); + LOG_DEBUG("YP entry %s already exists", mount); server = server->next; } thread_mutex_unlock (&yp_pending_lock); @@ -930,7 +930,7 @@ void yp_remove (const char *mount) list = yp->next; continue; /* search again these are old entries */ } - DEBUG2 ("release %s on YP %s", mount, server->url); + LOG_DEBUG("release %s on YP %s", mount, server->url); yp->release = 1; yp->next_update = 0; } @@ -983,6 +983,6 @@ void yp_shutdown (void) curl_global_cleanup(); free ((char*)server_version); server_version = NULL; - INFO0 ("YP thread down"); + LOG_INFO("YP thread down"); } diff --git a/src/yp.h b/src/yp.h index 6b2eb187..9f495433 100644 --- a/src/yp.h +++ b/src/yp.h @@ -41,7 +41,7 @@ void yp_shutdown(void); #define yp_remove(x) do{}while(0) #define yp_touch(x) do{}while(0) #define yp_recheck_config(x) do{}while(0) -#define yp_initialize() WARN0("YP server handling has been disabled") +#define yp_initialize() LOG_WARN("YP server handling has been disabled") #define yp_shutdown() do{}while(0) #endif /* USE_YP */