Skip to content

Commit 0946277

Browse files
pcaspersjenkins
authored andcommitted
QPR-12135 clean up structured logging in OREApp
1 parent d008830 commit 0946277

6 files changed

Lines changed: 7 additions & 125 deletions

File tree

OREAnalytics/orea/app/oreapp.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,7 @@ boost::shared_ptr<AggregationScenarioData> OREApp::getMarketCube(std::string cub
156156
}
157157

158158
std::vector<std::string> OREApp::getErrors() {
159-
std::vector<std::string> errors;
160-
while (fbLogger_ && fbLogger_->logger->hasNext())
161-
errors.push_back(fbLogger_->logger->next());
162-
return errors;
159+
return structuredLogger_->messages();
163160
}
164161

165162
Real OREApp::getRunTime() {
@@ -383,6 +380,7 @@ void OREApp::run() {
383380
runTimer_.start();
384381

385382
try {
383+
structuredLogger_->clear();
386384
analytics();
387385
} catch (std::exception& e) {
388386
StructuredAnalyticsWarningMessage("OREApp::run()", "Error", e.what()).log();
@@ -403,6 +401,7 @@ void OREApp::run(const std::vector<std::string>& marketData,
403401

404402
try {
405403
LOG("ORE analytics starting");
404+
structuredLogger_->clear();
406405
MEM_LOG_USING_LEVEL(ORE_WARNING)
407406

408407
QL_REQUIRE(inputs_, "ORE input parameters not set");
@@ -1411,8 +1410,6 @@ void OREApp::setupLog(const std::string& path, const std::string& file, Size mas
14111410
QL_REQUIRE(boost::filesystem::is_directory(p), "output path '" << path << "' is not a directory.");
14121411

14131412
Log::instance().registerLogger(boost::make_shared<FileLogger>(file));
1414-
// Report StructuredErrorMessages with level WARNING, ERROR, CRITICAL, ALERT
1415-
fbLogger_ = boost::make_shared<FilteredBufferedLoggerGuard>();
14161413
boost::filesystem::path oreRootPath =
14171414
logRootPath.empty() ? boost::filesystem::path(__FILE__).parent_path().parent_path().parent_path().parent_path()
14181415
: logRootPath;
@@ -1428,10 +1425,10 @@ void OREApp::setupLog(const std::string& path, const std::string& file, Size mas
14281425
Log::instance().registerIndependentLogger(progressLogger);
14291426

14301427
// Structured message logger
1431-
auto structuredLogger = boost::make_shared<StructuredLogger>();
1428+
structuredLogger_ = boost::make_shared<StructuredLogger>();
14321429
string structuredLogFilePath = structuredLogFile.empty() ? path + "/log_structured.json" : structuredLogFile;
1433-
structuredLogger->setFileLog(structuredLogFilePath, path, structuredLogRotationSize);
1434-
Log::instance().registerIndependentLogger(structuredLogger);
1430+
structuredLogger_->setFileLog(structuredLogFilePath, path, structuredLogRotationSize);
1431+
Log::instance().registerIndependentLogger(structuredLogger_);
14351432

14361433
// Event message logger
14371434
auto eventLogger = boost::make_shared<EventLogger>();

OREAnalytics/orea/app/oreapp.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
#include <orea/app/parameters.hpp>
2828
#include <orea/app/analyticsmanager.hpp>
2929

30-
#include <ored/utilities/filteredbufferedlogger.hpp>
31-
3230
#include <boost/make_shared.hpp>
3331
#include <boost/timer/timer.hpp>
3432

@@ -102,7 +100,7 @@ class OREApp {
102100
boost::shared_ptr<OutputParameters> outputs_;
103101

104102
boost::shared_ptr<AnalyticsManager> analyticsManager_;
105-
boost::shared_ptr<FilteredBufferedLoggerGuard> fbLogger_;
103+
boost::shared_ptr<StructuredLogger> structuredLogger_;
106104
boost::timer::cpu_timer runTimer_;
107105
};
108106

OREData/ored/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,6 @@ utilities/currencyhedgedequityindexdecomposition.cpp
337337
utilities/currencyparser.cpp
338338
utilities/dategrid.cpp
339339
utilities/fileio.cpp
340-
utilities/filteredbufferedlogger.cpp
341340
utilities/flowanalysis.cpp
342341
utilities/indexnametranslator.cpp
343342
utilities/indexparser.cpp
@@ -721,7 +720,6 @@ utilities/currencyhedgedequityindexdecomposition.hpp
721720
utilities/currencyparser.hpp
722721
utilities/dategrid.hpp
723722
utilities/fileio.hpp
724-
utilities/filteredbufferedlogger.hpp
725723
utilities/flowanalysis.hpp
726724
utilities/indexnametranslator.hpp
727725
utilities/indexparser.hpp

OREData/ored/ored.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@
369369
#include <ored/utilities/currencyparser.hpp>
370370
#include <ored/utilities/dategrid.hpp>
371371
#include <ored/utilities/fileio.hpp>
372-
#include <ored/utilities/filteredbufferedlogger.hpp>
373372
#include <ored/utilities/flowanalysis.hpp>
374373
#include <ored/utilities/indexnametranslator.hpp>
375374
#include <ored/utilities/indexparser.hpp>

OREData/ored/utilities/filteredbufferedlogger.cpp

Lines changed: 0 additions & 54 deletions
This file was deleted.

OREData/ored/utilities/filteredbufferedlogger.hpp

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)