From 060814daa83f6a94f5934464ae42a406c5c7e947 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 27 Sep 2013 22:31:24 +0200 Subject: Log: new logging library API Prepare to migrate away from GLib. Currently, we're still using GLib as a backend. --- src/StateFile.cxx | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src/StateFile.cxx') 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 +#include "util/Domain.hxx" +#include "Log.hxx" #include -#include -#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(); -- cgit v1.2.3