MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / InitLogFile

Method InitLogFile

lib/mdflib/mdfviewer/src/util/logfile.cpp:226–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226void LogFile::InitLogFile(const std::string &base_name) {
227 try {
228 stop_thread_ = true;
229 if (worker_thread_.joinable()) {
230 condition_.notify_one();
231 worker_thread_.join();
232 }
233 stop_thread_ = false;
234 if (file_ != nullptr) {
235 fclose(file_);
236 file_ = nullptr;
237 }
238 filename_ = {};
239 path p = FindLogPath(base_name);
240 if (p.empty()) {
241 throw std::ios_base::failure(std::string("Path is empty. Path: ") +
242 p.string());
243 }
244 if (!exists(p.parent_path())) {
245 throw std::ios_base::failure(std::string("Path does not exist Path: ") +
246 p.string());
247 }
248 filename_ = p.string();
249 StartWorkerThread();
250 } catch (const std::exception &error) {
251 std::cerr << "Couldn't initiate a log file. Error: " << error.what()
252 << std::endl;
253 }
254}
255
256bool LogFile::HasLogFile() const { return !filename_.empty(); }
257

Callers

nothing calls this directly

Calls 3

FindLogPathFunction · 0.85
failureFunction · 0.85
emptyMethod · 0.80

Tested by

no test coverage detected