5 #include <fwk/RunController.h>
6 #include <fwk/CentralConfig.h>
7 #include <fwk/CommandLineOptions.h>
8 #include <fwk/GITGlobalRevision.h>
9 #include <utl/ErrorLogger.h>
10 #include <utl/AugerException.h>
11 #include <utl/TabularStream.h>
12 #include <utl/Deprecator.h>
14 #ifndef AUGER_SQLITE_ENABLED
15 # include <det/VSQLManager_MySQL.h>
18 #include <boost/filesystem/operations.hpp>
19 #include <boost/program_options.hpp>
27 namespace fs = boost::filesystem;
28 namespace po = boost::program_options;
38 Trailer(
const string& text) : fText(text) { }
46 Red(
const string& str)
48 if (ErrorLogger::GetInstance().HasColor())
49 return "\033[1;31m" + str +
"\033[0m";
72 main(
int argc,
char* argv[])
76 string bootstrapFile(
"bootstrap.xml");
81 po::options_description desc(
"Usage:");
86 po::value<string>(&bootstrapFile),
87 "Bootstrap file name. Defaults to './bootstrap.xml' if this option is not used.")
89 po::value<string>(&logFile),
90 "Write out a log file.")
91 (
"fingerprintFatal,f",
92 "If option is used, throw exceptions in case of mismatch of config file md5 fingerprints.")
95 "Verbosity: -1=default, 0=silent... 3=annoying")
99 po::value<int>(&fpException),
100 "Unmask specific floating-point exceptions for debugging: 1=invalid-sqrt(-1), 4=div-by-0, 8=overflow.")
102 po::value<int>(&logDbQueries)->default_value(logDbQueries),
103 "switch on logging of all SQL queries")
104 (
"show-available-modules",
105 "show available Offline modules")
108 po::variables_map vm;
110 po::store(po::parse_command_line(argc, argv, desc), vm);
112 }
catch (po::error& er) {
113 cerr <<
"Command line error : " << er.what() <<
'\n'
118 if (vm.count(
"help")) {
119 cerr << desc << endl;
123 auto& errorLogger = ErrorLogger::GetInstance();
124 if (vm.count(
"color"))
125 errorLogger.SetColorOutput(
true);
128 if (vm.count(
"verbosity")) {
129 const auto v = vm[
"verbosity"].as<
int>();
130 errorLogger.SetVerbosity(static_cast<Verbosity::EVerbosity>(
135 if (vm.count(
"show-available-modules")) {
136 cout <<
"# list of registered Offline modules:\n";
138 cout << it->first <<
'\n';
144 if (vm.count(
"fpexception"))
145 feenableexcept(fpException);
147 if (vm.count(
"fpexception"))
148 cerr <<
"floating-point exceptions will not be enabled on this architecture..." << endl;
151 #ifndef AUGER_SQLITE_ENABLED
152 if (vm.count(
"log-db-queries"))
162 " ___________________\n"
164 " / ) / ` / ` / __ _\n"
165 " / / _/__ _/__ / / / ) /___)\n"
166 " / / / / / / / / (___\n"
167 " (____/ / / __________________\n"
170 " " << OFFLINE_PACKAGE_STRING <<
"\n"
171 " Reference: Nucl. Instrum. Meth. A 580 (2007) 1485." <<
"\n"
172 " GIT revision number : " << GITGlobalRevision::GetInstance().GetId() <<
"\n"
173 " Bug reports to : " << OFFLINE_PACKAGE_BUGREPORT <<
"\n"
174 " ____________________________________________________\n";
182 <<
"End of run: " << OFFLINE_PACKAGE_STRING <<
endr
183 <<
"GIT revision number: " << GITGlobalRevision::GetInstance().GetId() <<
endr
188 if (vm.count(
"fingerprintFatal"))
194 fwk::CommandLineOptions::GetInstance().SetVariablesMap(vm);
200 auto& myController = RunController::GetInstance();
205 ERROR(
"ModuleSequenceException thrown. Abnormal termination in RunController Init().");
212 ERROR(
"ModuleSequenceException thrown. Abnormal termination in RunController Run().");
217 myController.Finish();
219 ERROR(
"ModuleSequenceException thrown. Abnormal termination in RunController Finish()");
226 const auto& d = Deprecator::GetInstance();
228 WARNING(
"*** The following deprecated methods were used:\n\n" +
230 "Please update your code.");
#define INFO(message)
Macro for logging informational messages.
Exception to use in case of module sequencing failures.
static Iterator Begin()
Begin iterator over the internal map (read only)
int main(int argc, char *argv[])
Trailer(const string &text)
class that triggers insertion of the line row in the TabularStream
class to format data in tabular form
static Iterator End()
End iterator over the internal map (read only)
#define WARNING(message)
Macro for logging warning messages.
static void SetGlobalLogQueries(const int q)
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
string Red(const string &str)
void WriteConfig(const std::string &fileName="")
Get the link name for moduleConfigLink with given id (any)
use default verbosity from error logger
#define ERROR(message)
Macro for logging error messages.