Commit 259defff81fb23c440fa6aa8d65c857e13758efb

Authored by Jürgen Knödlseder
1 parent ff9009be

Specifying logfile= does not create a log file.

Log file creation may now be disabled by specifying logfile= on the command line. The GPars class has to be changed for this to support empty value arguments.
src/app/GApplication.cpp
... ... @@ -281,15 +281,22 @@ double GApplication::celapse(void) const
281 281 /***********************************************************************//**
282 282 * @brief Open log file
283 283 *
284   - * @param[in] clobber (defaults to true)
  284 + * @param[in] clobber Overwrite (true) or append (false) to existing file
  285 + * (defaults to true)
285 286 *
286 287 * Opens application log file and sets the logger chattiness dependent on
287 288 * the chatter parameter of the application.
288 289 ***************************************************************************/
289 290 void GApplication::logFileOpen(const bool& clobber)
290 291 {
291   - // Initialise the application logger
292   - log.open(log_filename(), clobber);
  292 + // Open logger only if filename is non-empty
  293 + if (!log_filename().empty()) {
  294 +
  295 + // Initialise the application logger
  296 + log.open(log_filename(), clobber);
  297 +
  298 +
  299 + }
293 300  
294 301 // Set logger chattiness
295 302 set_log_chatter();
... ...
src/app/GPars.cpp
... ... @@ -683,7 +683,7 @@ void GPars::load(const std::string& filename,
683 683 // Overwrite parameter values that are specified in the command line
684 684 for (int i = 1; i < args.size(); ++i) {
685 685  
686   - // Extract parameter name and value
  686 + // Extract parameter name and value (empty values are permitted)
687 687 size_t pos = args[i].find("=");
688 688 if (pos == std::string::npos) {
689 689 throw GException::bad_cmdline_argument(G_LOAD2, args[i],
... ... @@ -695,11 +695,7 @@ void GPars::load(const std::string&amp; filename,
695 695 throw GException::bad_cmdline_argument(G_LOAD2, args[i],
696 696 "no parameter name before \"=\"");
697 697 }
698   - if (value.length() < 1) {
699   - throw GException::bad_cmdline_argument(G_LOAD2, args[i],
700   - "no parameter value after \"=\"");
701   - }
702   -
  698 +
703 699 // Check if parameter exists
704 700 if (!contains(name)) {
705 701 throw GException::bad_cmdline_argument(G_LOAD2, args[i],
... ...