log: removed DEBUG() and FATAL()
Use GLib the logging functions g_debug(), g_error() instead.
This commit is contained in:
parent
9e30dfb9c1
commit
a899c210b9
@ -33,7 +33,6 @@
|
|||||||
#include "stats.h"
|
#include "stats.h"
|
||||||
#include "permission.h"
|
#include "permission.h"
|
||||||
#include "buffer2array.h"
|
#include "buffer2array.h"
|
||||||
#include "log.h"
|
|
||||||
#include "stored_playlist.h"
|
#include "stored_playlist.h"
|
||||||
#include "ack.h"
|
#include "ack.h"
|
||||||
#include "output_command.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)) {
|
for (GSList *cur = list; cur != NULL; cur = g_slist_next(cur)) {
|
||||||
char *cmd = cur->data;
|
char *cmd = cur->data;
|
||||||
|
|
||||||
DEBUG("command_process_list: process command \"%s\"\n",
|
g_debug("command_process_list: process command \"%s\"",
|
||||||
cmd);
|
cmd);
|
||||||
ret = command_process(client, 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))
|
if (ret != COMMAND_RETURN_OK || client_is_expired(client))
|
||||||
break;
|
break;
|
||||||
else if (list_ok)
|
else if (list_ok)
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "mapper.h"
|
#include "mapper.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "log.h"
|
|
||||||
#include "uri.h"
|
#include "uri.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
@ -269,5 +268,5 @@ void decoder_thread_start(void)
|
|||||||
|
|
||||||
dc.thread = g_thread_create(decoder_task, NULL, true, &e);
|
dc.thread = g_thread_create(decoder_task, NULL, true, &e);
|
||||||
if (dc.thread == NULL)
|
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 cycle_log_files(void)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
@ -23,9 +23,6 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <stdbool.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
|
* Configure a logging destination for daemon startup, before the
|
||||||
* configuration file is read. This allows the daemon to use the
|
* configuration file is read. This allows the daemon to use the
|
||||||
|
@ -168,9 +168,9 @@ initialize_decoder_and_player(void)
|
|||||||
if (param != NULL) {
|
if (param != NULL) {
|
||||||
perc = strtod(param->value, &test);
|
perc = strtod(param->value, &test);
|
||||||
if (*test != '%' || perc < 0 || perc > 100) {
|
if (*test != '%' || perc < 0 || perc > 100) {
|
||||||
FATAL("buffered before play \"%s\" is not a positive "
|
g_error("buffered before play \"%s\" is not a positive "
|
||||||
"percentage and less than 100 percent, line %i"
|
"percentage and less than 100 percent, line %i",
|
||||||
"\n", param->value, param->line);
|
param->value, param->line);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
perc = DEFAULT_BUFFER_BEFORE_PLAY;
|
perc = DEFAULT_BUFFER_BEFORE_PLAY;
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include "permission.h"
|
#include "permission.h"
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "log.h"
|
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
@ -59,7 +58,7 @@ static unsigned parsePermissions(const char *string)
|
|||||||
} else if (strcmp(temp, PERMISSION_ADMIN_STRING) == 0) {
|
} else if (strcmp(temp, PERMISSION_ADMIN_STRING) == 0) {
|
||||||
permission |= PERMISSION_ADMIN;
|
permission |= PERMISSION_ADMIN;
|
||||||
} else {
|
} 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);
|
strchr(param->value, PERMISSION_PASSWORD_CHAR);
|
||||||
|
|
||||||
if (separator == NULL)
|
if (separator == NULL)
|
||||||
FATAL("\"%c\" not found in password string "
|
g_error("\"%c\" not found in password string "
|
||||||
"\"%s\", line %i\n",
|
"\"%s\", line %i",
|
||||||
PERMISSION_PASSWORD_CHAR,
|
PERMISSION_PASSWORD_CHAR,
|
||||||
param->value, param->line);
|
param->value, param->line);
|
||||||
|
|
||||||
password = g_strndup(param->value,
|
password = g_strndup(param->value,
|
||||||
separator - param->value);
|
separator - param->value);
|
||||||
|
@ -51,7 +51,7 @@ x_sigaction(int signum, const struct sigaction *act)
|
|||||||
static void
|
static void
|
||||||
handle_reload_event(void)
|
handle_reload_event(void)
|
||||||
{
|
{
|
||||||
DEBUG("got SIGHUP, rereading DB\n");
|
g_debug("got SIGHUP, reopening log files");
|
||||||
cycle_log_files();
|
cycle_log_files();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,10 +23,14 @@
|
|||||||
#include "directory.h"
|
#include "directory.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "log.h"
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#undef G_LOG_DOMAIN
|
||||||
|
#define G_LOG_DOMAIN "song"
|
||||||
|
|
||||||
#define SONG_KEY "key: "
|
#define SONG_KEY "key: "
|
||||||
#define SONG_MTIME "mtime: "
|
#define SONG_MTIME "mtime: "
|
||||||
|
|
||||||
@ -126,7 +130,7 @@ void readSongInfoIntoList(FILE *fp, struct songvec *sv,
|
|||||||
} else if (*buffer == 0) {
|
} else if (*buffer == 0) {
|
||||||
/* ignore empty lines (starting with '\0') */
|
/* ignore empty lines (starting with '\0') */
|
||||||
} else if (song == NULL) {
|
} 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))) {
|
} else if (0 == strncmp(SONG_FILE, buffer, strlen(SONG_FILE))) {
|
||||||
/* we don't need this info anymore */
|
/* we don't need this info anymore */
|
||||||
} else if ((value = matchesAnMpdTagItemKey(buffer,
|
} else if ((value = matchesAnMpdTagItemKey(buffer,
|
||||||
@ -148,7 +152,7 @@ void readSongInfoIntoList(FILE *fp, struct songvec *sv,
|
|||||||
song->mtime = atoi(&(buffer[strlen(SONG_MTIME)]));
|
song->mtime = atoi(&(buffer[strlen(SONG_MTIME)]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
FATAL("songinfo: unknown line in db: %s\n", buffer);
|
g_error("unknown line in db: %s", buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (song)
|
if (song)
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "tag_internal.h"
|
#include "tag_internal.h"
|
||||||
#include "tag_pool.h"
|
#include "tag_pool.h"
|
||||||
#include "log.h"
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "song.h"
|
#include "song.h"
|
||||||
|
|
||||||
@ -106,8 +105,8 @@ void tag_lib_init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (strlen(c) && i == TAG_NUM_OF_ITEM_TYPES) {
|
if (strlen(c) && i == TAG_NUM_OF_ITEM_TYPES) {
|
||||||
FATAL("error parsing metadata item \"%s\"\n",
|
g_error("error parsing metadata item \"%s\"",
|
||||||
c);
|
c);
|
||||||
}
|
}
|
||||||
s++;
|
s++;
|
||||||
c = s;
|
c = s;
|
||||||
|
Loading…
Reference in New Issue
Block a user