Skip to content

Commit 265f6dc

Browse files
authored
Merge pull request #800 from os-fpga/pln_added_logfile
pln: added logfile (split print to stdout and to logfile)
2 parents 27ef04f + e61b8ea commit 265f6dc

File tree

4 files changed

+226
-134
lines changed

4 files changed

+226
-134
lines changed

planning/src/RS/rsEnv.cpp

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ using std::cout;
1515
using std::endl;
1616

1717
rsEnv::rsEnv() noexcept {
18-
CStr ts = getenv("pln_trace_marker");
18+
CStr ts = ::getenv("pln_trace_marker");
1919
if (ts) traceMarker_ = ts;
2020

21+
ts = ::getenv("pln_no_logfile");
22+
if (not ts) {
23+
open_pln_logfile("rs_planner.log");
24+
}
25+
2126
init();
2227
}
2328

@@ -240,64 +245,64 @@ bool rsEnv::getPidExePath(int pid, std::string& out) noexcept { return true; }
240245
cout.setf(origF); }
241246

242247
void rsEnv::listDevEnv() const noexcept {
243-
lprintf("\n\t PLN ver. %s\n", shortVer_.c_str());
244-
lprintf("\t compiled: %s\n", compTimeCS());
248+
printf("\n\t PLN ver. %s\n", shortVer_.c_str());
249+
printf("\t compiled: %s\n", compTimeCS());
245250

246251
size_t cxxstd = __cplusplus;
247-
lprintf("\n(compiler) -- c++std= %zu\n", cxxstd);
252+
printf("\n(compiler) -- c++std= %zu\n", cxxstd);
248253
#ifdef __GNUC__
249-
lprintf("\t __GNUC__ \t\t %i\n", __GNUC__);
254+
printf("\t __GNUC__ \t\t %i\n", __GNUC__);
250255
#endif
251256
#ifdef __GNUC_MINOR__
252-
lprintf("\t __GNUC_MINOR__ \t %i\n", __GNUC_MINOR__);
257+
printf("\t __GNUC_MINOR__ \t %i\n", __GNUC_MINOR__);
253258
#endif
254259
#ifdef __VERSION__
255-
lprintf("\t __VERSION__ \t\t %s\n", __VERSION__);
260+
printf("\t __VERSION__ \t\t %s\n", __VERSION__);
256261
#endif
257262
#ifdef __OPTIMIZE__
258-
lprintf("\t __OPTIMIZE__ \t\t %i\n", __OPTIMIZE__);
263+
printf("\t __OPTIMIZE__ \t\t %i\n", __OPTIMIZE__);
259264
#else
260-
lprintf("\t __OPTIMIZE__ :\t NOT DEFINED => deb binary\n");
265+
printf("\t __OPTIMIZE__ :\t NOT DEFINED => deb binary\n");
261266
#endif
262267
#ifdef __NO_INLINE__
263-
lprintf("\t __NO_INLINE__ :\t (defined)\n");
268+
printf("\t __NO_INLINE__ :\t (defined)\n");
264269
#endif
265270
#ifdef NDEBUG
266-
lprintf("\t NDEBUG : (defined) => assert() is disabled\n");
271+
printf("\t NDEBUG : (defined) => assert() is disabled\n");
267272
#else
268-
lprintf("\t NDEBUG : NOT DEFINED => assert() is enabled\n");
273+
printf("\t NDEBUG : NOT DEFINED => assert() is enabled\n");
269274
#endif
270275

271-
lprintf("\n(modes)\n");
276+
printf("\n(modes)\n");
272277
#ifdef NO_GRAPHICS
273-
lprintf("\t NO_GRAPHICS : \t (defined)\n");
278+
printf("\t NO_GRAPHICS : \t (defined)\n");
274279
#endif
275280
#ifdef RS_PC_MODE
276-
lprintf("\t RS_PC_MODE :\t (defined)\n");
281+
printf("\t RS_PC_MODE :\t (defined)\n");
277282
#endif
278283
#ifdef PINC_DEVEL_MODE
279-
lprintf("\t PINC_DEVEL_MODE :\t (defined)\n");
284+
printf("\t PINC_DEVEL_MODE :\t (defined)\n");
280285
#endif
281286
#ifdef NN_FAST_BUILD
282-
lprintf("\t NN_FAST_BUILD :\t (defined)\n");
287+
printf("\t NN_FAST_BUILD :\t (defined)\n");
283288
#endif
284289
#ifdef ENABLE_ANALYTIC_PLACE
285-
lprintf("\t ENABLE_ANALYTIC_PLACE :\t (defined)\n");
290+
printf("\t ENABLE_ANALYTIC_PLACE :\t (defined)\n");
286291
#endif
287292

288-
lputs();
293+
cout << endl;
289294

290295
#ifdef _PLN_VEC_BOUNDS_CHECK
291-
lprintf("\t _PLN_VEC_BOUNDS_CHECK : ON => stl_vector BC enabled\n");
296+
printf("\t _PLN_VEC_BOUNDS_CHECK : ON => stl_vector BC enabled\n");
292297
#else
293-
lprintf("\t _PLN_VEC_BOUNDS_CHECK : OFF => std_vector BC disabled\n");
298+
printf("\t _PLN_VEC_BOUNDS_CHECK : OFF => std_vector BC disabled\n");
294299
#endif
295300

296301
#ifdef PLN_JEMALLOC
297302
LIST_DEC(PLN_JEMALLOC);
298303
#endif
299304

300-
pln::flush_out(true);
305+
cout << endl;
301306
}
302307

303308
}

planning/src/main.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
static const char* _pln_VERSION_STR = "pln0314";
1+
static const char* _pln_VERSION_STR = "pln0315";
22

33
#include "RS/rsEnv.h"
44
#include "util/pln_log.h"
@@ -419,7 +419,7 @@ static void deal_help(const rsOpts& opts) {
419419
return;
420420
}
421421
if (opts.version_) {
422-
lputs();
422+
cout << endl;
423423
return;
424424
}
425425
if (opts.help_) {
@@ -459,11 +459,6 @@ int main(int argc, char** argv) {
459459

460460
s_env.initVersions(_pln_VERSION_STR);
461461

462-
if (ltrace() >= 3) {
463-
lprintf("\t %s\n", _pln_VERSION_STR);
464-
lprintf("\t compiled: %s\n", s_env.compTimeCS());
465-
}
466-
467462
s_env.parse(argc, argv);
468463

469464
if (opts.trace_ >= 8 || ltrace() >= 9 || getenv("pln_trace_env")) {
@@ -472,11 +467,19 @@ int main(int argc, char** argv) {
472467
}
473468

474469
if (opts.ver_or_help()) {
470+
if (ltrace() >= 2) {
471+
printf("\t %s\n", _pln_VERSION_STR);
472+
printf("\t compiled: %s\n", s_env.compTimeCS());
473+
}
475474
deal_help(opts);
476475
pln::flush_out();
477476
std::quick_exit(0);
478477
}
479478

479+
if (ltrace() >= 2) {
480+
lprintf("\t %s\n", _pln_VERSION_STR);
481+
lprintf("\t compiled: %s\n", s_env.compTimeCS());
482+
}
480483
if (ltrace() >= 4) {
481484
lprintf("ltrace()= %u cmd.argc= %i\n", ltrace(), argc);
482485
}

0 commit comments

Comments
 (0)