Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
OREApp Class Reference

Orchestrates the processes covered by ORE, data loading, analytics and reporting. More...

#include <orea/app/oreapp.hpp>

+ Collaboration diagram for OREApp:

Public Member Functions

 OREApp (QuantLib::ext::shared_ptr< Parameters > params, bool console=false, const boost::filesystem::path &logRootPath=boost::filesystem::path())
 Constructor that uses ORE parameters and input data from files. More...
 
 OREApp (const QuantLib::ext::shared_ptr< InputParameters > &inputs, const std::string &logFile, Size logLevel=31, bool console=false, const boost::filesystem::path &logRootPath=boost::filesystem::path())
 Constructor that assumes we have already assembled input parameters via API. More...
 
virtual ~OREApp ()
 Destructor. More...
 
virtual void run ()
 Runs analytics and generates reports after using the first OREApp c'tor. More...
 
void run (const std::vector< std::string > &marketData, const std::vector< std::string > &fixingData)
 Runs analytics and generates reports after using the second OREApp c'tor. More...
 
QuantLib::ext::shared_ptr< InputParametersgetInputs ()
 
std::set< std::string > getAnalyticTypes ()
 
std::set< std::string > getSupportedAnalyticTypes ()
 
const QuantLib::ext::shared_ptr< Analytic > & getAnalytic (std::string type)
 
std::set< std::string > getReportNames ()
 
QuantLib::ext::shared_ptr< PlainInMemoryReportgetReport (std::string reportName)
 
std::set< std::string > getCubeNames ()
 
QuantLib::ext::shared_ptr< NPVCubegetCube (std::string cubeName)
 
std::set< std::string > getMarketCubeNames ()
 
QuantLib::ext::shared_ptr< AggregationScenarioDatagetMarketCube (std::string cubeName)
 
std::vector< std::string > getErrors ()
 
Real getRunTime ()
 time for executing run(...) in seconds More...
 
std::string version ()
 

Protected Member Functions

virtual void analytics ()
 
void buildInputParameters (QuantLib::ext::shared_ptr< InputParameters > inputs, const QuantLib::ext::shared_ptr< Parameters > &params)
 Populate InputParameters object from classic ORE key-value pairs in Parameters. More...
 
QuantLib::ext::shared_ptr< CSVLoaderbuildCsvLoader (const QuantLib::ext::shared_ptr< Parameters > &params)
 
void setupLog (const std::string &path, const std::string &file, QuantLib::Size mask, const boost::filesystem::path &logRootPath, const std::string &progressLogFile="", QuantLib::Size progressLogRotationSize=100 *1024 *1024, bool progressLogToConsole=false, const std::string &structuredLogFile="", QuantLib::Size structuredLogRotationSize=100 *1024 *1024)
 set up logging More...
 
void closeLog ()
 remove logs More...
 
void initFromParams ()
 
void initFromInputs ()
 

Protected Attributes

QuantLib::ext::shared_ptr< Parametersparams_
 ORE Input parameters. More...
 
QuantLib::ext::shared_ptr< InputParametersinputs_
 
QuantLib::ext::shared_ptr< OutputParametersoutputs_
 
QuantLib::ext::shared_ptr< AnalyticsManageranalyticsManager_
 
QuantLib::ext::shared_ptr< StructuredLoggerstructuredLogger_
 
boost::timer::cpu_timer runTimer_
 
string logFile_
 Logging. More...
 
Size logMask_
 
bool console_
 
string outputPath_
 
boost::filesystem::path logRootPath_
 
string progressLogFile_ = ""
 
QuantLib::Size progressLogRotationSize_ = 100 * 1024 * 1024
 
bool progressLogToConsole_ = false
 
string structuredLogFile_ = ""
 
QuantLib::Size structuredLogRotationSize_ = 100 * 1024 * 1024
 
std::vector< std::string > errorMessages_
 

Detailed Description

Orchestrates the processes covered by ORE, data loading, analytics and reporting.

Definition at line 40 of file oreapp.hpp.

Constructor & Destructor Documentation

◆ OREApp() [1/2]

OREApp ( QuantLib::ext::shared_ptr< Parameters params,
bool  console = false,
const boost::filesystem::path &  logRootPath = boost::filesystem::path() 
)

Constructor that uses ORE parameters and input data from files.

Definition at line 43 of file oreapp.hpp.

45 : params_(params), inputs_(nullptr), console_(console), logRootPath_(logRootPath) {}
QuantLib::ext::shared_ptr< Parameters > params_
ORE Input parameters.
Definition: oreapp.hpp:104
boost::filesystem::path logRootPath_
Definition: oreapp.hpp:117
QuantLib::ext::shared_ptr< InputParameters > inputs_
Definition: oreapp.hpp:105

◆ OREApp() [2/2]

OREApp ( const QuantLib::ext::shared_ptr< InputParameters > &  inputs,
const std::string &  logFile,
Size  logLevel = 31,
bool  console = false,
const boost::filesystem::path &  logRootPath = boost::filesystem::path() 
)

Constructor that assumes we have already assembled input parameters via API.

Definition at line 48 of file oreapp.hpp.

50 : params_(nullptr), inputs_(inputs), logFile_(logFile), logMask_(logLevel), console_(console),
51 logRootPath_(logRootPath) {}
string logFile_
Logging.
Definition: oreapp.hpp:113

◆ ~OREApp()

~OREApp ( )
virtual

Destructor.

Definition at line 393 of file oreapp.cpp.

393 {
394 // Close logs
395 closeLog();
396}
void closeLog()
remove logs
Definition: oreapp.cpp:562
+ Here is the call graph for this function:

Member Function Documentation

◆ run() [1/2]

void run ( )
virtual

Runs analytics and generates reports after using the first OREApp c'tor.

Definition at line 398 of file oreapp.cpp.

398 {
399
400 // Only one thread at a time should call run
401 static std::mutex _s_mutex;
402 std::lock_guard<std::mutex> lock(_s_mutex);
403
404 // Clean start, but leave Singletons intact after run is completed
405 {
406 CleanUpThreadLocalSingletons cleanupThreadLocalSingletons;
407 CleanUpThreadGlobalSingletons cleanupThreadGloablSingletons;
408 CleanUpLogSingleton cleanupLogSingleton(true, true);
409 }
410
411 // Use inputs when available, otherwise try params
412 if (inputs_ != nullptr)
414 else if (params_ != nullptr)
416 else {
417 ALOG("both inputs are empty");
418 return;
419 }
420
421 runTimer_.start();
422
423 try {
424 structuredLogger_->clear();
425 analytics();
426 } catch (std::exception& e) {
427 StructuredAnalyticsWarningMessage("OREApp::run()", "Error", e.what()).log();
428 CONSOLE("Error: " << e.what());
429 return;
430 }
431
432 runTimer_.stop();
433
434 // cache the error messages because we reset the loggers
435 errorMessages_ = structuredLogger_->messages();
436
437 CONSOLE("run time: " << runTimer_.format(default_places, "%w") << " sec");
438 CONSOLE("ORE done.");
439 LOG("ORE done.");
440}
boost::timer::cpu_timer runTimer_
Definition: oreapp.hpp:110
std::vector< std::string > errorMessages_
Definition: oreapp.hpp:125
virtual void analytics()
Definition: oreapp.cpp:218
QuantLib::ext::shared_ptr< StructuredLogger > structuredLogger_
Definition: oreapp.hpp:109
#define LOG(text)
#define ALOG(text)
#define CONSOLE(text)
+ Here is the call graph for this function:

◆ run() [2/2]

void run ( const std::vector< std::string > &  marketData,
const std::vector< std::string > &  fixingData 
)

Runs analytics and generates reports after using the second OREApp c'tor.

Definition at line 442 of file oreapp.cpp.

443 {
444
445 // Only one thread at a time should call run
446 static std::mutex _s_mutex;
447 std::lock_guard<std::mutex> lock(_s_mutex);
448
449 // Clean start, but leave Singletons intact after run is completed
450 {
451 CleanUpThreadLocalSingletons cleanupThreadLocalSingletons;
452 CleanUpThreadGlobalSingletons cleanupThreadGloablSingletons;
453 CleanUpLogSingleton cleanupLogSingleton(true, true);
454 }
455
456 // Use inputs when available, otherwise try params
457 if (inputs_ != nullptr)
459 else if (params_ != nullptr)
461 else {
462 ALOG("both inputs are empty");
463 return;
464 }
465
466 runTimer_.start();
467
468 try {
469 LOG("ORE analytics starting");
470 structuredLogger_->clear();
471 MEM_LOG_USING_LEVEL(ORE_WARNING)
472
473 QL_REQUIRE(inputs_, "ORE input parameters not set");
474
475 // Set global evaluation date, though already set in the OREAppInputParameters c'tor
476 Settings::instance().evaluationDate() = inputs_->asof();
477
478 // FIXME
479 QL_REQUIRE(inputs_->pricingEngine(), "pricingEngine not set");
480 GlobalPseudoCurrencyMarketParameters::instance().set(inputs_->pricingEngine()->globalParameters());
481
482 // Initialize the global conventions
483 QL_REQUIRE(inputs_->conventions(), "conventions not set");
484 InstrumentConventions::instance().setConventions(inputs_->conventions());
485
486 // Create a market data loader that takes input from the provided vectors
487 auto loader = QuantLib::ext::make_shared<MarketDataInMemoryLoader>(inputs_, marketData, fixingData);
488
489 // Create the analytics manager
490 analyticsManager_ = QuantLib::ext::make_shared<AnalyticsManager>(inputs_, loader);
491 LOG("Available analytics: " << to_string(analyticsManager_->validAnalytics()));
492 CONSOLEW("Requested analytics:");
493 CONSOLE(to_string(inputs_->analytics()));
494 LOG("Requested analytics: " << to_string(inputs_->analytics()));
495
496 QuantLib::ext::shared_ptr<MarketCalibrationReportBase> mcr;
497 if (inputs_->outputTodaysMarketCalibration()) {
498 auto marketCalibrationReport = QuantLib::ext::make_shared<ore::data::InMemoryReport>();
499 mcr = QuantLib::ext::make_shared<MarketCalibrationReport>(string(), marketCalibrationReport);
500 }
501
502 // Run the requested analytics
503 analyticsManager_->runAnalytics(mcr);
504
505 MEM_LOG_USING_LEVEL(ORE_WARNING)
506 // Leave any report writing to the calling aplication
507 }
508 catch (std::exception& e) {
509 ostringstream oss;
510 oss << "Error in ORE analytics: " << e.what();
511 StructuredAnalyticsWarningMessage("OREApp::run()", oss.str(), e.what()).log();
512 MEM_LOG_USING_LEVEL(ORE_WARNING)
513 CONSOLE(oss.str());
514 QL_FAIL(oss.str());
515 return;
516 }
517
518 runTimer_.stop();
519
520 LOG("ORE analytics done");
521}
QuantLib::ext::shared_ptr< AnalyticsManager > analyticsManager_
Definition: oreapp.hpp:108
#define MEM_LOG_USING_LEVEL(LEVEL)
#define CONSOLEW(text)
std::string to_string(const LocationInfo &l)
+ Here is the call graph for this function:

◆ getInputs()

QuantLib::ext::shared_ptr< InputParameters > getInputs ( )

Definition at line 63 of file oreapp.hpp.

63{ return inputs_; }

◆ getAnalyticTypes()

std::set< std::string > getAnalyticTypes ( )

Definition at line 64 of file oreapp.cpp.

64 {
65 QL_REQUIRE(analyticsManager_, "analyticsManager_ not set yet, call analytics first");
66 return analyticsManager_->requestedAnalytics();
67}

◆ getSupportedAnalyticTypes()

std::set< std::string > getSupportedAnalyticTypes ( )

Definition at line 69 of file oreapp.cpp.

69 {
70 QL_REQUIRE(analyticsManager_, "analyticsManager_ not set yet, call analytics first");
71 return analyticsManager_->validAnalytics();
72}

◆ getAnalytic()

const QuantLib::ext::shared_ptr< Analytic > & getAnalytic ( std::string  type)

Definition at line 74 of file oreapp.cpp.

74 {
75 QL_REQUIRE(analyticsManager_, "analyticsManager_ not set yet, call analytics first");
76 return analyticsManager_->getAnalytic(type);
77}

◆ getReportNames()

std::set< std::string > getReportNames ( )

Definition at line 79 of file oreapp.cpp.

79 {
80 QL_REQUIRE(analyticsManager_, "analyticsManager_ not set yet, call analytics first");
81 std::set<std::string> names;
82 for (const auto& rep : analyticsManager_->reports()) {
83 for (auto b : rep.second) {
84 string reportName = b.first;
85 if (names.find(reportName) == names.end())
86 names.insert(reportName);
87 else {
88 ALOG("report name " << reportName
89 << " occurs more than once, will retrieve the first report with that only");
90 }
91 }
92 }
93 return names;
94}

◆ getReport()

QuantLib::ext::shared_ptr< PlainInMemoryReport > getReport ( std::string  reportName)

Definition at line 96 of file oreapp.cpp.

96 {
97 QL_REQUIRE(analyticsManager_, "analyticsManager_ not set yet, call analytics first");
98 for (const auto& rep : analyticsManager_->reports()) {
99 for (auto b : rep.second) {
100 if (reportName == b.first)
101 return QuantLib::ext::make_shared<PlainInMemoryReport>(b.second);
102 }
103 }
104 QL_FAIL("report " << reportName << " not found in results");
105}

◆ getCubeNames()

std::set< std::string > getCubeNames ( )

Definition at line 107 of file oreapp.cpp.

107 {
108 QL_REQUIRE(analyticsManager_, "analyticsManager_ not set yet, call analytics first");
109 std::set<std::string> names;
110 for (const auto& c : analyticsManager_->npvCubes()) {
111 for (auto b : c.second) {
112 string cubeName = b.first;
113 if (names.find(cubeName) == names.end())
114 names.insert(cubeName);
115 else {
116 ALOG("cube name " << cubeName
117 << " occurs more than once, will retrieve the first cube with that name only");
118 }
119 }
120 }
121 return names;
122}

◆ getCube()

QuantLib::ext::shared_ptr< NPVCube > getCube ( std::string  cubeName)

Definition at line 124 of file oreapp.cpp.

124 {
125 QL_REQUIRE(analyticsManager_, "analyticsManager_ not set yet, call analytics first");
126 for (const auto& c : analyticsManager_->npvCubes()) {
127 for (auto b : c.second) {
128 if (cubeName == b.first)
129 return b.second;
130 }
131 }
132 QL_FAIL("npv cube " << cubeName << " not found in results");
133}

◆ getMarketCubeNames()

std::set< std::string > getMarketCubeNames ( )

Definition at line 135 of file oreapp.cpp.

135 {
136 QL_REQUIRE(analyticsManager_, "analyticsManager_ not set yet, call analytics first");
137 std::set<std::string> names;
138 for (const auto& c : analyticsManager_->mktCubes()) {
139 for (auto b : c.second) {
140 string cubeName = b.first;
141 if (names.find(cubeName) == names.end())
142 names.insert(cubeName);
143 else {
144 ALOG("market cube name " << cubeName
145 << " occurs more than once, will retrieve the first cube with that name only");
146 }
147 }
148 }
149 return names;
150}

◆ getMarketCube()

QuantLib::ext::shared_ptr< AggregationScenarioData > getMarketCube ( std::string  cubeName)

Definition at line 152 of file oreapp.cpp.

152 {
153 QL_REQUIRE(analyticsManager_, "analyticsManager_ not set yet, call analytics first");
154 for (const auto& c : analyticsManager_->mktCubes()) {
155 for (auto b : c.second) {
156 if (cubeName == b.first)
157 return b.second;
158 }
159 }
160 QL_FAIL("market cube " << cubeName << " not found in results");
161}

◆ getErrors()

std::vector< std::string > getErrors ( )

Definition at line 163 of file oreapp.cpp.

163 {
164 return errorMessages_;
165}

◆ getRunTime()

Real getRunTime ( )

time for executing run(...) in seconds

Definition at line 167 of file oreapp.cpp.

167 {
168 boost::chrono::duration<double> seconds = boost::chrono::nanoseconds(runTimer_.elapsed().wall);
169 return seconds.count();
170}

◆ version()

std::string version ( )

Definition at line 564 of file oreapp.cpp.

564{ return std::string(OPEN_SOURCE_RISK_VERSION); }

◆ analytics()

void analytics ( )
protectedvirtual

Definition at line 218 of file oreapp.cpp.

218 {
219
220 try {
221 LOG("ORE analytics starting");
222 MEM_LOG_USING_LEVEL(ORE_WARNING)
223
224 QL_REQUIRE(params_, "ORE input parameters not set");
225
226 Settings::instance().evaluationDate() = inputs_->asof();
227
228 GlobalPseudoCurrencyMarketParameters::instance().set(inputs_->pricingEngine()->globalParameters());
229
230 // Initialize the global conventions
231 InstrumentConventions::instance().setConventions(inputs_->conventions());
232
233 // Create a market data loader that reads market data, fixings, dividends from csv files
234 auto csvLoader = buildCsvLoader(params_);
235 auto loader = QuantLib::ext::make_shared<MarketDataCsvLoader>(inputs_, csvLoader);
236
237 // Create the analytics manager
238 analyticsManager_ = QuantLib::ext::make_shared<AnalyticsManager>(inputs_, loader);
239 LOG("Available analytics: " << to_string(analyticsManager_->validAnalytics()));
240 CONSOLEW("Requested analytics");
241 CONSOLE(to_string(inputs_->analytics()));
242 LOG("Requested analytics: " << to_string(inputs_->analytics()));
243
244 QuantLib::ext::shared_ptr<MarketCalibrationReportBase> mcr;
245 if (inputs_->outputTodaysMarketCalibration()) {
246 auto marketCalibrationReport = QuantLib::ext::make_shared<ore::data::InMemoryReport>();
247 mcr = QuantLib::ext::make_shared<MarketCalibrationReport>(string(), marketCalibrationReport);
248 }
249
250 // Run the requested analytics
251 analyticsManager_->runAnalytics(mcr);
252
253 // Write reports to files in the results path
255 analyticsManager_->toFile(reports,
256 inputs_->resultsPath().string(), outputs_->fileNameMap(),
257 inputs_->csvSeparator(), inputs_->csvCommentCharacter(),
258 inputs_->csvQuoteChar(), inputs_->reportNaString());
259
260 // Write npv cube(s)
261 for (auto a : analyticsManager_->npvCubes()) {
262 for (auto b : a.second) {
263 LOG("write npv cube " << b.first);
264 string reportName = b.first;
265 std::string fileName = inputs_->resultsPath().string() + "/" + outputs_->outputFileName(reportName, "csv.gz");
266 LOG("write npv cube " << reportName << " to file " << fileName);
268 r.cube = b.second;
269 if (b.first == "cube") {
270 // store meta data together with npv cube
271 r.scenarioGeneratorData = inputs_->scenarioGeneratorData();
272 r.storeFlows = inputs_->storeFlows();
273 r.storeCreditStateNPVs = inputs_->storeCreditStateNPVs();
274 }
275 saveCube(fileName, r);
276 }
277 }
278
279 // Write market cube(s)
280 for (auto a : analyticsManager_->mktCubes()) {
281 for (auto b : a.second) {
282 string reportName = b.first;
283 std::string fileName = inputs_->resultsPath().string() + "/" + outputs_->outputFileName(reportName, "csv.gz");
284 LOG("write market cube " << reportName << " to file " << fileName);
285 saveAggregationScenarioData(fileName, *b.second);
286 }
287 }
288
289 for (auto a: analyticsManager_->stressTests()){
290 for(auto b: a.second){
291 string reportName = b.first;
292 std::string fileName =
293 inputs_->resultsPath().string() + "/" + outputs_->outputFileName(reportName, "xml");
294 LOG("write converted stress test scenario definition " << reportName << " to file " << fileName);
295 b.second->toFile(fileName);
296 }
297 }
298
299 }
300 catch (std::exception& e) {
301 ostringstream oss;
302 oss << "Error in ORE analytics: " << e.what();
303 ALOG(oss.str());
304 MEM_LOG_USING_LEVEL(ORE_WARNING)
305 CONSOLE(oss.str());
306 QL_FAIL(oss.str());
307 }
308
309 MEM_LOG_USING_LEVEL(ORE_WARNING)
310 LOG("ORE analytics done");
311}
std::map< std::string, std::map< std::string, QuantLib::ext::shared_ptr< ore::data::InMemoryReport > > > analytic_reports
Definition: analytic.hpp:51
QuantLib::ext::shared_ptr< OutputParameters > outputs_
Definition: oreapp.hpp:106
QuantLib::ext::shared_ptr< CSVLoader > buildCsvLoader(const QuantLib::ext::shared_ptr< Parameters > &params)
Definition: oreapp.cpp:172
void saveCube(const std::string &filename, const NPVCubeWithMetaData &cube, const bool doublePrecision)
Definition: cube_io.cpp:167
void saveAggregationScenarioData(const std::string &filename, const AggregationScenarioData &cube)
Definition: cube_io.cpp:302
QuantLib::ext::shared_ptr< NPVCube > cube
Definition: cube_io.hpp:39
QuantLib::ext::shared_ptr< ScenarioGeneratorData > scenarioGeneratorData
Definition: cube_io.hpp:41
boost::optional< Size > storeCreditStateNPVs
Definition: cube_io.hpp:43
boost::optional< bool > storeFlows
Definition: cube_io.hpp:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildInputParameters()

void buildInputParameters ( QuantLib::ext::shared_ptr< InputParameters inputs,
const QuantLib::ext::shared_ptr< Parameters > &  params 
)
protected

Populate InputParameters object from classic ORE key-value pairs in Parameters.

◆ buildCsvLoader()

QuantLib::ext::shared_ptr< CSVLoader > buildCsvLoader ( const QuantLib::ext::shared_ptr< Parameters > &  params)
protected

Definition at line 172 of file oreapp.cpp.

172 {
173 bool implyTodaysFixings = false;
174 vector<string> marketFiles = {};
175 vector<string> fixingFiles = {};
176 vector<string> dividendFiles = {};
177
178 filesystem::path inputPath = params_->get("setup", "inputPath");
179
180 std::string tmp = params_->get("setup", "implyTodaysFixings", false);
181 if (tmp != "")
182 implyTodaysFixings = ore::data::parseBool(tmp);
183
184 tmp = params->get("setup", "marketDataFile", false);
185 if (tmp != "")
186 marketFiles = getFileNames(tmp, inputPath);
187 else {
188 ALOG("market data file not found");
189 }
190
191 tmp = params->get("setup", "fixingDataFile", false);
192 if (tmp != "")
193 fixingFiles = getFileNames(tmp, inputPath);
194 else {
195 ALOG("fixing data file not found");
196 }
197
198 tmp = params->get("setup", "dividendDataFile", false);
199 if (tmp != "")
200 dividendFiles = getFileNames(tmp, inputPath);
201 else {
202 WLOG("dividend data file not found");
203 }
204
205 tmp = params->get("setup", "fixingCutoff", false);
206 Date cutoff = Date();
207 if (tmp != "")
208 cutoff = parseDate(tmp);
209 else {
210 WLOG("fixing cutoff date not set");
211 }
212
213 auto loader = boost::make_shared<CSVLoader>(marketFiles, fixingFiles, dividendFiles, implyTodaysFixings, cutoff);
214
215 return loader;
216}
Date parseDate(const string &s)
bool parseBool(const string &s)
#define WLOG(text)
vector< string > getFileNames(const string &fileString, const std::filesystem::path &path)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setupLog()

void setupLog ( const std::string &  path,
const std::string &  file,
QuantLib::Size  mask,
const boost::filesystem::path &  logRootPath,
const std::string &  progressLogFile = "",
QuantLib::Size  progressLogRotationSize = 100 * 1024 * 1024,
bool  progressLogToConsole = false,
const std::string &  structuredLogFile = "",
QuantLib::Size  structuredLogRotationSize = 100 * 1024 * 1024 
)
protected

set up logging

Definition at line 523 of file oreapp.cpp.

526 {
527 closeLog();
528
529 boost::filesystem::path p{path};
530 if (!boost::filesystem::exists(p)) {
531 boost::filesystem::create_directories(p);
532 }
533 QL_REQUIRE(boost::filesystem::is_directory(p), "output path '" << path << "' is not a directory.");
534
535 Log::instance().registerLogger(QuantLib::ext::make_shared<FileLogger>(file));
536 boost::filesystem::path oreRootPath =
537 logRootPath.empty() ? boost::filesystem::path(__FILE__).parent_path().parent_path().parent_path().parent_path()
538 : logRootPath;
539 Log::instance().setRootPath(oreRootPath);
540 Log::instance().setMask(mask);
541 Log::instance().switchOn();
542
543 // Progress logger
544 auto progressLogger = QuantLib::ext::make_shared<ProgressLogger>();
545 string progressLogFilePath = progressLogFile.empty() ? path + "/log_progress.json" : progressLogFile;
546 progressLogger->setFileLog(progressLogFilePath, path, progressLogRotationSize);
547 progressLogger->setCoutLog(progressLogToConsole);
548 Log::instance().registerIndependentLogger(progressLogger);
549
550 // Structured message logger
551 structuredLogger_ = QuantLib::ext::make_shared<StructuredLogger>();
552 string structuredLogFilePath = structuredLogFile.empty() ? path + "/log_structured.json" : structuredLogFile;
553 structuredLogger_->setFileLog(structuredLogFilePath, path, structuredLogRotationSize);
554 Log::instance().registerIndependentLogger(structuredLogger_);
555
556 // Event message logger
557 auto eventLogger = QuantLib::ext::make_shared<EventLogger>();
558 eventLogger->setFileLog(path + "/log_event_");
559 ore::data::Log::instance().registerIndependentLogger(eventLogger);
560}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ closeLog()

void closeLog ( )
protected

remove logs

Definition at line 562 of file oreapp.cpp.

562{ Log::instance().removeAllLoggers(); }
+ Here is the caller graph for this function:

◆ initFromParams()

void initFromParams ( )
protected

Definition at line 314 of file oreapp.cpp.

314 {
315 if (console_) {
316 ConsoleLog::instance().switchOn();
317 }
318
319 outputPath_ = params_->get("setup", "outputPath");
320 logFile_ = outputPath_ + "/" + params_->get("setup", "logFile");
321 logMask_ = 15;
322 // Get log mask if available
323 if (params_->has("setup", "logMask")) {
324 logMask_ = static_cast<Size>(parseInteger(params_->get("setup", "logMask")));
325 }
326
328 progressLogToConsole_ = false;
330
331 if (params_->hasGroup("logging")) {
332 string tmp = params_->get("logging", "logFile", false);
333 if (!tmp.empty()) {
334 logFile_ = outputPath_ + '/' + tmp;
335 }
336 tmp = params_->get("logging", "logMask", false);
337 if (!tmp.empty()) {
338 logMask_ = static_cast<Size>(parseInteger(tmp));
339 }
340 tmp = params_->get("logging", "progressLogFile", false);
341 if (!tmp.empty()) {
342 progressLogFile_ = outputPath_ + '/' + tmp;
343 }
344 tmp = params_->get("logging", "progressLogRotationSize", false);
345 if (!tmp.empty()) {
346 progressLogRotationSize_ = static_cast<Size>(parseInteger(tmp));
347 }
348 tmp = params_->get("logging", "progressLogToConsole", false);
349 if (!tmp.empty()) {
351 }
352 tmp = params_->get("logging", "structuredLogFile", false);
353 if (!tmp.empty()) {
354 structuredLogFile_ = outputPath_ + '/' + tmp;
355 }
356 tmp = params_->get("logging", "structuredLogRotationSize", false);
357 if (!tmp.empty()) {
358 structuredLogRotationSize_ = static_cast<Size>(parseInteger(tmp));
359 }
360 }
361
364
365 // Log the input parameters
366 params_->log();
367
368 // Read all inputs from params and files referenced in params
369 CONSOLEW("Loading inputs");
370 inputs_ = QuantLib::ext::make_shared<OREAppInputParameters>(params_);
371 inputs_->loadParameters();
372 outputs_ = QuantLib::ext::make_shared<OutputParameters>(params_);
373 CONSOLE("OK");
374
375 Settings::instance().evaluationDate() = inputs_->asof();
376 LOG("initFromParameters done, requested analytics:" << to_string(inputs_->analytics()));
377}
QuantLib::Size structuredLogRotationSize_
Definition: oreapp.hpp:122
void setupLog(const std::string &path, const std::string &file, QuantLib::Size mask, const boost::filesystem::path &logRootPath, const std::string &progressLogFile="", QuantLib::Size progressLogRotationSize=100 *1024 *1024, bool progressLogToConsole=false, const std::string &structuredLogFile="", QuantLib::Size structuredLogRotationSize=100 *1024 *1024)
set up logging
Definition: oreapp.cpp:523
QuantLib::Size progressLogRotationSize_
Definition: oreapp.hpp:119
Integer parseInteger(const string &s)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initFromInputs()

void initFromInputs ( )
protected

Definition at line 379 of file oreapp.cpp.

379 {
380 // Initialise Singletons
381 Settings::instance().evaluationDate() = inputs_->asof();
382 InstrumentConventions::instance().setConventions(inputs_->conventions());
383 if (console_) {
384 ConsoleLog::instance().switchOn();
385 }
386
387 outputPath_ = inputs_->resultsPath().string();
390 LOG("initFromInputs done, requested analytics:" << to_string(inputs_->analytics()));
391}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ params_

QuantLib::ext::shared_ptr<Parameters> params_
protected

ORE Input parameters.

Definition at line 104 of file oreapp.hpp.

◆ inputs_

QuantLib::ext::shared_ptr<InputParameters> inputs_
protected

Definition at line 105 of file oreapp.hpp.

◆ outputs_

QuantLib::ext::shared_ptr<OutputParameters> outputs_
protected

Definition at line 106 of file oreapp.hpp.

◆ analyticsManager_

QuantLib::ext::shared_ptr<AnalyticsManager> analyticsManager_
protected

Definition at line 108 of file oreapp.hpp.

◆ structuredLogger_

QuantLib::ext::shared_ptr<StructuredLogger> structuredLogger_
protected

Definition at line 109 of file oreapp.hpp.

◆ runTimer_

boost::timer::cpu_timer runTimer_
protected

Definition at line 110 of file oreapp.hpp.

◆ logFile_

string logFile_
protected

Logging.

Definition at line 113 of file oreapp.hpp.

◆ logMask_

Size logMask_
protected

Definition at line 114 of file oreapp.hpp.

◆ console_

bool console_
protected

Definition at line 115 of file oreapp.hpp.

◆ outputPath_

string outputPath_
protected

Definition at line 116 of file oreapp.hpp.

◆ logRootPath_

boost::filesystem::path logRootPath_
protected

Definition at line 117 of file oreapp.hpp.

◆ progressLogFile_

string progressLogFile_ = ""
protected

Definition at line 118 of file oreapp.hpp.

◆ progressLogRotationSize_

QuantLib::Size progressLogRotationSize_ = 100 * 1024 * 1024
protected

Definition at line 119 of file oreapp.hpp.

◆ progressLogToConsole_

bool progressLogToConsole_ = false
protected

Definition at line 120 of file oreapp.hpp.

◆ structuredLogFile_

string structuredLogFile_ = ""
protected

Definition at line 121 of file oreapp.hpp.

◆ structuredLogRotationSize_

QuantLib::Size structuredLogRotationSize_ = 100 * 1024 * 1024
protected

Definition at line 122 of file oreapp.hpp.

◆ errorMessages_

std::vector<std::string> errorMessages_
protected

Definition at line 125 of file oreapp.hpp.