You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rm...@apache.org on 2022/12/16 03:14:01 UTC
[logging-log4cxx] branch LOGCXX-567 updated: Added test and rename things to be more appropriate
This is an automated email from the ASF dual-hosted git repository.
rmiddleton pushed a commit to branch LOGCXX-567
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
The following commit(s) were added to refs/heads/LOGCXX-567 by this push:
new 4dd767d4 Added test and rename things to be more appropriate
4dd767d4 is described below
commit 4dd767d4b53ce72f3c101a31aafde2fa18c7fafd
Author: Robert Middleton <ro...@rm5248.com>
AuthorDate: Thu Dec 15 22:13:55 2022 -0500
Added test and rename things to be more appropriate
---
src/main/cpp/CMakeLists.txt | 2 +-
.../cpp/{logbuilder.cpp => optionallogparams.cpp} | 2 +-
src/main/include/log4cxx/logger.h | 2 +-
.../log4cxx/{logbuilder.h => optionallogparams.h} | 6 +-
src/test/cpp/CMakeLists.txt | 1 +
src/test/cpp/stacktracetest.cpp | 71 ++++++++++++++++++++++
6 files changed, 78 insertions(+), 6 deletions(-)
diff --git a/src/main/cpp/CMakeLists.txt b/src/main/cpp/CMakeLists.txt
index f2ab2796..636d3aa5 100644
--- a/src/main/cpp/CMakeLists.txt
+++ b/src/main/cpp/CMakeLists.txt
@@ -131,7 +131,6 @@ target_sources(log4cxx
loader.cpp
locale.cpp
locationinfo.cpp
- logbuilder.cpp
logger.cpp
loggermatchfilter.cpp
loggerpatternconverter.cpp
@@ -155,6 +154,7 @@ target_sources(log4cxx
odbcappender.cpp
onlyonceerrorhandler.cpp
optionconverter.cpp
+ optionallogparams.cpp
outputdebugstringappender.cpp
outputstream.cpp
outputstreamwriter.cpp
diff --git a/src/main/cpp/logbuilder.cpp b/src/main/cpp/optionallogparams.cpp
similarity index 96%
rename from src/main/cpp/logbuilder.cpp
rename to src/main/cpp/optionallogparams.cpp
index 12bda43f..564f5d7d 100644
--- a/src/main/cpp/logbuilder.cpp
+++ b/src/main/cpp/optionallogparams.cpp
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-#include <log4cxx/logbuilder.h>
+#include <log4cxx/optionallogparams.h>
using log4cxx::OptionalLogParams;
diff --git a/src/main/include/log4cxx/logger.h b/src/main/include/log4cxx/logger.h
index c0e3b19a..8f2f43a6 100644
--- a/src/main/include/log4cxx/logger.h
+++ b/src/main/include/log4cxx/logger.h
@@ -24,7 +24,7 @@
#include <log4cxx/spi/location/locationinfo.h>
#include <log4cxx/helpers/resourcebundle.h>
#include <log4cxx/helpers/messagebuffer.h>
-#include <log4cxx/logbuilder.h>
+#include <log4cxx/optionallogparams.h>
namespace log4cxx
{
diff --git a/src/main/include/log4cxx/logbuilder.h b/src/main/include/log4cxx/optionallogparams.h
similarity index 93%
rename from src/main/include/log4cxx/logbuilder.h
rename to src/main/include/log4cxx/optionallogparams.h
index 7e3dbbe2..a9fec17d 100644
--- a/src/main/include/log4cxx/logbuilder.h
+++ b/src/main/include/log4cxx/optionallogparams.h
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-#ifndef _LOG4CXX_LOGBUILDER_H
-#define _LOG4CXX_LOGBUILDER_H
+#ifndef _LOG4CXX_OPTIONALLOGPARAMS_H
+#define _LOG4CXX_OPTIONALLOGPARAMS_H
#include <log4cxx/spi/location/locationinfo.h>
#include <log4cxx/level.h>
@@ -32,7 +32,7 @@ namespace log4cxx {
* The OptionalLogParams class provides a way of providing optional log parameters,
* depending on if the feature is enabled by client code or not.
*/
-class OptionalLogParams{
+class LOG4CXX_EXPORT OptionalLogParams{
public:
enum class ParameterType{
BoostStacktrace,
diff --git a/src/test/cpp/CMakeLists.txt b/src/test/cpp/CMakeLists.txt
index 74a35e5b..2a910340 100644
--- a/src/test/cpp/CMakeLists.txt
+++ b/src/test/cpp/CMakeLists.txt
@@ -57,6 +57,7 @@ set(ALL_LOG4CXX_TESTS
multithreadtest
locationtest
locationdisabledtest
+ stacktracetest
)
if(${ENABLE_FMT_LAYOUT})
set(ALL_LOG4CXX_TESTS ${ALL_LOG4CXX_TESTS} fmttest)
diff --git a/src/test/cpp/stacktracetest.cpp b/src/test/cpp/stacktracetest.cpp
new file mode 100644
index 00000000..27cd345e
--- /dev/null
+++ b/src/test/cpp/stacktracetest.cpp
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#define LOG4CXX_ENABLE_STACKTRACE
+#include <log4cxx/logger.h>
+#include <log4cxx/propertyconfigurator.h>
+#include <log4cxx/spi/loggingevent.h>
+
+#include "testchar.h"
+#include "logunit.h"
+#include "util/compare.h"
+#include "vectorappender.h"
+
+using namespace log4cxx;
+using namespace log4cxx::helpers;
+using namespace log4cxx::spi;
+
+LOGUNIT_CLASS(StacktraceTest)
+{
+ LOGUNIT_TEST_SUITE(StacktraceTest);
+ LOGUNIT_TEST(test1);
+ LOGUNIT_TEST_SUITE_END();
+
+public:
+ void setUp()
+ {
+ }
+
+ void tearDown()
+ {
+ }
+
+ void test1()
+ {
+ LoggerPtr logger = Logger::getLogger("test.logger");
+ logger->setLevel(Level::getTrace());
+ VectorAppenderPtr vecAppend = std::make_shared<VectorAppender>();
+ logger->addAppender(vecAppend);
+
+ LOG4CXX_FATAL(logger, "Some Message");
+ LOG4CXX_ERROR(logger, "Some Message");
+ LOG4CXX_WARN(logger, "Some Message");
+ LOG4CXX_INFO(logger, "Some Message");
+ LOG4CXX_DEBUG(logger, "Some Message");
+ LOG4CXX_TRACE(logger, "Some Message");
+
+ LOGUNIT_ASSERT(vecAppend->getVector().size() == 6);
+#if LOG4CXX_HAS_BOOST_STACKTRACE
+ for( LoggingEventPtr loggingEvent : vecAppend->getVector() ){
+ LOGUNIT_ASSERT(loggingEvent->getStacktrace().size() > 0);
+ }
+#endif
+ }
+
+};
+
+
+LOGUNIT_TEST_SUITE_REGISTRATION(StacktraceTest);