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/05/03 00:16:51 UTC
[logging-log4cxx] branch odbc_appender_regression created (now 0bdf9eda)
This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a change to branch odbc_appender_regression
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
at 0bdf9eda ODBCAppender should not use the message as an SQL statement
This branch includes the following new commits:
new 86526407 Revert "Remove the layout for the ODBC appender, since we only insert into columns (#211)"
new 0bdf9eda ODBCAppender should not use the message as an SQL statement
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[logging-log4cxx] 02/02: ODBCAppender should not use the message as an SQL statement
Posted by sw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a commit to branch odbc_appender_regression
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit 0bdf9edae584e5c94b887c977c3d4e092a1a84e4
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Wed May 3 10:16:26 2023 +1000
ODBCAppender should not use the message as an SQL statement
---
src/main/cpp/odbcappender.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/main/cpp/odbcappender.cpp b/src/main/cpp/odbcappender.cpp
index b5202c6b..49993fd0 100644
--- a/src/main/cpp/odbcappender.cpp
+++ b/src/main/cpp/odbcappender.cpp
@@ -249,7 +249,10 @@ void ODBCAppender::append(const spi::LoggingEventPtr& event, log4cxx::helpers::P
LogString ODBCAppender::getLogStatement(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p) const
{
LogString sbuf;
- getLayout()->format(sbuf, event, p);
+ if (auto l = getLayout())
+ l->format(sbuf, event, p);
+ else
+ LogLog::error(LOG4CXX_STR("A SQL statement must be provided to ODBCAppender"));
return sbuf;
}
[logging-log4cxx] 01/02: Revert "Remove the layout for the ODBC appender, since we only insert into columns (#211)"
Posted by sw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a commit to branch odbc_appender_regression
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit 86526407fd55c13702ad90d384c04056fd057efb
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Wed May 3 10:08:03 2023 +1000
Revert "Remove the layout for the ODBC appender, since we only insert into columns (#211)"
This reverts commit 0be583c3a43bd643f445b14fba9d570aa54274c8.
---
src/main/cpp/odbcappender.cpp | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/src/main/cpp/odbcappender.cpp b/src/main/cpp/odbcappender.cpp
index f6f93158..b5202c6b 100644
--- a/src/main/cpp/odbcappender.cpp
+++ b/src/main/cpp/odbcappender.cpp
@@ -192,7 +192,7 @@ void ODBCAppender::setOption(const LogString& option, const LogString& value)
bool ODBCAppender::requiresLayout() const
{
- return false;
+ return _priv->parameterValue.empty();
}
void ODBCAppender::activateOptions(log4cxx::helpers::Pool&)
@@ -248,7 +248,9 @@ void ODBCAppender::append(const spi::LoggingEventPtr& event, log4cxx::helpers::P
LogString ODBCAppender::getLogStatement(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p) const
{
- return event->getMessage();
+ LogString sbuf;
+ getLayout()->format(sbuf, event, p);
+ return sbuf;
}
void ODBCAppender::execute(const LogString& sql, log4cxx::helpers::Pool& p)
@@ -643,7 +645,23 @@ void ODBCAppender::flushBuffer(Pool& p)
void ODBCAppender::setSql(const LogString& s)
{
- _priv->sqlStatement = s;
+ _priv->sqlStatement = s;
+
+ if (getLayout() == 0)
+ {
+ this->setLayout(std::make_shared<PatternLayout>(s));
+ }
+ else
+ {
+ PatternLayoutPtr patternLayout;
+ LayoutPtr asLayout = this->getLayout();
+ patternLayout = log4cxx::cast<PatternLayout>(asLayout);
+
+ if (patternLayout != 0)
+ {
+ patternLayout->setConversionPattern(s);
+ }
+ }
}
#if LOG4CXX_WCHAR_T_API || LOG4CXX_LOGCHAR_IS_WCHAR_T || defined(WIN32) || defined(_WIN32)