Skip to content

Commit 68275e4

Browse files
committed
pln: env variable RS_PLN_LOGFILE for non-default logfile name
1 parent 0329a36 commit 68275e4

File tree

3 files changed

+34
-18
lines changed

3 files changed

+34
-18
lines changed

planning/src/RS/rsOpts.cpp

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,36 +115,36 @@ void rsOpts::print(CStr label) const noexcept {
115115
cout << label;
116116
else
117117
cout << endl;
118-
printf(" argc_ = %i\n", argc_);
118+
::printf(" argc_ = %i\n", argc_);
119119
if (argv_) {
120-
for (int i = 1; i < argc_; i++) printf(" argv[%i] = %s", i, argv_[i]);
120+
for (int i = 1; i < argc_; i++) ::printf(" argv[%i] = %s", i, argv_[i]);
121121
} else {
122122
lputs("\n\t !!! no argv_");
123123
}
124124
lputs();
125125

126126
bool exi = input_file_exists(deviceXML_);
127-
printf(" deviceXML_: %s exists:%i\n", nns(deviceXML_), exi);
127+
::printf(" deviceXML_: %s exists:%i\n", nns(deviceXML_), exi);
128128

129129
exi = input_file_exists(csvFile_);
130-
printf(" csvFile_: %s exists:%i\n", nns(csvFile_), exi);
130+
::printf(" csvFile_: %s exists:%i\n", nns(csvFile_), exi);
131131

132-
printf(" pcfFile_: %s\n", nns(pcfFile_));
133-
printf(" blifFile_: %s\n", nns(blifFile_));
134-
printf(" jsonFile_: %s\n", nns(jsonFile_));
135-
printf(" editsFile_: %s\n", nns(editsFile_));
136-
printf(" output_: %s\n", nns(output_));
137-
printf(" assignOrder_: %s\n", nns(assignOrder_));
132+
::printf(" pcfFile_: %s\n", nns(pcfFile_));
133+
::printf(" blifFile_: %s\n", nns(blifFile_));
134+
::printf(" jsonFile_: %s\n", nns(jsonFile_));
135+
::printf(" editsFile_: %s\n", nns(editsFile_));
136+
::printf(" output_: %s\n", nns(output_));
137+
::printf(" assignOrder_: %s\n", nns(assignOrder_));
138138

139-
printf(" input_: %s\n", nns(input_));
139+
::printf(" input_: %s\n", nns(input_));
140140

141-
printf(" test_id_ = %i\n", test_id_);
142-
printf(" trace_ = %i traceIndex_ = %i\n", trace_, traceIndex_);
141+
::printf(" test_id_ = %i\n", test_id_);
142+
::printf(" trace_ = %i traceIndex_ = %i\n", trace_, traceIndex_);
143143
cout << " trace_specified: " << std::boolalpha << trace_specified() << '\n';
144144
cout << " unit_specified: " << std::boolalpha << unit_specified() << endl;
145145

146-
printf(" help_:%i check_:%i\n", help_, check_);
147-
printf(" ver:%i det_ver_:%i\n", version_, det_ver_);
146+
::printf(" help_:%i check_:%i\n", help_, check_);
147+
::printf(" ver:%i det_ver_:%i\n", version_, det_ver_);
148148

149149
lputs();
150150
#endif // RSBE_UNIT_TEST_ON
@@ -168,10 +168,13 @@ void rsOpts::printHelp() const noexcept {
168168
CStr hlp = tab1[i+1];
169169
if (!hlp)
170170
break;
171-
printf("%30s : %s\n", opt, hlp);
171+
::printf("%30s : %s\n", opt, hlp);
172172
}
173173

174-
flush_out(true);
174+
cout << endl;
175+
::printf("Logfile can be specified by env variable RS_PLN_LOGFILE\n");
176+
::printf("Default logfile is 'rs_planner.log'\n");
177+
cout << endl;
175178
}
176179

177180
static char* make_file_name(CStr arg) noexcept {

planning/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
static const char* _pln_VERSION_STR = "pln0349";
1+
static const char* _pln_VERSION_STR = "pln0350";
22

33
#include "RS/rsEnv.h"
44
#include "util/pln_log.h"

planning/src/util/pln_log.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ bool open_pln_logfile(CStr fn) noexcept {
4949
assert(fn and fn[0]);
5050
if (_plnLF.is_open())
5151
return false;
52+
53+
CStr env_fn = ::getenv("RS_PLN_LOGFILE");
54+
if (env_fn and env_fn[0]) {
55+
if (fn and ::strcmp(fn, env_fn)) {
56+
cout << endl;
57+
::printf("PLN: using logfile name '%s' from env variable %s\n",
58+
env_fn, "RS_PLN_LOGFILE");
59+
cout << endl; cout.flush();
60+
fflush(stdout);
61+
}
62+
fn = env_fn;
63+
}
64+
5265
if (!fn or !fn[0])
5366
return false;
5467

0 commit comments

Comments
 (0)