Skip to content

Commit 845fe39

Browse files
pcaspersjenkins
authored andcommitted
74 into master
1 parent 3b9d050 commit 845fe39

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

OREData/ored/utilities/log.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,11 @@ LoggerStream::~LoggerStream() {
482482
}
483483
}
484484

485+
void JSONMessage::log() const {
486+
if (!ore::data::Log::instance().checkExcludeFilters(msg()))
487+
emitLog();
488+
}
489+
485490
string JSONMessage::jsonify(const boost::any& obj) {
486491
if (obj.type() == typeid(map<string, boost::any>)) {
487492
string jsonStr = "{ ";
@@ -562,7 +567,7 @@ StructuredMessage::StructuredMessage(const Category& category, const Group& grou
562567
}
563568
}
564569

565-
void StructuredMessage::log() const {
570+
void StructuredMessage::emitLog() const {
566571
lsrc::severity_logger_mt<oreSeverity> lg;
567572
lg.add_attribute(messageType.get_name(), lattr::constant<string>(name));
568573

@@ -608,7 +613,7 @@ void StructuredMessage::addSubFields(const map<string, string>& subFields) {
608613
}
609614
}
610615

611-
void EventMessage::log() const {
616+
void EventMessage::emitLog() const {
612617
lsrc::severity_logger_mt<oreSeverity> lg;
613618
lg.add_attribute(messageType.get_name(), lattr::constant<string>(name));
614619
BOOST_LOG_SEV(lg, oreSeverity::alert) << json();
@@ -623,7 +628,7 @@ ProgressMessage::ProgressMessage(const string& key, const Size progressCurrent,
623628
boost::posix_time::to_iso_extended_string(boost::posix_time::microsec_clock::universal_time());
624629
}
625630

626-
void ProgressMessage::log() const {
631+
void ProgressMessage::emitLog() const {
627632
lsrc::severity_logger_mt<oreSeverity> lg;
628633
lg.add_attribute(messageType.get_name(), lattr::constant<string>(name));
629634
BOOST_LOG_SEV(lg, oreSeverity::notice) << json();

OREData/ored/utilities/log.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -637,12 +637,14 @@ class JSONMessage {
637637
//! return a std::string for the log file
638638
virtual std::string msg() const = 0;
639639
//! generate Boost log record to pass to corresponding sinks
640-
virtual void log() const = 0;
640+
void log() const;
641641
//! create JSON-like output from the data
642642
const std::string json() const { return jsonify(data_); }
643643
void set(const std::string& key, const boost::any& value) { data_[key] = value; }
644644

645645
protected:
646+
//! generate Boost log record - this method is called by log()
647+
virtual void emitLog() const = 0;
646648
static std::string jsonify(const boost::any&);
647649

648650
std::map<std::string, boost::any> data_;
@@ -691,7 +693,7 @@ class StructuredMessage : public JSONMessage {
691693
//! return a std::string for the log file
692694
std::string msg() const { return std::string(name) + std::string(" ") + json(); }
693695
//! generate Boost log record to pass to corresponding sinks
694-
void log() const;
696+
void emitLog() const;
695697

696698
protected:
697699
void addSubFields(const std::map<std::string, std::string>&);
@@ -720,7 +722,7 @@ class EventMessage : public JSONMessage {
720722
//! return a std::string for the log file
721723
std::string msg() const { return std::string(name) + std::string(" ") + json(); }
722724
//! generate Boost log record to pass to corresponding sinks
723-
void log() const;
725+
void emitLog() const;
724726

725727
private:
726728
std::string message_;
@@ -735,7 +737,7 @@ class ProgressMessage : public JSONMessage {
735737
//! return a std::string for the log file
736738
std::string msg() const { return std::string(name) + std::string(" ") + json(); }
737739
//! generate Boost log record to pass to corresponding sinks
738-
void log() const;
740+
void emitLog() const;
739741
};
740742

741743
//! Singleton to control console logging

0 commit comments

Comments
 (0)