summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2019-03-02 14:25:50 -0500
committerGravatar Lioncash2019-03-02 14:44:24 -0500
commit43c1092031a7e0ad2ac9f45a651b97ce19102bb6 (patch)
tree29619034f52f6f4c3587c432e9441df57fb546e3 /src
parentMerge pull request #2183 from ReinUsesLisp/vk-buffer-cache-clang (diff)
downloadyuzu-43c1092031a7e0ad2ac9f45a651b97ce19102bb6.tar.gz
yuzu-43c1092031a7e0ad2ac9f45a651b97ce19102bb6.tar.xz
yuzu-43c1092031a7e0ad2ac9f45a651b97ce19102bb6.zip
logging/backend: Move CreateEntry into the Impl class
This function is only ever used within this source file and makes it easier to remove static state in the following change.
Diffstat (limited to 'src')
-rw-r--r--src/common/logging/backend.cpp51
-rw-r--r--src/common/logging/backend.h4
2 files changed, 26 insertions, 29 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index b369f199f..555addb95 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -39,8 +39,10 @@ public:
39 Impl(Impl const&) = delete; 39 Impl(Impl const&) = delete;
40 const Impl& operator=(Impl const&) = delete; 40 const Impl& operator=(Impl const&) = delete;
41 41
42 void PushEntry(Entry e) { 42 void PushEntry(Class log_class, Level log_level, const char* filename, unsigned int line_num,
43 message_queue.Push(std::move(e)); 43 const char* function, std::string message) {
44 message_queue.Push(
45 CreateEntry(log_class, log_level, filename, line_num, function, std::move(message)));
44 } 46 }
45 47
46 void AddBackend(std::unique_ptr<Backend> backend) { 48 void AddBackend(std::unique_ptr<Backend> backend) {
@@ -108,6 +110,26 @@ private:
108 backend_thread.join(); 110 backend_thread.join();
109 } 111 }
110 112
113 Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr,
114 const char* function, std::string message) const {
115 using std::chrono::duration_cast;
116 using std::chrono::steady_clock;
117
118 static steady_clock::time_point time_origin = steady_clock::now();
119
120 Entry entry;
121 entry.timestamp =
122 duration_cast<std::chrono::microseconds>(steady_clock::now() - time_origin);
123 entry.log_class = log_class;
124 entry.log_level = log_level;
125 entry.filename = Common::TrimSourcePath(filename);
126 entry.line_num = line_nr;
127 entry.function = function;
128 entry.message = std::move(message);
129
130 return entry;
131 }
132
111 std::mutex writing_mutex; 133 std::mutex writing_mutex;
112 std::thread backend_thread; 134 std::thread backend_thread;
113 std::vector<std::unique_ptr<Backend>> backends; 135 std::vector<std::unique_ptr<Backend>> backends;
@@ -271,25 +293,6 @@ const char* GetLevelName(Level log_level) {
271#undef LVL 293#undef LVL
272} 294}
273 295
274Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr,
275 const char* function, std::string message) {
276 using std::chrono::duration_cast;
277 using std::chrono::steady_clock;
278
279 static steady_clock::time_point time_origin = steady_clock::now();
280
281 Entry entry;
282 entry.timestamp = duration_cast<std::chrono::microseconds>(steady_clock::now() - time_origin);
283 entry.log_class = log_class;
284 entry.log_level = log_level;
285 entry.filename = Common::TrimSourcePath(filename);
286 entry.line_num = line_nr;
287 entry.function = function;
288 entry.message = std::move(message);
289
290 return entry;
291}
292
293void SetGlobalFilter(const Filter& filter) { 296void SetGlobalFilter(const Filter& filter) {
294 Impl::Instance().SetGlobalFilter(filter); 297 Impl::Instance().SetGlobalFilter(filter);
295} 298}
@@ -314,9 +317,7 @@ void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
314 if (!filter.CheckMessage(log_class, log_level)) 317 if (!filter.CheckMessage(log_class, log_level))
315 return; 318 return;
316 319
317 Entry entry = 320 instance.PushEntry(log_class, log_level, filename, line_num, function,
318 CreateEntry(log_class, log_level, filename, line_num, function, fmt::vformat(format, args)); 321 fmt::vformat(format, args));
319
320 instance.PushEntry(std::move(entry));
321} 322}
322} // namespace Log 323} // namespace Log
diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h
index a31ee6968..fca0267a1 100644
--- a/src/common/logging/backend.h
+++ b/src/common/logging/backend.h
@@ -135,10 +135,6 @@ const char* GetLogClassName(Class log_class);
135 */ 135 */
136const char* GetLevelName(Level log_level); 136const char* GetLevelName(Level log_level);
137 137
138/// Creates a log entry by formatting the given source location, and message.
139Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsigned int line_nr,
140 const char* function, std::string message);
141
142/** 138/**
143 * The global filter will prevent any messages from even being processed if they are filtered. Each 139 * The global filter will prevent any messages from even being processed if they are filtered. Each
144 * backend can have a filter, but if the level is lower than the global filter, the backend will 140 * backend can have a filter, but if the level is lower than the global filter, the backend will