summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2021-04-20 16:07:00 -0700
committerGravatar GitHub2021-04-20 16:07:00 -0700
commit4cd6c3e6f1440375d77c38dfc2041ee7d3f3d301 (patch)
tree11cbefaff4db119429a628dfc1b5cb3b71a3f8de
parentMerge pull request #6218 from lioncash/tcache (diff)
parentlog/backend: Use in-class initializer for FileBackend (diff)
downloadyuzu-4cd6c3e6f1440375d77c38dfc2041ee7d3f3d301.tar.gz
yuzu-4cd6c3e6f1440375d77c38dfc2041ee7d3f3d301.tar.xz
yuzu-4cd6c3e6f1440375d77c38dfc2041ee7d3f3d301.zip
Merge pull request #6219 from lioncash/log-erase
log/backend: Make use of erase_if
-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:
56 56
57 void RemoveBackend(std::string_view backend_name) { 57 void RemoveBackend(std::string_view backend_name) {
58 std::lock_guard lock{writing_mutex}; 58 std::lock_guard lock{writing_mutex};
59 const auto it = 59
60 std::remove_if(backends.begin(), backends.end(), 60 std::erase_if(backends, [&backend_name](const auto& backend) {
61 [&backend_name](const auto& i) { return backend_name == i->GetName(); }); 61 return backend_name == backend->GetName();
62 backends.erase(it, backends.end()); 62 });
63 } 63 }
64 64
65 const Filter& GetGlobalFilter() const { 65 const Filter& GetGlobalFilter() const {
@@ -148,12 +148,14 @@ void ColorConsoleBackend::Write(const Entry& entry) {
148 PrintColoredMessage(entry); 148 PrintColoredMessage(entry);
149} 149}
150 150
151FileBackend::FileBackend(const std::string& filename) : bytes_written(0) { 151FileBackend::FileBackend(const std::string& filename) {
152 if (FS::Exists(filename + ".old.txt")) { 152 const auto old_filename = filename + ".old.txt";
153 FS::Delete(filename + ".old.txt"); 153
154 if (FS::Exists(old_filename)) {
155 FS::Delete(old_filename);
154 } 156 }
155 if (FS::Exists(filename)) { 157 if (FS::Exists(filename)) {
156 FS::Rename(filename, filename + ".old.txt"); 158 FS::Rename(filename, old_filename);
157 } 159 }
158 160
159 // _SH_DENYWR allows read only access to the file for other programs. 161 // _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:
94 void Write(const Entry& entry) override; 94 void Write(const Entry& entry) override;
95 95
96private: 96private:
97 Common::FS::IOFile file; 97 FS::IOFile file;
98 std::size_t bytes_written; 98 std::size_t bytes_written = 0;
99}; 99};
100 100
101/** 101/**