================
@@ -642,17 +640,19 @@ int main(int argc, char *argv[]) {
}
#endif
- std::unique_ptr<Log> log = nullptr;
- const char *log_file_path = getenv("LLDBDAP_LOG");
- if (log_file_path) {
- std::error_code EC;
- log = std::make_unique<Log>(log_file_path, EC);
- if (EC) {
- llvm::logAllUnhandledErrors(llvm::errorCodeToError(EC), llvm::errs(),
- "Failed to create log file: ");
+ std::unique_ptr<llvm::raw_ostream> log_os;
+ if (const char *log_file_path = getenv("LLDBDAP_LOG"); log_file_path) {
+ int FD;
+ if (std::error_code EC =
+ llvm::sys::fs::openFileForWrite(log_file_path, FD)) {
+ llvm::errs() << "Failed to open log file: " << log_file_path << ": "
+ << EC.message() << "\n";
return EXIT_FAILURE;
}
+ log_os = std::make_unique<llvm::raw_fd_ostream>(FD, /*shouldClose=*/true);
}
+ Log::Mutex mutex;
+ Log log(log_os ? *log_os.get() : llvm::nulls(), mutex);
----------------
DrSergei wrote:
nit: don't need `get` here
https://github.com/llvm/llvm-project/pull/170731
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits