aboutsummaryrefslogtreecommitdiff
path: root/src/log.c
diff options
context:
space:
mode:
authorThomas Jansen <mithi@mithi.net>2010-09-25 15:00:43 +0200
committerThomas Jansen <mithi@mithi.net>2010-09-25 15:00:43 +0200
commit28bcb8bdf568875eeea1349e39b7958d77c8fcc1 (patch)
tree17397be16e8067a48fd532a581081f68a1b17700 /src/log.c
parent9af9fd140032138894e4781caabee8a5a96edab8 (diff)
eliminate g_error() usage
Replaced all occurrences of g_error() with MPD_ERROR() located in a new header file 'mpd_error.h'. This macro uses g_critical() to print the error message and then exits gracefully in contrast to g_error() which would internally call abort() to produce a core dump. The macro name is distinctive and allows to find all places with dubious error handling. The long-term goal is to get rid of MPD_ERROR() altogether. To facilitate the eventual removal of this macro it was added in a new header file rather than to an existing header file. This fixes #2995 and #3007.
Diffstat (limited to 'src/log.c')
-rw-r--r--src/log.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/log.c b/src/log.c
index dc762887..556c8b04 100644
--- a/src/log.c
+++ b/src/log.c
@@ -22,6 +22,7 @@
#include "conf.h"
#include "utils.h"
#include "fd_util.h"
+#include "mpd_error.h"
#include <assert.h>
#include <sys/types.h>
@@ -60,9 +61,9 @@ static void redirect_logs(int fd)
{
assert(fd >= 0);
if (dup2(fd, STDOUT_FILENO) < 0)
- g_error("problems dup2 stdout : %s\n", strerror(errno));
+ MPD_ERROR("problems dup2 stdout : %s\n", strerror(errno));
if (dup2(fd, STDERR_FILENO) < 0)
- g_error("problems dup2 stderr : %s\n", strerror(errno));
+ MPD_ERROR("problems dup2 stderr : %s\n", strerror(errno));
}
static const char *log_date(void)
@@ -138,8 +139,8 @@ log_init_file(const char *path, unsigned line)
out_filename = path;
out_fd = open_log_file();
if (out_fd < 0)
- g_error("problem opening log file \"%s\" (config line %u) for "
- "writing\n", path, line);
+ MPD_ERROR("problem opening log file \"%s\" (config line %u) "
+ "for writing\n", path, line);
g_log_set_default_handler(file_log_func, NULL);
}
@@ -216,8 +217,8 @@ parse_log_level(const char *value, unsigned line)
else if (0 == strcmp(value, "verbose"))
return G_LOG_LEVEL_DEBUG;
else {
- g_error("unknown log level \"%s\" at line %u\n",
- value, line);
+ MPD_ERROR("unknown log level \"%s\" at line %u\n",
+ value, line);
return G_LOG_LEVEL_MESSAGE;
}
}
@@ -252,8 +253,8 @@ void log_init(bool verbose, bool use_stdout)
available) */
log_init_syslog();
#else
- g_error("config parameter \"%s\" not found\n",
- CONF_LOG_FILE);
+ MPD_ERROR("config parameter \"%s\" not found\n",
+ CONF_LOG_FILE);
#endif
#ifdef HAVE_SYSLOG
} else if (strcmp(param->value, "syslog") == 0) {