| 59 | } |
| 60 | |
| 61 | void dsv_log_enalbe_logfile(bool append) |
| 62 | { |
| 63 | if (!b_logfile && log_ctx){ |
| 64 | b_logfile = true; |
| 65 | |
| 66 | QString lf = get_dsv_log_path(); |
| 67 | |
| 68 | dsv_info("%s\"%s\"", "Store log to file: ", lf.toUtf8().data()); |
| 69 | |
| 70 | QFileInfo fileInfo(lf); |
| 71 | QString file_dir = fileInfo.absolutePath(); |
| 72 | |
| 73 | QDir dir; |
| 74 | if (!dir.exists(file_dir) && !dir.mkpath(file_dir)){ |
| 75 | dsv_err("ERROR: failed to create log directory."); |
| 76 | } |
| 77 | |
| 78 | std::string log_file = pv::path::ToUnicodePath(lf); |
| 79 | |
| 80 | int ret = xlog_add_receiver_from_file(log_ctx, log_file.c_str(), &log_file_index, append); |
| 81 | if (ret != 0){ |
| 82 | dsv_err("Create log file error!"); |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | void dsv_clear_log_file() |
| 88 | { |
no test coverage detected