diff options
author | Max Kellermann <max@duempel.org> | 2009-03-15 18:23:00 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-03-15 18:23:00 +0100 |
commit | a899c210b9de405a232f0cd102ca9409ef89518b (patch) | |
tree | 3b42f6d527cb92c8f1c3c1592541511ce14d283d /src | |
parent | 9e30dfb9c195dab50c4d0173885a94e7b81d45bd (diff) | |
download | mpd-a899c210b9de405a232f0cd102ca9409ef89518b.tar.gz mpd-a899c210b9de405a232f0cd102ca9409ef89518b.tar.xz mpd-a899c210b9de405a232f0cd102ca9409ef89518b.zip |
log: removed DEBUG() and FATAL()
Use GLib the logging functions g_debug(), g_error() instead.
Diffstat (limited to '')
-rw-r--r-- | src/command.c | 7 | ||||
-rw-r--r-- | src/decoder_thread.c | 3 | ||||
-rw-r--r-- | src/log.c | 24 | ||||
-rw-r--r-- | src/log.h | 3 | ||||
-rw-r--r-- | src/main.c | 6 | ||||
-rw-r--r-- | src/permission.c | 11 | ||||
-rw-r--r-- | src/sig_handlers.c | 2 | ||||
-rw-r--r-- | src/song_save.c | 10 | ||||
-rw-r--r-- | src/tag.c | 5 |
9 files changed, 22 insertions, 49 deletions
diff --git a/src/command.c b/src/command.c index 513a53e5b..7603f669c 100644 --- a/src/command.c +++ b/src/command.c @@ -33,7 +33,6 @@ #include "stats.h" #include "permission.h" #include "buffer2array.h" -#include "log.h" #include "stored_playlist.h" #include "ack.h" #include "output_command.h" @@ -1797,10 +1796,10 @@ command_process_list(struct client *client, for (GSList *cur = list; cur != NULL; cur = g_slist_next(cur)) { char *cmd = cur->data; - DEBUG("command_process_list: process command \"%s\"\n", - cmd); + g_debug("command_process_list: process command \"%s\"", + cmd); ret = command_process(client, cmd); - DEBUG("command_process_list: command returned %i\n", ret); + g_debug("command_process_list: command returned %i", ret); if (ret != COMMAND_RETURN_OK || client_is_expired(client)) break; else if (list_ok) diff --git a/src/decoder_thread.c b/src/decoder_thread.c index c04d0b849..dee16218a 100644 --- a/src/decoder_thread.c +++ b/src/decoder_thread.c @@ -29,7 +29,6 @@ #include "tag.h" #include "mapper.h" #include "path.h" -#include "log.h" #include "uri.h" #include <glib.h> @@ -269,5 +268,5 @@ void decoder_thread_start(void) dc.thread = g_thread_create(decoder_task, NULL, true, &e); if (dc.thread == NULL) - FATAL("Failed to spawn decoder task: %s\n", e->message); + g_error("Failed to spawn decoder task: %s", e->message); } @@ -285,30 +285,6 @@ void setup_log_output(bool use_stdout) } } -#define log_func(func,level) \ -G_GNUC_PRINTF(1, 2) void func(const char *fmt, ...) \ -{ \ - if (level <= log_threshold) { \ - va_list args; \ - va_start(args, fmt); \ - g_logv(NULL, level, fmt, args); \ - va_end(args); \ - } \ -} - -log_func(DEBUG, G_LOG_LEVEL_DEBUG) - -#undef log_func - -G_GNUC_PRINTF(1, 2) G_GNUC_NORETURN void FATAL(const char *fmt, ...) -{ - va_list args; - va_start(args, fmt); - g_logv(NULL, G_LOG_LEVEL_ERROR, fmt, args); - va_end(args); - exit(EXIT_FAILURE); -} - int cycle_log_files(void) { int fd; @@ -23,9 +23,6 @@ #include <glib.h> #include <stdbool.h> -G_GNUC_PRINTF(1, 2) void DEBUG(const char *fmt, ...); -G_GNUC_PRINTF(1, 2) G_GNUC_NORETURN void FATAL(const char *fmt, ...); - /** * Configure a logging destination for daemon startup, before the * configuration file is read. This allows the daemon to use the diff --git a/src/main.c b/src/main.c index 483947a1a..a8e6ddae5 100644 --- a/src/main.c +++ b/src/main.c @@ -168,9 +168,9 @@ initialize_decoder_and_player(void) if (param != NULL) { perc = strtod(param->value, &test); if (*test != '%' || perc < 0 || perc > 100) { - FATAL("buffered before play \"%s\" is not a positive " - "percentage and less than 100 percent, line %i" - "\n", param->value, param->line); + g_error("buffered before play \"%s\" is not a positive " + "percentage and less than 100 percent, line %i", + param->value, param->line); } } else perc = DEFAULT_BUFFER_BEFORE_PLAY; diff --git a/src/permission.c b/src/permission.c index da51d4b80..7df4e27fc 100644 --- a/src/permission.c +++ b/src/permission.c @@ -19,7 +19,6 @@ #include "permission.h" #include "conf.h" -#include "log.h" #include <glib.h> @@ -59,7 +58,7 @@ static unsigned parsePermissions(const char *string) } else if (strcmp(temp, PERMISSION_ADMIN_STRING) == 0) { permission |= PERMISSION_ADMIN; } else { - FATAL("unknown permission \"%s\"\n", temp); + g_error("unknown permission \"%s\"", temp); } } @@ -90,10 +89,10 @@ void initPermissions(void) strchr(param->value, PERMISSION_PASSWORD_CHAR); if (separator == NULL) - FATAL("\"%c\" not found in password string " - "\"%s\", line %i\n", - PERMISSION_PASSWORD_CHAR, - param->value, param->line); + g_error("\"%c\" not found in password string " + "\"%s\", line %i", + PERMISSION_PASSWORD_CHAR, + param->value, param->line); password = g_strndup(param->value, separator - param->value); diff --git a/src/sig_handlers.c b/src/sig_handlers.c index c42f0b169..e70e1a159 100644 --- a/src/sig_handlers.c +++ b/src/sig_handlers.c @@ -51,7 +51,7 @@ x_sigaction(int signum, const struct sigaction *act) static void handle_reload_event(void) { - DEBUG("got SIGHUP, rereading DB\n"); + g_debug("got SIGHUP, reopening log files"); cycle_log_files(); } diff --git a/src/song_save.c b/src/song_save.c index e0d61a3be..1d2724e83 100644 --- a/src/song_save.c +++ b/src/song_save.c @@ -23,10 +23,14 @@ #include "directory.h" #include "path.h" #include "tag.h" -#include "log.h" + +#include <glib.h> #include <stdlib.h> +#undef G_LOG_DOMAIN +#define G_LOG_DOMAIN "song" + #define SONG_KEY "key: " #define SONG_MTIME "mtime: " @@ -126,7 +130,7 @@ void readSongInfoIntoList(FILE *fp, struct songvec *sv, } else if (*buffer == 0) { /* ignore empty lines (starting with '\0') */ } else if (song == NULL) { - FATAL("Problems reading song info\n"); + g_error("Problems reading song info"); } else if (0 == strncmp(SONG_FILE, buffer, strlen(SONG_FILE))) { /* we don't need this info anymore */ } else if ((value = matchesAnMpdTagItemKey(buffer, @@ -148,7 +152,7 @@ void readSongInfoIntoList(FILE *fp, struct songvec *sv, song->mtime = atoi(&(buffer[strlen(SONG_MTIME)])); } else - FATAL("songinfo: unknown line in db: %s\n", buffer); + g_error("unknown line in db: %s", buffer); } if (song) @@ -20,7 +20,6 @@ #include "tag.h" #include "tag_internal.h" #include "tag_pool.h" -#include "log.h" #include "conf.h" #include "song.h" @@ -106,8 +105,8 @@ void tag_lib_init(void) } } if (strlen(c) && i == TAG_NUM_OF_ITEM_TYPES) { - FATAL("error parsing metadata item \"%s\"\n", - c); + g_error("error parsing metadata item \"%s\"", + c); } s++; c = s; |