Skip to content

Commit ef43d34

Browse files
author
jenkins
committed
git subrepo pull (merge) ore
subrepo: subdir: "ore" merged: "f5654d211c" upstream: origin: "git@gitlab.acadiasoft.net:qs/ore.git" branch: "master" commit: "9389a1b8ce" git-subrepo: version: "0.4.6" origin: "https://github.com/ingydotnet/git-subrepo" commit: "110b9eb"
2 parents 0e54392 + 9389a1b commit ef43d34

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

OREData/ored/utilities/log.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,18 @@ StructuredLogger::StructuredLogger() : IndependentLogger(name) {
197197
std::find(this->messages().begin(), this->messages().end(), msg) == this->messages().end()) {
198198
// Store the message
199199
this->messages().push_back(msg);
200-
200+
201+
oreSeverity logSeverity = boost::log::extract<oreSeverity>(severity.get_name(), rec).get();
201202
// If a file sink has been defined, then send the log record to it.
202203
if (this->fileSink()) {
203204
// Send to structured log file
204205
lsrc::severity_logger_mt<oreSeverity> lg;
205206
lg.add_attribute(messageType.get_name(), lattr::constant<string>(name));
206-
BOOST_LOG_SEV(lg, oreSeverity::warning) << rec[lexpr::smessage];
207+
BOOST_LOG_SEV(lg, logSeverity) << rec[lexpr::smessage];
207208
}
208209

209210
// Also send to full log file
210-
MLOG(oreSeverity::warning, StructuredMessage::name << " " << rec[lexpr::smessage]);
211+
MLOG(logSeverity, StructuredMessage::name << " " << rec[lexpr::smessage]);
211212
}
212213
};
213214
sink->set_formatter(formatter);
@@ -562,7 +563,19 @@ StructuredMessage::StructuredMessage(const Category& category, const Group& grou
562563
void StructuredMessage::log() const {
563564
lsrc::severity_logger_mt<oreSeverity> lg;
564565
lg.add_attribute(messageType.get_name(), lattr::constant<string>(name));
565-
BOOST_LOG_SEV(lg, oreSeverity::alert) << json();
566+
567+
auto it = data_.find("category");
568+
QL_REQUIRE(it != data_.end(), "StructuredMessage must have a 'category' key specified.");
569+
QL_REQUIRE(it->second.type() == typeid(string), "StructuredMessage category must be a string.");
570+
571+
string category = boost::any_cast<string>(it->second);
572+
if (category == to_string(StructuredMessage::Category::Unknown) || category == to_string(StructuredMessage::Category::Warning)) {
573+
BOOST_LOG_SEV(lg, oreSeverity::warning) << json();
574+
} else if (category == to_string(StructuredMessage::Category::Error)) {
575+
BOOST_LOG_SEV(lg, oreSeverity::alert) << json();
576+
} else {
577+
QL_FAIL("StructuredMessage::log() invalid category '" << category << "'");
578+
}
566579
}
567580

568581
void StructuredMessage::addSubFields(const map<string, string>& subFields) {

0 commit comments

Comments
 (0)