aboutsummaryrefslogtreecommitdiff
path: root/src/common/logging/backend.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2021-04-20 12:57:45 -0400
committerLioncash <mathew1800@gmail.com>2021-04-20 12:57:49 -0400
commit4105a18d217096ee88d7eb302a56be9b2ba38110 (patch)
treec420bcf8709cf5af735988fddf25bba63ddbd2eb /src/common/logging/backend.cpp
parentb34cf1fe349b818f3ec5a154fbc295097f0632c9 (diff)
log/backend: Use in-class initializer for FileBackend
We can also avoid redundant constructions of the same string repeatedly.
Diffstat (limited to 'src/common/logging/backend.cpp')
-rw-r--r--src/common/logging/backend.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index f0bb392c64..96efa977d8 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -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.