Skip to content

Commit 3237ad6

Browse files
clang
1 parent 77ab7bb commit 3237ad6

8 files changed

Lines changed: 73 additions & 80 deletions

File tree

examples/common/sdl_media_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#include "sdl_media_manager.h"
1818

1919
#include "fallback_capture.h"
20-
#include "lk_log.h"
2120
#include "livekit/livekit.h"
21+
#include "lk_log.h"
2222
#include "sdl_media.h"
2323
#include "sdl_video_renderer.h"
2424
#include <cstring>

examples/common/sdl_video_renderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
#include "sdl_video_renderer.h"
1818

19-
#include "lk_log.h"
2019
#include "livekit/livekit.h"
20+
#include "lk_log.h"
2121
#include <cstring>
2222

2323
using namespace livekit;

examples/logging_levels/basic_usage.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
/// If no argument is given, the example cycles through every level so you can
3535
/// see which messages are filtered at each setting.
3636

37-
#include "lk_log.h"
3837
#include "livekit/livekit.h"
38+
#include "lk_log.h"
3939

4040
#include <cstring>
4141
#include <iostream>
@@ -79,8 +79,7 @@ livekit::LogLevel parseLevel(const char *arg) {
7979
return livekit::LogLevel::Critical;
8080
if (std::strcmp(arg, "off") == 0)
8181
return livekit::LogLevel::Off;
82-
std::cerr << "Unknown level '" << arg
83-
<< "', defaulting to Info.\n"
82+
std::cerr << "Unknown level '" << arg << "', defaulting to Info.\n"
8483
<< "Valid: trace, debug, info, warn, error, critical, off\n";
8584
return livekit::LogLevel::Info;
8685
}
@@ -123,12 +122,12 @@ void runCallbackDemo() {
123122

124123
// Install a user-defined callback that captures all log output.
125124
// In a real ROS2 node you would replace this with RCLCPP_* macros.
126-
livekit::setLogCallback(
127-
[](livekit::LogLevel level, const std::string &logger_name,
128-
const std::string &message) {
129-
std::cout << "[CALLBACK] [" << levelName(level) << "] [" << logger_name
130-
<< "] " << message << "\n";
131-
});
125+
livekit::setLogCallback([](livekit::LogLevel level,
126+
const std::string &logger_name,
127+
const std::string &message) {
128+
std::cout << "[CALLBACK] [" << levelName(level) << "] [" << logger_name
129+
<< "] " << message << "\n";
130+
});
132131

133132
LK_LOG_INFO("This message is routed through the custom callback");
134133
LK_LOG_WARN("Warnings also go through the callback");

examples/logging_levels/custom_sinks.cpp

Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ void runFileSinkDemo() {
120120

121121
// The shared_ptr keeps the stream alive inside the lambda even if
122122
// the local variable goes out of scope before the callback fires.
123-
livekit::LogCallback fileSink =
124-
[file](livekit::LogLevel level, const std::string &logger_name,
125-
const std::string &message) {
126-
*file << nowISO8601() << " [" << levelTag(level) << "] ["
127-
<< logger_name << "] " << message << "\n";
128-
file->flush();
129-
};
123+
livekit::LogCallback fileSink = [file](livekit::LogLevel level,
124+
const std::string &logger_name,
125+
const std::string &message) {
126+
*file << nowISO8601() << " [" << levelTag(level) << "] [" << logger_name
127+
<< "] " << message << "\n";
128+
file->flush();
129+
};
130130

131131
// In a real app you would call:
132132
// livekit::setLogCallback(fileSink);
@@ -178,14 +178,13 @@ std::string escapeJson(const std::string &s) {
178178
void runJsonSinkDemo() {
179179
std::cout << "\n=== JSON sink: structured log lines to stdout ===\n\n";
180180

181-
livekit::LogCallback jsonSink =
182-
[](livekit::LogLevel level, const std::string &logger_name,
183-
const std::string &message) {
184-
std::cout << R"({"ts":")" << nowISO8601() << R"(","level":")"
185-
<< levelTag(level) << R"(","logger":")"
186-
<< escapeJson(logger_name) << R"(","msg":")"
187-
<< escapeJson(message) << "\"}\n";
188-
};
181+
livekit::LogCallback jsonSink = [](livekit::LogLevel level,
182+
const std::string &logger_name,
183+
const std::string &message) {
184+
std::cout << R"({"ts":")" << nowISO8601() << R"(","level":")"
185+
<< levelTag(level) << R"(","logger":")" << escapeJson(logger_name)
186+
<< R"(","msg":")" << escapeJson(message) << "\"}\n";
187+
};
189188

190189
livekit::setLogCallback(jsonSink);
191190
driveCallback(jsonSink);
@@ -228,39 +227,38 @@ void runRos2SinkDemo() {
228227

229228
const std::string node_name = "livekit_bridge_node";
230229

231-
livekit::LogCallback ros2Sink =
232-
[&node_name](livekit::LogLevel level, const std::string &logger_name,
233-
const std::string &message) {
234-
const char *ros_level;
235-
switch (level) {
236-
case livekit::LogLevel::Trace:
237-
case livekit::LogLevel::Debug:
238-
ros_level = "DEBUG";
239-
break;
240-
case livekit::LogLevel::Info:
241-
ros_level = "INFO";
242-
break;
243-
case livekit::LogLevel::Warn:
244-
ros_level = "WARN";
245-
break;
246-
case livekit::LogLevel::Error:
247-
case livekit::LogLevel::Critical:
248-
ros_level = "ERROR";
249-
break;
250-
default:
251-
ros_level = "INFO";
252-
break;
253-
}
230+
livekit::LogCallback ros2Sink = [&node_name](livekit::LogLevel level,
231+
const std::string &logger_name,
232+
const std::string &message) {
233+
const char *ros_level;
234+
switch (level) {
235+
case livekit::LogLevel::Trace:
236+
case livekit::LogLevel::Debug:
237+
ros_level = "DEBUG";
238+
break;
239+
case livekit::LogLevel::Info:
240+
ros_level = "INFO";
241+
break;
242+
case livekit::LogLevel::Warn:
243+
ros_level = "WARN";
244+
break;
245+
case livekit::LogLevel::Error:
246+
case livekit::LogLevel::Critical:
247+
ros_level = "ERROR";
248+
break;
249+
default:
250+
ros_level = "INFO";
251+
break;
252+
}
254253

255-
// Mimic: [INFO] [1719500000.123] [livekit_bridge_node]: [livekit] msg
256-
auto epoch_s =
257-
std::chrono::duration<double>(
258-
std::chrono::system_clock::now().time_since_epoch())
259-
.count();
260-
std::cout << "[" << ros_level << "] [" << std::fixed
261-
<< std::setprecision(3) << epoch_s << "] [" << node_name
262-
<< "]: [" << logger_name << "] " << message << "\n";
263-
};
254+
// Mimic: [INFO] [1719500000.123] [livekit_bridge_node]: [livekit] msg
255+
auto epoch_s = std::chrono::duration<double>(
256+
std::chrono::system_clock::now().time_since_epoch())
257+
.count();
258+
std::cout << "[" << ros_level << "] [" << std::fixed << std::setprecision(3)
259+
<< epoch_s << "] [" << node_name << "]: [" << logger_name << "] "
260+
<< message << "\n";
261+
};
264262

265263
livekit::setLogCallback(ros2Sink);
266264
driveCallback(ros2Sink);

examples/simple_room/fallback_capture.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#include <iostream>
2424
#include <thread>
2525

26-
#include "lk_log.h"
2726
#include "livekit/livekit.h"
27+
#include "lk_log.h"
2828
#include "wav_audio_source.h"
2929

3030
using namespace livekit;

examples/simple_room/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
#include <thread>
2727
#include <vector>
2828

29-
#include "lk_log.h"
3029
#include "livekit/livekit.h"
30+
#include "lk_log.h"
3131
#include "sdl_media_manager.h"
3232
#include "wav_audio_source.h"
3333

src/tests/integration/test_logging.cpp

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,11 @@ TEST_F(LoggingTest, CallbackReceivesLogMessages) {
7272
std::mutex mtx;
7373
std::vector<Captured> captured;
7474

75-
livekit::setLogCallback(
76-
[&](LogLevel level, const std::string &logger_name,
77-
const std::string &message) {
78-
std::lock_guard<std::mutex> lock(mtx);
79-
captured.push_back({level, logger_name, message});
80-
});
75+
livekit::setLogCallback([&](LogLevel level, const std::string &logger_name,
76+
const std::string &message) {
77+
std::lock_guard<std::mutex> lock(mtx);
78+
captured.push_back({level, logger_name, message});
79+
});
8180

8281
livekit::setLogLevel(LogLevel::Trace);
8382

@@ -102,11 +101,11 @@ TEST_F(LoggingTest, CallbackReceivesCorrectLevel) {
102101
std::mutex mtx;
103102
std::vector<LogLevel> levels_seen;
104103

105-
livekit::setLogCallback([&](LogLevel level, const std::string &,
106-
const std::string &) {
107-
std::lock_guard<std::mutex> lock(mtx);
108-
levels_seen.push_back(level);
109-
});
104+
livekit::setLogCallback(
105+
[&](LogLevel level, const std::string &, const std::string &) {
106+
std::lock_guard<std::mutex> lock(mtx);
107+
levels_seen.push_back(level);
108+
});
110109

111110
livekit::setLogLevel(LogLevel::Trace);
112111

@@ -202,21 +201,17 @@ TEST_F(LoggingTest, ReplacingCallbackStopsOldOne) {
202201
std::atomic<int> old_count{0};
203202
std::atomic<int> new_count{0};
204203

205-
livekit::setLogCallback(
206-
[&](LogLevel, const std::string &, const std::string &) {
207-
old_count.fetch_add(1);
208-
});
204+
livekit::setLogCallback([&](LogLevel, const std::string &,
205+
const std::string &) { old_count.fetch_add(1); });
209206

210207
livekit::setLogLevel(LogLevel::Trace);
211208
LK_LOG_INFO("to old");
212209
EXPECT_GE(old_count.load(), 1);
213210

214211
int old_before = old_count.load();
215212

216-
livekit::setLogCallback(
217-
[&](LogLevel, const std::string &, const std::string &) {
218-
new_count.fetch_add(1);
219-
});
213+
livekit::setLogCallback([&](LogLevel, const std::string &,
214+
const std::string &) { new_count.fetch_add(1); });
220215

221216
LK_LOG_INFO("to new");
222217

src/tests/integration/test_sdk_initialization.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ TEST_F(SDKInitializationTest, InitializeDefault) {
3434

3535
TEST_F(SDKInitializationTest, InitializeWithLogLevel) {
3636
bool result = livekit::initialize(livekit::LogLevel::Debug);
37-
EXPECT_TRUE(result) << "Initialization with explicit log level should succeed";
37+
EXPECT_TRUE(result)
38+
<< "Initialization with explicit log level should succeed";
3839
EXPECT_EQ(livekit::getLogLevel(), livekit::LogLevel::Debug);
3940
}
4041

0 commit comments

Comments
 (0)