log: removed DEBUG() and FATAL()
Use GLib the logging functions g_debug(), g_error() instead.
This commit is contained in:
		@@ -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",
 | 
			
		||||
		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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										24
									
								
								src/log.c
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								src/log.c
									
									
									
									
									
								
							@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -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,8 +89,8 @@ void initPermissions(void)
 | 
			
		||||
				strchr(param->value, PERMISSION_PASSWORD_CHAR);
 | 
			
		||||
 | 
			
		||||
			if (separator == NULL)
 | 
			
		||||
				FATAL("\"%c\" not found in password string "
 | 
			
		||||
				      "\"%s\", line %i\n",
 | 
			
		||||
				g_error("\"%c\" not found in password string "
 | 
			
		||||
					"\"%s\", line %i",
 | 
			
		||||
					PERMISSION_PASSWORD_CHAR,
 | 
			
		||||
					param->value, param->line);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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,7 +105,7 @@ void tag_lib_init(void)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			if (strlen(c) && i == TAG_NUM_OF_ITEM_TYPES) {
 | 
			
		||||
				FATAL("error parsing metadata item \"%s\"\n",
 | 
			
		||||
				g_error("error parsing metadata item \"%s\"",
 | 
			
		||||
					c);
 | 
			
		||||
			}
 | 
			
		||||
			s++;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user