using boost::program_options::parsed_options;
using boost::program_options::positional_options_description;
using boost::program_options::variables_map;
+using boost::program_options::collect_unrecognized;
+using boost::program_options::include_positional;
using I2n::Logger::GlobalLogger;
//-----------------------------------------------------------------------------
positional( p ).
allow_unregistered().
run();
+
+ // TODO not sure whether the "allow_unregistered()" above is required or not
+ // Because of this option, it is easy to make mistakes in options, so at least
+ // warn
+ vector<string> unrecognized_options = collect_unrecognized(parsed_opt.options,
+ include_positional);
+ if ( !unrecognized_options.empty() )
+ {
+ GlobalLogger.warning() << "Accepted unrecognized options" << endl;
+ }
+
store( parsed_opt, *vm );
notify( *vm );
}
Configuration config_obj = config_reader.get_configuration();
configuration.reset( new Configuration( config_obj ) );
}
+ else
+ {
+ GlobalLogger.error() << "Failed to parse options from command line and/or config file! "
+ << "Continue with standard values." << endl;
+ }
return configuration;
}
void init_logger()
{
+ // set default: log at level NOTICE to syslog
const int default_log_level = I2n::Logger::LogLevel::Notice;
I2n::Logger::enable_syslog( I2n::Logger::Facility::User ); //lint !e1786
switch (log_output)
{
case LogOutput_SYSLOG:
+ GlobalLogger.info() << "Setting log output target to syslog" << endl;
I2n::Logger::enable_syslog(true);
I2n::Logger::enable_stderr_log(false);
I2n::Logger::enable_log_file(false);
+ GlobalLogger.info() << "Set log output target to syslog" << endl;
break;
case LogOutput_TERMINAL:
+ GlobalLogger.info() << "Setting log output target to terminal" << endl;
I2n::Logger::enable_syslog(false);
I2n::Logger::enable_stderr_log(true);
I2n::Logger::enable_log_file(false);
+ GlobalLogger.info() << "Set log output target to terminal" << endl;
+ GlobalLogger.info() << "(check syslog for earlier messages)" << endl;
+ break;
+ default:
+ GlobalLogger.error() << "Unknown log output target!" << endl;
break;
}
}