summaryrefslogtreecommitdiff
path: root/src/common/logging
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/logging')
-rw-r--r--src/common/logging/backend.cpp22
-rw-r--r--src/common/logging/backend.h16
2 files changed, 16 insertions, 22 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 04bc3128f..62cfde397 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -113,19 +113,19 @@ private:
113 Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr, 113 Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr,
114 const char* function, std::string message) const { 114 const char* function, std::string message) const {
115 using std::chrono::duration_cast; 115 using std::chrono::duration_cast;
116 using std::chrono::microseconds;
116 using std::chrono::steady_clock; 117 using std::chrono::steady_clock;
117 118
118 Entry entry; 119 return {
119 entry.timestamp = 120 .timestamp = duration_cast<microseconds>(steady_clock::now() - time_origin),
120 duration_cast<std::chrono::microseconds>(steady_clock::now() - time_origin); 121 .log_class = log_class,
121 entry.log_class = log_class; 122 .log_level = log_level,
122 entry.log_level = log_level; 123 .filename = filename,
123 entry.filename = filename; 124 .line_num = line_nr,
124 entry.line_num = line_nr; 125 .function = function,
125 entry.function = function; 126 .message = std::move(message),
126 entry.message = std::move(message); 127 .final_entry = false,
127 128 };
128 return entry;
129 } 129 }
130 130
131 std::mutex writing_mutex; 131 std::mutex writing_mutex;
diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h
index fc338c70d..da1c2f185 100644
--- a/src/common/logging/backend.h
+++ b/src/common/logging/backend.h
@@ -21,19 +21,13 @@ class Filter;
21 */ 21 */
22struct Entry { 22struct Entry {
23 std::chrono::microseconds timestamp; 23 std::chrono::microseconds timestamp;
24 Class log_class; 24 Class log_class{};
25 Level log_level; 25 Level log_level{};
26 const char* filename; 26 const char* filename = nullptr;
27 unsigned int line_num; 27 unsigned int line_num = 0;
28 std::string function; 28 std::string function;
29 std::string message; 29 std::string message;
30 bool final_entry = false; 30 bool final_entry = false;
31
32 Entry() = default;
33 Entry(Entry&& o) = default;
34
35 Entry& operator=(Entry&& o) = default;
36 Entry& operator=(const Entry& o) = default;
37}; 31};
38 32
39/** 33/**
@@ -100,7 +94,7 @@ public:
100 void Write(const Entry& entry) override; 94 void Write(const Entry& entry) override;
101 95
102private: 96private:
103 FileUtil::IOFile file; 97 Common::FS::IOFile file;
104 std::size_t bytes_written; 98 std::size_t bytes_written;
105}; 99};
106 100