Skip to content

Commit 309f46b

Browse files
committed
[eclipse-iceoryx#464] Try to fix windows gnu build log test
1 parent f013c66 commit 309f46b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

iceoryx2-ffi/cxx/tests/src/log_tests.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
//
1111
// SPDX-License-Identifier: Apache-2.0 OR MIT
1212

13+
#include <mutex>
1314
#include <string>
1415
#include <vector>
1516

17+
1618
#include "iox2/log.hpp"
1719
#include "iox2/log_level.hpp"
1820

@@ -40,10 +42,13 @@ class Entry {
4042

4143
class TestLogger : public Log {
4244
public:
45+
TestLogger()
46+
: Log() {
47+
}
48+
4349
static auto set_global_logger() {
4450
auto& instance = get_instance();
4551
set_logger(instance);
46-
instance.m_log_buffer.clear();
4752
}
4853

4954
static auto get_instance() -> TestLogger& {
@@ -52,16 +57,21 @@ class TestLogger : public Log {
5257
}
5358

5459
void log(LogLevel log_level, const char* origin, const char* message) override {
60+
m_lock.lock();
5561
m_log_buffer.emplace_back(log_level, origin, message);
62+
m_lock.unlock();
5663
}
5764

5865
auto get_log_buffer() -> std::vector<Entry> {
66+
m_lock.lock();
5967
auto buffer = m_log_buffer;
6068
m_log_buffer.clear();
69+
m_lock.unlock();
6170
return buffer;
6271
}
6372

6473
private:
74+
std::mutex m_lock;
6575
std::vector<Entry> m_log_buffer;
6676
};
6777

0 commit comments

Comments
 (0)