state_file: use GLib logging
This commit is contained in:
parent
d4018c9966
commit
409ee38b42
@ -19,7 +19,6 @@
|
|||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#include "state_file.h"
|
#include "state_file.h"
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "log.h"
|
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
@ -29,6 +28,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#undef G_LOG_DOMAIN
|
||||||
|
#define G_LOG_DOMAIN "state_file"
|
||||||
|
|
||||||
static struct _sf_cb {
|
static struct _sf_cb {
|
||||||
void (*reader)(FILE *);
|
void (*reader)(FILE *);
|
||||||
void (*writer)(FILE *);
|
void (*writer)(FILE *);
|
||||||
@ -59,8 +61,8 @@ void write_state_file(void)
|
|||||||
return;
|
return;
|
||||||
fp = fopen(sfpath, "w");
|
fp = fopen(sfpath, "w");
|
||||||
if (G_UNLIKELY(!fp)) {
|
if (G_UNLIKELY(!fp)) {
|
||||||
ERROR("problems opening state file \"%s\" for writing: %s\n",
|
g_warning("failed to create %s: %s",
|
||||||
sfpath, strerror(errno));
|
sfpath, strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,16 +82,16 @@ void read_state_file(void)
|
|||||||
if (!sfpath)
|
if (!sfpath)
|
||||||
return;
|
return;
|
||||||
if (stat(sfpath, &st) < 0) {
|
if (stat(sfpath, &st) < 0) {
|
||||||
DEBUG("failed to stat state file: %s\n", sfpath);
|
g_debug("failed to stat %s: %s", sfpath, strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!S_ISREG(st.st_mode))
|
if (!S_ISREG(st.st_mode))
|
||||||
FATAL("state file \"%s\" is not a regular file\n", sfpath);
|
g_error("\"%s\" is not a regular file", sfpath);
|
||||||
|
|
||||||
while (!(fp = fopen(sfpath, "r")) && errno == EINTR);
|
while (!(fp = fopen(sfpath, "r")) && errno == EINTR);
|
||||||
if (G_UNLIKELY(!fp)) {
|
if (G_UNLIKELY(!fp)) {
|
||||||
FATAL("problems opening state file \"%s\" for reading: %s\n",
|
g_error("failed to open %s: %s",
|
||||||
sfpath, strerror(errno));
|
sfpath, strerror(errno));
|
||||||
}
|
}
|
||||||
for (i = 0; i < ARRAY_SIZE(sf_callbacks); i++) {
|
for (i = 0; i < ARRAY_SIZE(sf_callbacks); i++) {
|
||||||
sf_callbacks[i].reader(fp);
|
sf_callbacks[i].reader(fp);
|
||||||
@ -101,6 +103,6 @@ void read_state_file(void)
|
|||||||
|
|
||||||
void G_GNUC_NORETURN state_file_fatal(void)
|
void G_GNUC_NORETURN state_file_fatal(void)
|
||||||
{
|
{
|
||||||
FATAL("error parsing state file \"%s\"\n", sfpath);
|
g_error("failed to parse %s", sfpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user