Log#Log(): require passing one involved object

This commit is contained in:
Alexander A. Klimov 2023-08-11 13:32:14 +02:00
parent 481ef9ea72
commit 6b642b270e
2 changed files with 6 additions and 3 deletions

View File

@ -345,8 +345,9 @@ void Logger::UpdateCheckObjectFilterCache()
m_ObjectFilterCache.swap(allObjects); m_ObjectFilterCache.swap(allObjects);
} }
Log::Log(LogSeverity severity, String facility, const String& message) Log::Log(LogSeverity severity, String facility, const ConfigObject::Ptr& involved, const String& message)
: m_Severity(severity), m_Facility(std::move(facility)), m_IsNoOp(severity < Logger::GetMinLogSeverity()) : m_Severity(severity), m_Facility(std::move(facility)),
m_Involved(involved), m_IsNoOp(severity < Logger::GetMinLogSeverity())
{ {
if (!m_IsNoOp && !message.IsEmpty()) { if (!m_IsNoOp && !message.IsEmpty()) {
m_Buffer << message; m_Buffer << message;

View File

@ -5,6 +5,7 @@
#include "base/atomic.hpp" #include "base/atomic.hpp"
#include "base/i2-base.hpp" #include "base/i2-base.hpp"
#include "base/configobject.hpp"
#include "base/logger-ti.hpp" #include "base/logger-ti.hpp"
#include <set> #include <set>
#include <sstream> #include <sstream>
@ -122,7 +123,7 @@ public:
Log(const Log& other) = delete; Log(const Log& other) = delete;
Log& operator=(const Log& rhs) = delete; Log& operator=(const Log& rhs) = delete;
Log(LogSeverity severity, String facility, const String& message = String()); Log(LogSeverity severity, String facility, const ConfigObject::Ptr& involved, const String& message = String());
~Log(); ~Log();
template<typename T> template<typename T>
@ -140,6 +141,7 @@ public:
private: private:
LogSeverity m_Severity; LogSeverity m_Severity;
String m_Facility; String m_Facility;
ConfigObject::Ptr m_Involved;
std::ostringstream m_Buffer; std::ostringstream m_Buffer;
bool m_IsNoOp; bool m_IsNoOp;
}; };