summaryrefslogtreecommitdiff
path: root/src/common/logging/backend.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/logging/backend.cpp')
-rw-r--r--src/common/logging/backend.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index ed1e93cc2..59b999935 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -3,19 +3,20 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm> 5#include <algorithm>
6#include <array> 6#include <atomic>
7#include <chrono> 7#include <chrono>
8#include <climits> 8#include <climits>
9#include <condition_variable> 9#include <condition_variable>
10#include <memory> 10#include <memory>
11#include <mutex>
11#include <thread> 12#include <thread>
13#include <vector>
12#ifdef _WIN32 14#ifdef _WIN32
13#include <share.h> // For _SH_DENYWR 15#include <share.h> // For _SH_DENYWR
14#else 16#else
15#define _SH_DENYWR 0 17#define _SH_DENYWR 0
16#endif 18#endif
17#include "common/assert.h" 19#include "common/assert.h"
18#include "common/common_funcs.h" // snprintf compatibility define
19#include "common/logging/backend.h" 20#include "common/logging/backend.h"
20#include "common/logging/log.h" 21#include "common/logging/log.h"
21#include "common/logging/text_formatter.h" 22#include "common/logging/text_formatter.h"
@@ -48,11 +49,11 @@ public:
48 backends.push_back(std::move(backend)); 49 backends.push_back(std::move(backend));
49 } 50 }
50 51
51 void RemoveBackend(const std::string& backend_name) { 52 void RemoveBackend(std::string_view backend_name) {
52 std::lock_guard<std::mutex> lock(writing_mutex); 53 std::lock_guard<std::mutex> lock(writing_mutex);
53 auto it = std::remove_if(backends.begin(), backends.end(), [&backend_name](const auto& i) { 54 const auto it =
54 return !strcmp(i->GetName(), backend_name.c_str()); 55 std::remove_if(backends.begin(), backends.end(),
55 }); 56 [&backend_name](const auto& i) { return backend_name == i->GetName(); });
56 backends.erase(it, backends.end()); 57 backends.erase(it, backends.end());
57 } 58 }
58 59
@@ -64,10 +65,10 @@ public:
64 filter = f; 65 filter = f;
65 } 66 }
66 67
67 Backend* GetBackend(const std::string& backend_name) { 68 Backend* GetBackend(std::string_view backend_name) {
68 auto it = std::find_if(backends.begin(), backends.end(), [&backend_name](const auto& i) { 69 const auto it =
69 return !strcmp(i->GetName(), backend_name.c_str()); 70 std::find_if(backends.begin(), backends.end(),
70 }); 71 [&backend_name](const auto& i) { return backend_name == i->GetName(); });
71 if (it == backends.end()) 72 if (it == backends.end())
72 return nullptr; 73 return nullptr;
73 return it->get(); 74 return it->get();
@@ -265,11 +266,11 @@ void AddBackend(std::unique_ptr<Backend> backend) {
265 Impl::Instance().AddBackend(std::move(backend)); 266 Impl::Instance().AddBackend(std::move(backend));
266} 267}
267 268
268void RemoveBackend(const std::string& backend_name) { 269void RemoveBackend(std::string_view backend_name) {
269 Impl::Instance().RemoveBackend(backend_name); 270 Impl::Instance().RemoveBackend(backend_name);
270} 271}
271 272
272Backend* GetBackend(const std::string& backend_name) { 273Backend* GetBackend(std::string_view backend_name) {
273 return Impl::Instance().GetBackend(backend_name); 274 return Impl::Instance().GetBackend(backend_name);
274} 275}
275 276