summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-04-21 01:07:00 +0200
committerGitHub <noreply@github.com>2021-04-21 01:07:00 +0200
commit4cd6c3e6f1440375d77c38dfc2041ee7d3f3d301 (patch)
tree11cbefaff4db119429a628dfc1b5cb3b71a3f8de
parentMerge pull request #6218 from lioncash/tcache (diff)
parentlog/backend: Use in-class initializer for FileBackend (diff)
downloadyuzu-4cd6c3e6f1440375d77c38dfc2041ee7d3f3d301.tar
yuzu-4cd6c3e6f1440375d77c38dfc2041ee7d3f3d301.tar.gz
yuzu-4cd6c3e6f1440375d77c38dfc2041ee7d3f3d301.tar.bz2
yuzu-4cd6c3e6f1440375d77c38dfc2041ee7d3f3d301.tar.lz
yuzu-4cd6c3e6f1440375d77c38dfc2041ee7d3f3d301.tar.xz
yuzu-4cd6c3e6f1440375d77c38dfc2041ee7d3f3d301.tar.zst
yuzu-4cd6c3e6f1440375d77c38dfc2041ee7d3f3d301.zip
-rw-r--r--src/common/logging/backend.cpp18
-rw-r--r--src/common/logging/backend.h4
2 files changed, 12 insertions, 10 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index bc82905c0..96efa977d 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -56,10 +56,10 @@ public:
void RemoveBackend(std::string_view backend_name) {
std::lock_guard lock{writing_mutex};
- const auto it =
- std::remove_if(backends.begin(), backends.end(),
- [&backend_name](const auto& i) { return backend_name == i->GetName(); });
- backends.erase(it, backends.end());
+
+ std::erase_if(backends, [&backend_name](const auto& backend) {
+ return backend_name == backend->GetName();
+ });
}
const Filter& GetGlobalFilter() const {
@@ -148,12 +148,14 @@ void ColorConsoleBackend::Write(const Entry& entry) {
PrintColoredMessage(entry);
}
-FileBackend::FileBackend(const std::string& filename) : bytes_written(0) {
- if (FS::Exists(filename + ".old.txt")) {
- FS::Delete(filename + ".old.txt");
+FileBackend::FileBackend(const std::string& filename) {
+ const auto old_filename = filename + ".old.txt";
+
+ if (FS::Exists(old_filename)) {
+ FS::Delete(old_filename);
}
if (FS::Exists(filename)) {
- FS::Rename(filename, filename + ".old.txt");
+ FS::Rename(filename, old_filename);
}
// _SH_DENYWR allows read only access to the file for other programs.
diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h
index 84a544ea4..9dd2589c3 100644
--- a/src/common/logging/backend.h
+++ b/src/common/logging/backend.h
@@ -94,8 +94,8 @@ public:
void Write(const Entry& entry) override;
private:
- Common::FS::IOFile file;
- std::size_t bytes_written;
+ FS::IOFile file;
+ std::size_t bytes_written = 0;
};
/**