|
16 | 16 | #include "Framework/DeviceSpec.h" |
17 | 17 | #include "DriverClientContext.h" |
18 | 18 | #include "DPLWebSocket.h" |
| 19 | +#include "Framework/Signpost.h" |
19 | 20 | #include <uv.h> |
20 | 21 | #include <string_view> |
21 | 22 | #include <charconv> |
22 | 23 |
|
| 24 | +O2_DECLARE_DYNAMIC_LOG(device); |
| 25 | +O2_DECLARE_DYNAMIC_LOG(completion); |
| 26 | +O2_DECLARE_DYNAMIC_LOG(monitoring_service); |
| 27 | + |
23 | 28 | namespace o2::framework |
24 | 29 | { |
25 | 30 |
|
@@ -152,6 +157,41 @@ void on_connect(uv_connect_t* connection, int status) |
152 | 157 | state.tracingFlags = tracingFlags; |
153 | 158 | }); |
154 | 159 |
|
| 160 | + client->observe("/log-streams", [ref = context->ref](std::string_view cmd) { |
| 161 | + auto& state = ref.get<DeviceState>(); |
| 162 | + static constexpr int prefixSize = std::string_view{"/log-streams "}.size(); |
| 163 | + if (prefixSize > cmd.size()) { |
| 164 | + LOG(error) << "Malformed log-streams request"; |
| 165 | + return; |
| 166 | + } |
| 167 | + cmd.remove_prefix(prefixSize); |
| 168 | + int logStreams = 0; |
| 169 | + |
| 170 | + auto error = std::from_chars(cmd.data(), cmd.data() + cmd.size(), logStreams); |
| 171 | + if (error.ec != std::errc()) { |
| 172 | + LOG(error) << "Malformed log-streams mask"; |
| 173 | + return; |
| 174 | + } |
| 175 | + LOGP(info, "Logstreams flags set to {}", logStreams); |
| 176 | + state.logStreams = logStreams; |
| 177 | + if ((state.logStreams & DeviceState::LogStreams::DEVICE_LOG) != 0) { |
| 178 | + O2_LOG_ENABLE(device); |
| 179 | + } else { |
| 180 | + O2_LOG_DISABLE(device); |
| 181 | + } |
| 182 | + if ((state.logStreams & DeviceState::LogStreams::COMPLETION_LOG) != 0) { |
| 183 | + O2_LOG_ENABLE(completion); |
| 184 | + } else { |
| 185 | + O2_LOG_DISABLE(completion); |
| 186 | + } |
| 187 | + |
| 188 | + if ((state.logStreams & DeviceState::LogStreams::MONITORING_SERVICE_LOG) != 0) { |
| 189 | + O2_LOG_ENABLE(monitoring_service); |
| 190 | + } else { |
| 191 | + O2_LOG_DISABLE(monitoring_service); |
| 192 | + } |
| 193 | + }); |
| 194 | + |
155 | 195 | // Client will be filled in the line after. I can probably have a single |
156 | 196 | // client per device. |
157 | 197 | auto dplClient = std::make_unique<WSDPLClient>(); |
|
0 commit comments