You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by sw...@apache.org on 2023/07/21 00:02:17 UTC

[logging-log4cxx] branch master updated: Move the constructed log message to the logging event (#237)

This is an automated email from the ASF dual-hosted git repository.

swebb2066 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git


The following commit(s) were added to refs/heads/master by this push:
     new 23f6716b Move the constructed log message to the logging event (#237)
23f6716b is described below

commit 23f6716b194669c99135cfbe9f532858ef6692a8
Author: Stephen Webb <st...@ieee.org>
AuthorDate: Fri Jul 21 10:02:11 2023 +1000

    Move the constructed log message to the logging event (#237)
---
 src/main/cpp/logger.cpp                          |  77 +++++++---
 src/main/cpp/loggingevent.cpp                    |  32 ++++
 src/main/cpp/messagebuffer.cpp                   |  60 ++++++++
 src/main/include/log4cxx/helpers/messagebuffer.h |  74 ++++++++++
 src/main/include/log4cxx/logger.h                | 179 ++++++++++++++---------
 src/main/include/log4cxx/spi/loggingevent.h      |  22 ++-
 6 files changed, 354 insertions(+), 90 deletions(-)

diff --git a/src/main/cpp/logger.cpp b/src/main/cpp/logger.cpp
index 8c7d8ba5..3b94eaac 100644
--- a/src/main/cpp/logger.cpp
+++ b/src/main/cpp/logger.cpp
@@ -158,27 +158,46 @@ void Logger::closeNestedAppenders()
 	}
 }
 
+void Logger::addEvent(const LevelPtr& level, std::string&& message, const LocationInfo& location) const
+{
+	if (!getHierarchy()) // Has removeHierarchy() been called?
+		return;
+#if LOG4CXX_LOGCHAR_IS_UTF8
+	auto event = std::make_shared<LoggingEvent>(m_priv->name, level, location, std::move(message));
+#else
+	LOG4CXX_DECODE_CHAR(msg, message);
+	auto event = std::make_shared<LoggingEvent>(m_priv->name, level, location, std::move(msg));
+#endif
+	Pool p;
+	callAppenders(event, p);
+}
 
-void Logger::forcedLog(const LevelPtr& level1, const std::string& message,
+void Logger::forcedLog(const LevelPtr& level, const std::string& message,
 	const LocationInfo& location) const
 {
 	if (!getHierarchy()) // Has removeHierarchy() been called?
 		return;
-	Pool p;
+#if LOG4CXX_LOGCHAR_IS_UTF8
+	auto event = std::make_shared<LoggingEvent>(m_priv->name, level, message, location);
+#else
 	LOG4CXX_DECODE_CHAR(msg, message);
-	auto event = std::make_shared<LoggingEvent>(m_priv->name, level1, msg, location);
+	auto event = std::make_shared<LoggingEvent>(m_priv->name, level, location, std::move(msg));
+#endif
+	Pool p;
 	callAppenders(event, p);
 }
 
-
 void Logger::forcedLog(const LevelPtr& level1, const std::string& message) const
+{
+	forcedLog(level1, message, LocationInfo::getLocationUnavailable());
+}
+
+void Logger::addEventLS(const LevelPtr& level, LogString&& message, const LocationInfo& location) const
 {
 	if (!getHierarchy()) // Has removeHierarchy() been called?
 		return;
 	Pool p;
-	LOG4CXX_DECODE_CHAR(msg, message);
-	auto event = std::make_shared<LoggingEvent>(m_priv->name, level1, msg,
-			LocationInfo::getLocationUnavailable());
+	auto event = std::make_shared<LoggingEvent>(m_priv->name, level, location, std::move(message));
 	callAppenders(event, p);
 }
 
@@ -427,7 +446,7 @@ void Logger::l7dlog(const LevelPtr& level1, const LogString& key,
 			msg = StringHelper::format(pattern, params);
 		}
 
-		forcedLogLS(level1, msg, location);
+		addEventLS(level1, std::move(msg), location);
 	}
 }
 
@@ -702,28 +721,40 @@ LoggerPtr Logger::getLoggerLS(const LogString& name)
 
 
 #if LOG4CXX_WCHAR_T_API
-void Logger::forcedLog(const LevelPtr& level1, const std::wstring& message,
-	const LocationInfo& location) const
+void Logger::addEvent(const LevelPtr& level, std::wstring&& message, const LocationInfo& location) const
 {
 	if (!getHierarchy()) // Has removeHierarchy() been called?
 		return;
-	Pool p;
+#if LOG4CXX_LOGCHAR_IS_WCHAR
+	auto event = std::make_shared<LoggingEvent>(m_priv->name, level, location, std::move(message));
+#else
 	LOG4CXX_DECODE_WCHAR(msg, message);
-	auto event = std::make_shared<LoggingEvent>(m_priv->name, level1, msg, location);
+	auto event = std::make_shared<LoggingEvent>(m_priv->name, level, location, std::move(msg));
+#endif
+	Pool p;
 	callAppenders(event, p);
 }
 
-void Logger::forcedLog(const LevelPtr& level1, const std::wstring& message) const
+void Logger::forcedLog(const LevelPtr& level, const std::wstring& message,
+	const LocationInfo& location) const
 {
 	if (!getHierarchy()) // Has removeHierarchy() been called?
 		return;
-	Pool p;
+#if LOG4CXX_LOGCHAR_IS_WCHAR
+	auto event = std::make_shared<LoggingEvent>(m_priv->name, level, message, location);
+#else
 	LOG4CXX_DECODE_WCHAR(msg, message);
-	auto event = std::make_shared<LoggingEvent>(m_priv->name, level1, msg,
-			LocationInfo::getLocationUnavailable());
+	auto event = std::make_shared<LoggingEvent>(m_priv->name, level, location, std::move(msg));
+#endif
+	Pool p;
 	callAppenders(event, p);
 }
 
+void Logger::forcedLog(const LevelPtr& level1, const std::wstring& message) const
+{
+	forcedLog(level1, message, LocationInfo::getLocationUnavailable());
+}
+
 void Logger::getName(std::wstring& rv) const
 {
 	Transcoder::encode(m_priv->name, rv);
@@ -857,6 +888,16 @@ void Logger::warn(const std::wstring& msg) const
 
 
 #if LOG4CXX_UNICHAR_API || LOG4CXX_CFSTRING_API
+void Logger::addEvent(const LevelPtr& level1, std::basic_string<UniChar>&& message,	const LocationInfo& location) const
+{
+	if (!getHierarchy()) // Has removeHierarchy() been called?
+		return;
+	Pool p;
+	LOG4CXX_DECODE_UNICHAR(msg, message);
+	auto event = std::make_shared<LoggingEvent>(m_priv->name, level1, location, std::move(msg));
+	callAppenders(event, p);
+}
+
 void Logger::forcedLog(const LevelPtr& level1, const std::basic_string<UniChar>& message,
 	const LocationInfo& location) const
 {
@@ -864,7 +905,7 @@ void Logger::forcedLog(const LevelPtr& level1, const std::basic_string<UniChar>&
 		return;
 	Pool p;
 	LOG4CXX_DECODE_UNICHAR(msg, message);
-	auto event = std::make_shared<LoggingEvent>(m_priv->name, level1, msg, location);
+	auto event = std::make_shared<LoggingEvent>(m_priv->name, level1, location, std::move(msg));
 	callAppenders(event, p);
 }
 
@@ -1016,7 +1057,7 @@ void Logger::forcedLog(const LevelPtr& level1, const CFStringRef& message,
 		return;
 	Pool p;
 	LOG4CXX_DECODE_CFSTRING(msg, message);
-	auto event = std::make_shared<LoggingEvent>(name, level1, msg, location);
+	auto event = std::make_shared<LoggingEvent>(name, level1, location, std::move(msg));
 	callAppenders(event, p);
 }
 
diff --git a/src/main/cpp/loggingevent.cpp b/src/main/cpp/loggingevent.cpp
index aa7d304e..aa629b80 100644
--- a/src/main/cpp/loggingevent.cpp
+++ b/src/main/cpp/loggingevent.cpp
@@ -57,6 +57,28 @@ struct LoggingEvent::LoggingEventPrivate
 	{
 	}
 
+	LoggingEventPrivate
+		( const LogString& logger1
+		, const LevelPtr& level1
+		, const LocationInfo& locationInfo1
+		, LogString&& message1
+		) :
+		logger(logger1),
+		level(level1),
+		ndc(0),
+		mdcCopy(0),
+		properties(0),
+		ndcLookupRequired(true),
+		mdcCopyLookupRequired(true),
+		message(std::move(message1)),
+		timeStamp(Date::currentTime()),
+		locationInfo(locationInfo1),
+		threadName(getCurrentThreadName()),
+		threadUserName(getCurrentThreadUserName()),
+		chronoTimeStamp(std::chrono::microseconds(timeStamp))
+	{
+	}
+
 	LoggingEventPrivate(
 		const LogString& logger1, const LevelPtr& level1,
 		const LogString& message1, const LocationInfo& locationInfo1) :
@@ -159,6 +181,16 @@ LoggingEvent::LoggingEvent() :
 {
 }
 
+LoggingEvent::LoggingEvent
+	( const LogString&    logger
+	, const LevelPtr&     level
+	, const LocationInfo& location
+	, LogString&&         message
+	)
+	: m_priv(std::make_unique<LoggingEventPrivate>(logger, level, location, std::move(message)))
+{
+}
+
 LoggingEvent::LoggingEvent(
 	const LogString& logger1, const LevelPtr& level1,
 	const LogString& message1, const LocationInfo& locationInfo1) :
diff --git a/src/main/cpp/messagebuffer.cpp b/src/main/cpp/messagebuffer.cpp
index 607d5959..e17a6ef4 100644
--- a/src/main/cpp/messagebuffer.cpp
+++ b/src/main/cpp/messagebuffer.cpp
@@ -149,6 +149,16 @@ CharMessageBuffer::operator std::basic_ostream<char>& ()
 	return m_priv->StreamFromBuf();
 }
 
+std::basic_string<char> CharMessageBuffer::extract_str(std::basic_ostream<char>&)
+{
+	return std::move(m_priv->BufFromStream());
+}
+
+std::basic_string<char> CharMessageBuffer::extract_str(CharMessageBuffer&)
+{
+	return std::move(m_priv->buf);
+}
+
 const std::basic_string<char>& CharMessageBuffer::str(std::basic_ostream<char>&)
 {
 	return m_priv->BufFromStream();
@@ -284,6 +294,16 @@ WideMessageBuffer::operator std::basic_ostream<wchar_t>& ()
 	return m_priv->StreamFromBuf();
 }
 
+std::basic_string<wchar_t> WideMessageBuffer::extract_str(std::basic_ostream<wchar_t>&)
+{
+	return std::move(m_priv->BufFromStream());
+}
+
+std::basic_string<wchar_t> WideMessageBuffer::extract_str(WideMessageBuffer&)
+{
+	return std::move(m_priv->buf);
+}
+
 const std::basic_string<wchar_t>& WideMessageBuffer::str(std::basic_ostream<wchar_t>&)
 {
 	return m_priv->BufFromStream();
@@ -416,6 +436,16 @@ CharMessageBuffer& MessageBuffer::operator<<(const char msg)
 	return m_priv->cbuf.operator << (msg);
 }
 
+std::string MessageBuffer::extract_str(CharMessageBuffer& buf)
+{
+	return std::move(m_priv->cbuf.extract_str(buf));
+}
+
+std::string MessageBuffer::extract_str(std::ostream& os)
+{
+	return std::move(m_priv->cbuf.extract_str(os));
+}
+
 const std::string& MessageBuffer::str(CharMessageBuffer& buf)
 {
 	return m_priv->cbuf.str(buf);
@@ -449,6 +479,16 @@ WideMessageBuffer& MessageBuffer::operator<<(const wchar_t msg)
 	return (*m_priv->wbuf) << msg;
 }
 
+std::wstring MessageBuffer::extract_str(WideMessageBuffer& buf)
+{
+	return std::move(m_priv->wbuf->extract_str(buf));
+}
+
+std::wstring MessageBuffer::extract_str(std::basic_ostream<wchar_t>& os)
+{
+	return std::move(m_priv->wbuf->extract_str(os));
+}
+
 const std::wstring& MessageBuffer::str(WideMessageBuffer& buf)
 {
 	return m_priv->wbuf->str(buf);
@@ -524,6 +564,16 @@ UniCharMessageBuffer& MessageBuffer::operator<<(const log4cxx::UniChar msg)
 	return (*m_priv->ubuf) << msg;
 }
 
+std::basic_string<log4cxx::UniChar> MessageBuffer::extract_str(UniCharMessageBuffer& buf)
+{
+	return std::move(m_priv->ubuf->extract_str(buf));
+}
+
+std::basic_string<log4cxx::UniChar> MessageBuffer::extract_str(std::basic_ostream<log4cxx::UniChar>& os)
+{
+	return std::move(m_priv->ubuf->extract_str(os));
+}
+
 const std::basic_string<log4cxx::UniChar>& MessageBuffer::str(UniCharMessageBuffer& buf)
 {
 	return m_priv->ubuf->str(buf);
@@ -609,6 +659,16 @@ UniCharMessageBuffer::operator UniCharMessageBuffer::uostream& ()
 	return m_priv->StreamFromBuf();
 }
 
+std::basic_string<log4cxx::UniChar> UniCharMessageBuffer::extract_str(UniCharMessageBuffer::uostream&)
+{
+	return std::move(m_priv->BufFromStream());
+}
+
+std::basic_string<log4cxx::UniChar> UniCharMessageBuffer::extract_str(UniCharMessageBuffer&)
+{
+	return std::move(m_priv->buf);
+}
+
 const std::basic_string<log4cxx::UniChar>& UniCharMessageBuffer::str(UniCharMessageBuffer::uostream&)
 {
 	return m_priv->BufFromStream();
diff --git a/src/main/include/log4cxx/helpers/messagebuffer.h b/src/main/include/log4cxx/helpers/messagebuffer.h
index cb85102c..a2bbefbe 100644
--- a/src/main/include/log4cxx/helpers/messagebuffer.h
+++ b/src/main/include/log4cxx/helpers/messagebuffer.h
@@ -148,6 +148,20 @@ class LOG4CXX_EXPORT CharMessageBuffer
 		 */
 		operator std::basic_ostream<char>& ();
 
+		/**
+		 *   Remove the constructed string.
+		 *   @param os used only to signal that
+		 *       the embedded stream was used.
+		 */
+		std::basic_string<char> extract_str(std::basic_ostream<char>& os);
+
+		/**
+		 *   Remove the constructed string.
+		 *   @param buf used only to signal that
+		 *       the embedded stream was not used.
+		 */
+		std::basic_string<char> extract_str(CharMessageBuffer& buf);
+
 		/**
 		 *   Get content of buffer.
 		 *   @param os used only to signal that
@@ -318,6 +332,20 @@ class LOG4CXX_EXPORT UniCharMessageBuffer
 		*/
 		operator uostream& ();
 
+		/**
+		 *   Remove the constructed string.
+		 *   @param os used only to signal that
+		 *       the embedded stream was used.
+		 */
+		std::basic_string<UniChar> extract_str(uostream& os);
+
+		/**
+		 *   Remove the constructed string.
+		 *   @param buf used only to signal that
+		 *       the embedded stream was not used.
+		 */
+		std::basic_string<UniChar> extract_str(UniCharMessageBuffer& buf);
+
 		/**
 		 *   Get content of buffer.
 		 *   @param os used only to signal that
@@ -477,6 +505,20 @@ class LOG4CXX_EXPORT WideMessageBuffer
 		*/
 		operator std::basic_ostream<wchar_t>& ();
 
+		/**
+		 *   Remove the constructed string.
+		 *   @param os used only to signal that
+		 *       the embedded stream was used.
+		 */
+		std::basic_string<wchar_t> extract_str(std::basic_ostream<wchar_t>& os);
+
+		/**
+		 *   Remove the constructed string.
+		 *   @param buf used only to signal that
+		 *       the embedded stream was not used.
+		 */
+		std::basic_string<wchar_t> extract_str(WideMessageBuffer& buf);
+
 		/**
 		 *   Get content of buffer.
 		 *   @param os used only to signal that
@@ -568,6 +610,22 @@ class LOG4CXX_EXPORT MessageBuffer
 		 */
 		CharMessageBuffer& operator<<(const char msg);
 
+		/**
+		 *   Remove the constructed string.
+		 *   @param buf used only to signal
+		 *       the character type and that
+		 *       the embedded stream was not used.
+		 */
+		std::string extract_str(CharMessageBuffer& buf);
+
+		/**
+		 *   Remove the constructed string.
+		 *   @param os used only to signal
+		 *       the character type and that
+		 *       the embedded stream was used.
+		 */
+		std::string extract_str(std::ostream& os);
+
 		/**
 		 *   Get content of buffer.
 		 *   @param buf used only to signal
@@ -722,6 +780,22 @@ class LOG4CXX_EXPORT MessageBuffer
 		 *   @return encapsulated STL stream.
 		 */
 		std::ostream& operator<<(void* val);
+		/**
+		 *   Remove the constructed string.
+		 *   @param buf used only to signal
+		 *       the character type and that
+		 *       the embedded stream was not used.
+		 */
+		std::wstring extract_str(WideMessageBuffer& buf);
+
+		/**
+		 *   Remove the constructed string.
+		 *   @param os used only to signal
+		 *       the character type and that
+		 *       the embedded stream was used.
+		 */
+		std::wstring extract_str(std::basic_ostream<wchar_t>& os);
+
 		/**
 		 *   Get content of buffer.
 		 *   @param buf used only to signal
diff --git a/src/main/include/log4cxx/logger.h b/src/main/include/log4cxx/logger.h
index 14edd657..db61db42 100644
--- a/src/main/include/log4cxx/logger.h
+++ b/src/main/include/log4cxx/logger.h
@@ -116,7 +116,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 		*/
 		void debug(const std::string& msg, const log4cxx::spi::LocationInfo& location) const;
 		/**
@@ -146,7 +146,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_DEBUG.
 		*/
@@ -179,7 +179,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_DEBUG.
 		*/
@@ -212,7 +212,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_DEBUG.
 		*/
@@ -245,7 +245,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_ERROR.
 		*/
@@ -292,7 +292,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_ERROR.
 		*/
@@ -310,7 +310,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_ERROR.
 		*/
@@ -343,7 +343,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_ERROR.
 		*/
@@ -376,7 +376,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_FATAL.
 		*/
@@ -408,7 +408,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_FATAL.
 		*/
@@ -441,7 +441,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_FATAL.
 		*/
@@ -474,7 +474,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_FATAL.
 		*/
@@ -499,17 +499,27 @@ class LOG4CXX_EXPORT Logger :
 		/**
 		Add a new logging event containing \c message and \c location to attached appender(s).
 		without further checks.
-		@param level the level to log.
-		@param message message.
-		@param location location of source of logging request.
+		@param level The logging event level.
+		@param message The text to add to the logging event.
+		@param location The source code location of the logging request.
+		*/
+		void addEvent(const LevelPtr& level, std::string&& message
+			, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
+
+		/**
+		Add a new logging event containing \c message and \c location to attached appender(s).
+		without further checks.
+		@param level The logging event level.
+		@param message The text to add to the logging event.
+		@param location The source code location of the logging request.
 		*/
 		void forcedLog(const LevelPtr& level, const std::string& message,
 			const log4cxx::spi::LocationInfo& location) const;
 		/**
 		Add a new logging event containing \c message to attached appender(s).
 		without further checks.
-		@param level the level to log.
-		@param message message.
+		@param level The logging event level.
+		@param message The text to add to the logging event.
 		*/
 		void forcedLog(const LevelPtr& level, const std::string& message) const;
 
@@ -517,17 +527,27 @@ class LOG4CXX_EXPORT Logger :
 		/**
 		Add a new logging event containing \c message and \c location to attached appender(s).
 		without further checks.
-		@param level the level to log.
-		@param message message.
-		@param location location of source of logging request.
+		@param level The logging event level.
+		@param message The text to add to the logging event.
+		@param location The source code location of the logging request.
+		*/
+		void addEvent(const LevelPtr& level, std::wstring&& message
+			, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
+
+		/**
+		Add a new logging event containing \c message and \c location to attached appender(s).
+		without further checks.
+		@param level The logging event level.
+		@param message The text to add to the logging event.
+		@param location The source code location of the logging request.
 		*/
 		void forcedLog(const LevelPtr& level, const std::wstring& message,
 			const log4cxx::spi::LocationInfo& location) const;
 		/**
 		Add a new logging event containing \c message to attached appender(s).
 		without further checks.
-		@param level the level to log.
-		@param message message.
+		@param level The logging event level.
+		@param message The text to add to the logging event.
 		*/
 		void forcedLog(const LevelPtr& level, const std::wstring& message) const;
 #endif
@@ -535,17 +555,26 @@ class LOG4CXX_EXPORT Logger :
 		/**
 		Add a new logging event containing \c message and \c location to attached appender(s).
 		without further checks.
-		@param level the level to log.
-		@param message message.
-		@param location location of source of logging request.
+		@param level The logging event level.
+		@param message The text to add to the logging event.
+		@param location The source code location of the logging request.
+		*/
+		void addEvent(const LevelPtr& level, std::basic_string<UniChar>&& message,
+			const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
+		/**
+		Add a new logging event containing \c message and \c location to attached appender(s).
+		without further checks.
+		@param level The logging event level.
+		@param message The text to add to the logging event.
+		@param location The source code location of the logging request.
 		*/
 		void forcedLog(const LevelPtr& level, const std::basic_string<UniChar>& message,
 			const log4cxx::spi::LocationInfo& location) const;
 		/**
 		Add a new logging event containing \c message to attached appender(s).
 		without further checks.
-		@param level the level to log.
-		@param message message.
+		@param level The logging event level.
+		@param message The text to add to the logging event.
 		*/
 		void forcedLog(const LevelPtr& level, const std::basic_string<UniChar>& message) const;
 #endif
@@ -553,24 +582,34 @@ class LOG4CXX_EXPORT Logger :
 		/**
 		Add a new logging event containing \c message and \c location to attached appender(s).
 		without further checks.
-		@param level the level to log.
-		@param message message.
-		@param location location of source of logging request.
+		@param level The logging event level.
+		@param message The text to add to the logging event.
+		@param location The source code location of the logging request.
 		*/
 		void forcedLog(const LevelPtr& level, const CFStringRef& message,
 			const log4cxx::spi::LocationInfo& location) const;
 		/**
 		Add a new logging event containing \c message to attached appender(s).
 		without further checks.
-		@param level the level to log.
-		@param message message.
+		@param level The logging event level.
+		@param message The text to add to the logging event.
 		*/
 		void forcedLog(const LevelPtr& level, const CFStringRef& message) const;
 #endif
 		/**
 		Add a new logging event containing \c message and \c location to attached appender(s).
 		without further checks.
-		@param level the level to log.
+		@param level The logging event level.
+		@param message the message string to log.
+		@param location location of the logging statement.
+		*/
+		void addEventLS(const LevelPtr& level, LogString&& message
+			, const spi::LocationInfo& location = spi::LocationInfo::getLocationUnavailable()) const;
+
+		/**
+		Add a new logging event containing \c message and \c location to attached appender(s).
+		without further checks.
+		@param level The logging event level.
 		@param message the message string to log.
 		@param location location of the logging statement.
 		*/
@@ -826,7 +865,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_INFO.
 		*/
@@ -858,7 +897,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_INFO.
 		*/
@@ -891,7 +930,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 		        */
 		void info(const std::basic_string<UniChar>& msg, const log4cxx::spi::LocationInfo& location) const;
 		/**
@@ -922,7 +961,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_INFO.
 		*/
@@ -991,7 +1030,7 @@ class LOG4CXX_EXPORT Logger :
 		 *  <p>By writing
 		 *  ~~~{.cpp}
 		 *    if(log4cxx::Logger::isDebugEnabledFor(logger)) {
-		 *      logger->forcedLog(log4cxx::Level::getDebug(), "Component: " + std::to_string(componentNumber));
+		 *      logger->addEvent(log4cxx::Level::getDebug(), "Component: " + std::to_string(componentNumber));
 		 *    }
 		 *  ~~~
 		 *  you minimise the computational cost
@@ -1666,7 +1705,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_WARN.
 		*/
@@ -1699,7 +1738,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_WARN.
 		*/
@@ -1732,7 +1771,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_WARN.
 		*/
@@ -1764,7 +1803,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_WARN.
 		*/
@@ -1797,7 +1836,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_TRACE.
 		*/
@@ -1830,7 +1869,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_TRACE.
 		*/
@@ -1863,7 +1902,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_TRACE.
 		*/
@@ -1895,7 +1934,7 @@ class LOG4CXX_EXPORT Logger :
 		hierarchy depending on the value of the additivity flag.
 
 		@param msg the message string to log.
-		@param location location of source of logging request.
+		@param location The source code location of the logging request.
 
 		See also #LOG4CXX_TRACE.
 		*/
@@ -1981,36 +2020,36 @@ LOG4CXX_LIST_DEF(LoggerList, LoggerPtr);
 Add a new logging event containing \c message to attached appender(s) if this logger is enabled for \c events.
 
 @param logger the logger to be used.
-@param level the level to log.
+@param level The logging event level.
 @param message the message string to log.
 */
 #define LOG4CXX_LOG(logger, level, message) do { \
 		if (logger->isEnabledFor(level)) {\
 			::log4cxx::helpers::MessageBuffer oss_; \
-			logger->forcedLog(level, oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
+			logger->addEvent(level, oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
 
 /**
 Add a new logging event containing libfmt formatted <code>...</code> to attached appender(s) if this logger is enabled for \c events.
 
 @param logger the logger to be used.
-@param level the level to log.
+@param level The logging event level.
 @param ... The format string and message to log
 */
 #define LOG4CXX_LOG_FMT(logger, level, ...) do { \
 		if (logger->isEnabledFor(level)) {\
-			logger->forcedLog(level, fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
+			logger->addEvent(level, fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
 
 /**
 Add a new logging event containing \c message to attached appender(s) if this logger is enabled for \c events.
 
 @param logger the logger to be used.
-@param level the level to log.
+@param level The logging event level.
 @param message the message string to log in the internal encoding.
 */
 #define LOG4CXX_LOGLS(logger, level, message) do { \
 		if (logger->isEnabledFor(level)) {\
 			::log4cxx::helpers::LogCharMessageBuffer oss_; \
-			logger->forcedLog(level, oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
+			logger->addEvent(level, oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
 
 #if !defined(LOG4CXX_THRESHOLD) || LOG4CXX_THRESHOLD <= 10000
 /**
@@ -2034,7 +2073,7 @@ LOG4CXX_DEBUG(m_log, "AddMesh:"
 #define LOG4CXX_DEBUG(logger, message) do { \
 		if (LOG4CXX_UNLIKELY(::log4cxx::Logger::isDebugEnabledFor(logger))) {\
 			::log4cxx::helpers::MessageBuffer oss_; \
-			logger->forcedLog(::log4cxx::Level::getDebug(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
+			logger->addEvent(::log4cxx::Level::getDebug(), oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
 
 /**
 Add a new logging event containing libfmt formatted <code>...</code> to attached appender(s) if \c logger is enabled for <code>DEBUG</code> events.
@@ -2044,7 +2083,7 @@ Add a new logging event containing libfmt formatted <code>...</code> to attached
 */
 #define LOG4CXX_DEBUG_FMT(logger, ...) do { \
 		if (LOG4CXX_UNLIKELY(::log4cxx::Logger::isDebugEnabledFor(logger))) {\
-			logger->forcedLog(::log4cxx::Level::getDebug(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
+			logger->addEvent(::log4cxx::Level::getDebug(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
 #else
 #define LOG4CXX_DEBUG(logger, message)
 #define LOG4CXX_DEBUG_FMT(logger, ...)
@@ -2066,7 +2105,7 @@ Add a new logging event containing \c message to attached appender(s) if \c logg
 #define LOG4CXX_TRACE(logger, message) do { \
 		if (LOG4CXX_UNLIKELY(::log4cxx::Logger::isTraceEnabledFor(logger))) {\
 			::log4cxx::helpers::MessageBuffer oss_; \
-			logger->forcedLog(::log4cxx::Level::getTrace(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
+			logger->addEvent(::log4cxx::Level::getTrace(), oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
 
 /**
 Add a new logging event containing libfmt formatted <code>...</code> to attached appender(s) if \c logger is enabled for <code>TRACE</code> events.
@@ -2076,7 +2115,7 @@ Add a new logging event containing libfmt formatted <code>...</code> to attached
 */
 #define LOG4CXX_TRACE_FMT(logger, ...) do { \
 		if (LOG4CXX_UNLIKELY(::log4cxx::Logger::isTraceEnabledFor(logger))) {\
-			logger->forcedLog(::log4cxx::Level::getTrace(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
+			logger->addEvent(::log4cxx::Level::getTrace(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
 #else
 #define LOG4CXX_TRACE(logger, message)
 #define LOG4CXX_TRACE_FMT(logger, ...)
@@ -2102,7 +2141,7 @@ LOG4CXX_INFO(m_log, surface->GetName()
 #define LOG4CXX_INFO(logger, message) do { \
 		if (::log4cxx::Logger::isInfoEnabledFor(logger)) {\
 			::log4cxx::helpers::MessageBuffer oss_; \
-			logger->forcedLog(::log4cxx::Level::getInfo(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
+			logger->addEvent(::log4cxx::Level::getInfo(), oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
 
 /**
 Add a new logging event containing libfmt formatted <code>...</code> to attached appender(s) if \c logger is enabled for <code>INFO</code> events.
@@ -2112,7 +2151,7 @@ Add a new logging event containing libfmt formatted <code>...</code> to attached
 */
 #define LOG4CXX_INFO_FMT(logger, ...) do { \
 		if (::log4cxx::Logger::isInfoEnabledFor(logger)) {\
-			logger->forcedLog(::log4cxx::Level::getInfo(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
+			logger->addEvent(::log4cxx::Level::getInfo(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
 #else
 #define LOG4CXX_INFO(logger, message)
 #define LOG4CXX_INFO_FMT(logger, ...)
@@ -2136,7 +2175,7 @@ catch (const std::exception& ex)
 #define LOG4CXX_WARN(logger, message) do { \
 		if (::log4cxx::Logger::isWarnEnabledFor(logger)) {\
 			::log4cxx::helpers::MessageBuffer oss_; \
-			logger->forcedLog(::log4cxx::Level::getWarn(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
+			logger->addEvent(::log4cxx::Level::getWarn(), oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
 
 /**
 Add a new logging event containing libfmt formatted <code>...</code> to attached appender(s) if \c logger is enabled for <code>WARN</code> events.
@@ -2146,7 +2185,7 @@ Add a new logging event containing libfmt formatted <code>...</code> to attached
 */
 #define LOG4CXX_WARN_FMT(logger, ...) do { \
 		if (::log4cxx::Logger::isWarnEnabledFor(logger)) {\
-			logger->forcedLog(::log4cxx::Level::getWarn(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
+			logger->addEvent(::log4cxx::Level::getWarn(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
 #else
 #define LOG4CXX_WARN(logger, message)
 #define LOG4CXX_WARN_FMT(logger, ...)
@@ -2170,7 +2209,7 @@ catch (std::exception& ex)
 #define LOG4CXX_ERROR(logger, message) do { \
 		if (::log4cxx::Logger::isErrorEnabledFor(logger)) {\
 			::log4cxx::helpers::MessageBuffer oss_; \
-			logger->forcedLog(::log4cxx::Level::getError(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
+			logger->addEvent(::log4cxx::Level::getError(), oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
 
 /**
 Add a new logging event containing libfmt formatted <code>...</code> to attached appender(s) if \c logger is enabled for <code>ERROR</code> events.
@@ -2180,7 +2219,7 @@ Add a new logging event containing libfmt formatted <code>...</code> to attached
 */
 #define LOG4CXX_ERROR_FMT(logger, ...) do { \
 		if (::log4cxx::Logger::isErrorEnabledFor(logger)) {\
-			logger->forcedLog(::log4cxx::Level::getError(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
+			logger->addEvent(::log4cxx::Level::getError(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
 
 /**
 If \c condition is not true, add a new logging event containing \c message to attached appender(s) if \c logger is enabled for <code>ERROR</code> events.
@@ -2193,7 +2232,7 @@ If \c condition is not true, add a new logging event containing \c message to at
 		if (!(condition) && ::log4cxx::Logger::isErrorEnabledFor(logger)) {\
 			::log4cxx::helpers::MessageBuffer oss_; \
 			LOG4CXX_STACKTRACE \
-			logger->forcedLog(::log4cxx::Level::getError(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
+			logger->addEvent(::log4cxx::Level::getError(), oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
 
 /**
 If \c condition is not true, add a new logging event containing libfmt formatted \c message to attached appender(s) if \c logger is enabled for <code>ERROR</code> events.
@@ -2205,7 +2244,7 @@ If \c condition is not true, add a new logging event containing libfmt formatted
 #define LOG4CXX_ASSERT_FMT(logger, condition, ...) do { \
 		if (!(condition) && ::log4cxx::Logger::isErrorEnabledFor(logger)) {\
 			LOG4CXX_STACKTRACE \
-			logger->forcedLog(::log4cxx::Level::getError(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
+			logger->addEvent(::log4cxx::Level::getError(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
 
 #else
 #define LOG4CXX_ERROR(logger, message)
@@ -2229,7 +2268,7 @@ LOG4CXX_FATAL(m_log, m_renderSystem->getName() << " is not supported");
 #define LOG4CXX_FATAL(logger, message) do { \
 		if (::log4cxx::Logger::isFatalEnabledFor(logger)) {\
 			::log4cxx::helpers::MessageBuffer oss_; \
-			logger->forcedLog(::log4cxx::Level::getFatal(), oss_.str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
+			logger->addEvent(::log4cxx::Level::getFatal(), oss_.extract_str(oss_ << message), LOG4CXX_LOCATION); }} while (0)
 
 /**
 Add a new logging event containing libfmt formatted <code>...</code> to attached appender(s) if \c logger is enabled for <code>FATAL</code> events.
@@ -2239,7 +2278,7 @@ Add a new logging event containing libfmt formatted <code>...</code> to attached
 */
 #define LOG4CXX_FATAL_FMT(logger, ...) do { \
 		if (::log4cxx::Logger::isFatalEnabledFor(logger)) {\
-			logger->forcedLog(::log4cxx::Level::getFatal(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
+			logger->addEvent(::log4cxx::Level::getFatal(), fmt::format( __VA_ARGS__ ), LOG4CXX_LOCATION); }} while (0)
 #else
 #define LOG4CXX_FATAL(logger, message)
 #define LOG4CXX_FATAL_FMT(logger, ...)
@@ -2249,7 +2288,7 @@ Add a new logging event containing libfmt formatted <code>...</code> to attached
 Add a new logging event containing the localized message \c key to attached appender(s) if \c logger is enabled for \c level events.
 
 @param logger the logger to be used.
-@param level the level to log.
+@param level The logging event level.
 @param key the key to be searched in the resourceBundle of the logger.
 */
 #define LOG4CXX_L7DLOG(logger, level, key) do { \
@@ -2260,7 +2299,7 @@ Add a new logging event containing the localized message \c key to attached appe
 Add a new logging event containing the localized message \c key to attached appender(s) if \c logger is enabled for \c level events with one parameter.
 
 @param logger the logger to be used.
-@param level the level to log.
+@param level The logging event level.
 @param key the key to be searched in the resourceBundle of the logger.
 @param p1 the unique parameter.
 */
@@ -2272,7 +2311,7 @@ Add a new logging event containing the localized message \c key to attached appe
 Add a new logging event containing the localized message \c key to attached appender(s) if \c logger is enabled for \c level events with two parameters.
 
 @param logger the logger to be used.
-@param level the level to log.
+@param level The logging event level.
 @param key the key to be searched in the resourceBundle of the logger.
 @param p1 the first parameter.
 @param p2 the second parameter.
@@ -2285,7 +2324,7 @@ Add a new logging event containing the localized message \c key to attached appe
 Add a new logging event containing the localized message \c key to attached appender(s) if \c logger is enabled for \c level events with three parameters.
 
 @param logger the logger to be used.
-@param level the level to log.
+@param level The logging event level.
 @param key the key to be searched in the resourceBundle of the logger.
 @param p1 the first parameter.
 @param p2 the second parameter.
diff --git a/src/main/include/log4cxx/spi/loggingevent.h b/src/main/include/log4cxx/spi/loggingevent.h
index 8641fcf6..b4234624 100644
--- a/src/main/include/log4cxx/spi/loggingevent.h
+++ b/src/main/include/log4cxx/spi/loggingevent.h
@@ -69,8 +69,26 @@ class LOG4CXX_EXPORT LoggingEvent :
 		<p>
 		@param logger The logger of this event.
 		@param level The level of this event.
-		@param message  The message of this event.
-		@param location location of logging request.
+		@param location The source code location of the logging request.
+		@param message  The text to add to this event.
+		*/
+		LoggingEvent
+			( const LogString& logger
+			, const LevelPtr& level
+			, const spi::LocationInfo& location
+			, LogString&& message
+			);
+
+		/**
+		Instantiate a LoggingEvent from the supplied parameters.
+
+		<p>Except timeStamp all the other fields of
+		<code>LoggingEvent</code> are filled when actually needed.
+		<p>
+		@param logger The logger of this event.
+		@param level The level of this event.
+		@param message  The text to add to this event.
+		@param location The source code location of the logging request.
 		*/
 		LoggingEvent(const LogString& logger,
 			const LevelPtr& level,   const LogString& message,