MCPcopy Create free account
hub / github.com/ERGO-Code/HiGHS / highsOpenLogFile

Function highsOpenLogFile

highs/lp_data/HighsOptions.cpp:20–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18#include "util/stringutil.h"
19
20void highsOpenLogFile(HighsLogOptions& log_options,
21 std::vector<OptionRecord*>& option_records,
22 const std::string& log_file) {
23 HighsInt index;
24 OptionStatus status =
25 getOptionIndex(log_options, "log_file", option_records, index);
26 assert(status == OptionStatus::kOk);
27 if (log_options.log_stream != nullptr) {
28 // Current log file stream is not null, so flush and close it
29 fflush(log_options.log_stream);
30 fclose(log_options.log_stream);
31 // Set the stream to null to give a test whether it has been
32 // closed (and avoid trying to close it again which causes an
33 // error)
34 log_options.log_stream = nullptr;
35 }
36 assert(!log_options.log_stream);
37 // If new log file name is not empty, open it, appending if possible
38 //
39 // If fopen fails then it returns nullptr, so log_file is open for
40 // writing or nullptr
41 if (log_file.compare(""))
42 log_options.log_stream = fopen(log_file.c_str(), "a");
43 OptionRecordString& option = *(OptionRecordString*)option_records[index];
44 option.assignvalue(log_file);
45}
46
47static std::string optionEntryTypeToString(const HighsOptionType type) {
48 if (type == HighsOptionType::kBool) {

Callers 2

openLogFileMethod · 0.70
setLocalOptionValueFunction · 0.70

Calls 3

getOptionIndexFunction · 0.85
c_strMethod · 0.80
assignvalueMethod · 0.45

Tested by

no test coverage detected