aboutsummaryrefslogtreecommitdiffstats
path: root/src/StateFile.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-09-27 22:31:24 +0200
committerMax Kellermann <max@duempel.org>2013-10-02 08:57:55 +0200
commit060814daa83f6a94f5934464ae42a406c5c7e947 (patch)
treef636ec6cdbb8e52fda6db987d2a28fc73c7b94b4 /src/StateFile.cxx
parentc53492a76a8a05825e1c7f699c05645eee891199 (diff)
downloadmpd-060814daa83f6a94f5934464ae42a406c5c7e947.tar.gz
mpd-060814daa83f6a94f5934464ae42a406c5c7e947.tar.xz
mpd-060814daa83f6a94f5934464ae42a406c5c7e947.zip
Log: new logging library API
Prepare to migrate away from GLib. Currently, we're still using GLib as a backend.
Diffstat (limited to 'src/StateFile.cxx')
-rw-r--r--src/StateFile.cxx27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/StateFile.cxx b/src/StateFile.cxx
index 901ebca39..ce812076c 100644
--- a/src/StateFile.cxx
+++ b/src/StateFile.cxx
@@ -26,14 +26,12 @@
#include "Volume.hxx"
#include "event/Loop.hxx"
#include "fs/FileSystem.hxx"
-
-#include <glib.h>
+#include "util/Domain.hxx"
+#include "Log.hxx"
#include <string.h>
-#include <errno.h>
-#undef G_LOG_DOMAIN
-#define G_LOG_DOMAIN "state_file"
+static constexpr Domain state_file_domain("state_file");
StateFile::StateFile(Path &&_path,
Partition &_partition, EventLoop &_loop)
@@ -66,12 +64,13 @@ StateFile::IsModified() const
void
StateFile::Write()
{
- g_debug("Saving state file %s", path_utf8.c_str());
+ FormatDebug(state_file_domain,
+ "Saving state file %s", path_utf8.c_str());
FILE *fp = FOpen(path, FOpenMode::WriteText);
- if (G_UNLIKELY(!fp)) {
- g_warning("failed to create %s: %s",
- path_utf8.c_str(), g_strerror(errno));
+ if (gcc_unlikely(!fp)) {
+ FormatErrno(state_file_domain, "failed to create %s",
+ path_utf8.c_str());
return;
}
@@ -89,12 +88,12 @@ StateFile::Read()
{
bool success;
- g_debug("Loading state file %s", path_utf8.c_str());
+ FormatDebug(state_file_domain, "Loading state file %s", path_utf8.c_str());
TextFile file(path);
if (file.HasFailed()) {
- g_warning("failed to open %s: %s",
- path_utf8.c_str(), g_strerror(errno));
+ FormatErrno(state_file_domain, "failed to open %s",
+ path_utf8.c_str());
return;
}
@@ -105,7 +104,9 @@ StateFile::Read()
playlist_state_restore(line, file, &partition.playlist,
&partition.pc);
if (!success)
- g_warning("Unrecognized line in state file: %s", line);
+ FormatError(state_file_domain,
+ "Unrecognized line in state file: %s",
+ line);
}
RememberVersions();