| 239 | std::function<void(void* user_data)> m_deleter; |
| 240 | |
| 241 | LoggingConnection(btck_LogCallback callback, void* user_data, btck_DestroyCallback user_data_destroy_callback) |
| 242 | { |
| 243 | LOCK(cs_main); |
| 244 | |
| 245 | auto connection{LogInstance().PushBackCallback([callback, user_data](const std::string& str) { callback(user_data, str.c_str(), str.length()); })}; |
| 246 | |
| 247 | // Only start logging if we just added the connection. |
| 248 | if (LogInstance().NumConnections() == 1 && !LogInstance().StartLogging()) { |
| 249 | LogError("Logger start failed."); |
| 250 | LogInstance().DeleteCallback(connection); |
| 251 | if (user_data && user_data_destroy_callback) { |
| 252 | user_data_destroy_callback(user_data); |
| 253 | } |
| 254 | throw std::runtime_error("Failed to start logging"); |
| 255 | } |
| 256 | |
| 257 | m_connection = std::make_unique<std::list<std::function<void(const std::string&)>>::iterator>(connection); |
| 258 | m_user_data = user_data; |
| 259 | m_deleter = user_data_destroy_callback; |
| 260 | |
| 261 | LogDebug(BCLog::KERNEL, "Logger connected."); |
| 262 | } |
| 263 | |
| 264 | ~LoggingConnection() |
| 265 | { |
nothing calls this directly
no test coverage detected