Author: carnold
Date: Mon Sep 24 22:10:47 2007
New Revision: 579071
URL: http://svn.apache.org/viewvc?rev=579071&view=rev
Log:
LOGCXX-18: Restores << operator in LOG4CXX_INFO et al
Added:
logging/log4cxx/trunk/src/main/cpp/messagebuffer.cpp
logging/log4cxx/trunk/src/main/include/log4cxx/helpers/messagebuffer.h
Modified:
logging/log4cxx/trunk/src/main/cpp/Makefile.am
logging/log4cxx/trunk/src/main/include/log4cxx/logger.h
logging/log4cxx/trunk/src/test/cpp/Makefile.am
logging/log4cxx/trunk/src/test/cpp/streamtestcase.cpp
Modified: logging/log4cxx/trunk/src/main/cpp/Makefile.am
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/Makefile.am?rev=579071&r1=579070&r2=579071&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/Makefile.am (original)
+++ logging/log4cxx/trunk/src/main/cpp/Makefile.am Mon Sep 24 22:10:47 2007
@@ -88,6 +88,7 @@
logmanager.cpp \
logstream.cpp \
manualtriggeringpolicy.cpp \
+ messagebuffer.cpp \
messagepatternconverter.cpp \
methodlocationpatternconverter.cpp \
mdc.cpp \
Added: logging/log4cxx/trunk/src/main/cpp/messagebuffer.cpp
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/messagebuffer.cpp?rev=579071&view=auto
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/messagebuffer.cpp (added)
+++ logging/log4cxx/trunk/src/main/cpp/messagebuffer.cpp Mon Sep 24 22:10:47
2007
@@ -0,0 +1,150 @@
+/*
+ * 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.
+ */
+
+#include <log4cxx/helpers/messagebuffer.h>
+
+using namespace log4cxx::helpers;
+
+MessageBuffer::MessageBuffer() {
+ stream = 0;
+#if LOG4CXX_HAS_WCHAR_T
+ wbuf = 0;
+#endif
+}
+
+MessageBuffer::~MessageBuffer() {
+ delete stream;
+#if LOG4CXX_HAS_WCHAR_T
+ delete wbuf;
+#endif
+}
+
+MessageBuffer& MessageBuffer::operator+(const std::string& msg) {
+ buf.assign(msg);
+ return *this;
+}
+
+MessageBuffer& MessageBuffer::operator+(const char* msg) {
+ if (0 == msg) {
+ buf.assign("null");
+ } else {
+ buf.assign(msg);
+ }
+ return *this;
+}
+
+MessageBuffer& MessageBuffer::operator+(const char msg) {
+ buf.assign(1, msg);
+ return *this;
+}
+
+MessageBuffer& MessageBuffer::operator<<(const std::string& msg) {
+ buf.append(msg);
+ return *this;
+}
+
+MessageBuffer& MessageBuffer::operator<<(const char* msg) {
+ if (0 == msg) {
+ buf.append("null");
+ } else {
+ buf.append(msg);
+ }
+ return *this;
+}
+
+MessageBuffer& MessageBuffer::operator<<(const char msg) {
+ buf.append(1, msg);
+ return *this;
+}
+
+const std::string& MessageBuffer::str(const MessageBuffer&) const {
+ return buf;
+}
+
+std::string MessageBuffer::str(const std::ostream&) const {
+ return stream->str();
+}
+
+#if LOG4CXX_HAS_WCHAR_T
+WideMessageBuffer& MessageBuffer::operator+(const std::wstring& msg) {
+ wbuf = new WideMessageBuffer(msg);
+ return *wbuf;
+}
+
+WideMessageBuffer& MessageBuffer::operator+(const wchar_t* msg) {
+ if (0 == msg) {
+ wbuf = new WideMessageBuffer(L"null"):
+ } else {
+ wbuf = new WideMessageBuffer(msg);
+ }
+ return *wbuf;
+}
+
+WideMessageBuffer& MessageBuffer::operator+(const wchar_t msg) {
+ wbuf = new WideMessageBuffer(msg);
+ return *wbuf;
+}
+
+const std::wstring& MessageBuffer::str(const WideMessageBuffer& wide) const {
+ return wbuf->str(wide);
+}
+
+std::wstring MessageBuffer::str(const std::wostream& wstr) const {
+ return wbuf->str(wstr);
+}
+
+WideMessageBuffer::WideMessageBuffer(const wchar_t msg) : buf(1, msg),
stream(0) {
+}
+
+WideMessageBuffer::WideMessageBuffer(const wchar_t* msg) : buf(msg), stream(0)
{
+}
+
+WideMessageBuffer::WideMessageBuffer(const std::wstream& msg) : buf(msg),
stream(0) {
+}
+
+const std::wstring& WideMessageBuffer::str(const WideMessageBuffer&) const {
+ return buf;
+}
+
+std::wstring WideMessageBuffer::str(const std::wostream&) const {
+ return stream->str();
+}
+
+WideMessageBuffer& WideMessageBuffer::operator<<(const std::wstring& msg) {
+ buf.append(msg);
+ return *this;
+}
+
+WideMessageBuffer& WideMessageBuffer::operator<<(const wchar_t* msg) {
+ if (0 == msg) {
+ buf.append(L"null");
+ } else {
+ buf.append(msg);
+ }
+ return *this;
+}
+
+WideMessageBuffer& WideMessageBuffer::operator<<(const wchar_t msg) {
+ buf.append(1, msg);
+ return *this;
+}
+
+
+#endif
+
+
+
Added: logging/log4cxx/trunk/src/main/include/log4cxx/helpers/messagebuffer.h
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/include/log4cxx/helpers/messagebuffer.h?rev=579071&view=auto
==============================================================================
--- logging/log4cxx/trunk/src/main/include/log4cxx/helpers/messagebuffer.h
(added)
+++ logging/log4cxx/trunk/src/main/include/log4cxx/helpers/messagebuffer.h Mon
Sep 24 22:10:47 2007
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ */
+
+#ifndef _LOG4CXX_MESSAGE_BUFFER_H
+#define _LOG4CXX_MESSAGE_BUFFER_H
+
+#include <string>
+#include <log4cxx/log4cxx.h>
+#include <ostream>
+#include <sstream>
+
+namespace log4cxx {
+ namespace helpers {
+
+#if LOG4CXX_HAS_WCHAR_T
+ class LOG4CXX_EXPORT WideMessageBuffer {
+ public:
+ WideMessageBuffer(const wchar_t);
+ WideMessageBuffer(const wchar_t*);
+ WideMessageBuffer(const std::wstring&);
+ ~WideMessageBuffer();
+
+ const std::wstring& str(const WideMessageBuffer&) const;
+ std::wstring str(const std::wostream&) const;
+
+ WideMessageBuffer& operator<<(const std::wstring& msg);
+ WideMessageBuffer& operator<<(const wchar_t* msg);
+ WideMessageBuffer& operator<<(const wchar_t msg);
+
+ template<class T>
+ std::wostream& operator<<(T arg) {
+ stream = new std::wostringstream();
+ return *stream << buf << arg;
+ }
+
+ private:
+ std::wstring buf;
+ std::wostringstream* stream;
+ };
+#endif
+
+ class LOG4CXX_EXPORT MessageBuffer {
+ public:
+ MessageBuffer();
+ ~MessageBuffer();
+
+ MessageBuffer& operator+(const std::string& msg);
+ MessageBuffer& operator+(const char* msg);
+ MessageBuffer& operator+(const char msg);
+
+ MessageBuffer& operator<<(const std::string& msg);
+ MessageBuffer& operator<<(const char* msg);
+ MessageBuffer& operator<<(const char msg);
+
+ template<class T>
+ std::ostream& operator<<(T arg) {
+ stream = new std::ostringstream();
+ return *stream << buf << arg;
+ }
+
+ template<class T>
+ std::ostream& operator+(T arg) {
+ return operator<<(arg);
+ }
+
+ const std::string& str(const MessageBuffer&) const;
+ std::string str(const std::ostream&) const;
+
+#if LOG4CXX_HAS_WCHAR_T
+ WideMessageBuffer& operator+(const std::wstring& msg);
+ WideMessageBuffer& operator+(const wchar_t* msg);
+ WideMessageBuffer& operator+(const wchar_t msg);
+
+ static std::wstring str(const WideMessageBuffer&);
+ static std::wstring str(const std::wostring&);
+#endif
+
+ private:
+ std::string buf;
+ std::ostringstream* stream;
+#if LOG4CXX_HAS_WCHAR_T
+ WideMessageBuffer* wbuf;
+#endif
+ };
+
+}
+}
+
+#endif
+
Modified: logging/log4cxx/trunk/src/main/include/log4cxx/logger.h
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/include/log4cxx/logger.h?rev=579071&r1=579070&r2=579071&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/include/log4cxx/logger.h (original)
+++ logging/log4cxx/trunk/src/main/include/log4cxx/logger.h Mon Sep 24 22:10:47
2007
@@ -26,6 +26,7 @@
#include <log4cxx/spi/location/locationinfo.h>
#include <log4cxx/helpers/resourcebundle.h>
#include <log4cxx/spi/loggerrepository.h>
+#include <log4cxx/helpers/messagebuffer.h>
namespace log4cxx
@@ -613,6 +614,7 @@
log4cxx::helpers::Mutex mutex;
friend class log4cxx::helpers::synchronized;
};
+
}
/** @addtogroup LoggingMacros Logging macros
@@ -649,7 +651,8 @@
*/
#define LOG4CXX_LOG(logger, level, message) { \
if (logger->isEnabledFor(level)) {\
- logger->forcedLog(level, message, LOG4CXX_LOCATION); } }
+ ::log4cxx::helpers::MessageBuffer buf; \
+ logger->forcedLog(level, buf.str(buf + message), LOG4CXX_LOCATION);
} }
/**
Logs a message to a specified logger with the DEBUG level.
@@ -659,7 +662,8 @@
*/
#define LOG4CXX_DEBUG(logger, message) { \
if (LOG4CXX_UNLIKELY(logger->isDebugEnabled())) {\
- logger->forcedLog(::log4cxx::Level::getDebug(), message,
LOG4CXX_LOCATION); }}
+ ::log4cxx::helpers::MessageBuffer buf; \
+ logger->forcedLog(::log4cxx::Level::getDebug(), buf.str(buf +
message), LOG4CXX_LOCATION); }}
/**
Logs a message to a specified logger with the TRACE level.
@@ -669,7 +673,8 @@
*/
#define LOG4CXX_TRACE(logger, message) { \
if (LOG4CXX_UNLIKELY(logger->isTraceEnabled())) {\
- logger->forcedLog(::log4cxx::Level::getTrace(), message,
LOG4CXX_LOCATION); }}
+ ::log4cxx::helpers::MessageBuffer buf; \
+ logger->forcedLog(::log4cxx::Level::getTrace(), buf.str(buf +
message), LOG4CXX_LOCATION); }}
/**
@@ -680,7 +685,8 @@
*/
#define LOG4CXX_INFO(logger, message) { \
if (logger->isInfoEnabled()) {\
- logger->forcedLog(::log4cxx::Level::getInfo(), message,
LOG4CXX_LOCATION); }}
+ ::log4cxx::helpers::MessageBuffer buf; \
+ logger->forcedLog(::log4cxx::Level::getInfo(), buf.str(buf +
message), LOG4CXX_LOCATION); }}
/**
Logs a message to a specified logger with the WARN level.
@@ -690,7 +696,8 @@
*/
#define LOG4CXX_WARN(logger, message) { \
if (logger->isWarnEnabled()) {\
- logger->forcedLog(::log4cxx::Level::getWarn(), message,
LOG4CXX_LOCATION); }}
+ ::log4cxx::helpers::MessageBuffer buf; \
+ logger->forcedLog(::log4cxx::Level::getWarn(), buf.str(buf +
message), LOG4CXX_LOCATION); }}
/**
Logs a message to a specified logger with the ERROR level.
@@ -700,7 +707,8 @@
*/
#define LOG4CXX_ERROR(logger, message) { \
if (logger->isErrorEnabled()) {\
- logger->forcedLog(::log4cxx::Level::getError(), message,
LOG4CXX_LOCATION); }}
+ ::log4cxx::helpers::MessageBuffer buf; \
+ logger->forcedLog(::log4cxx::Level::getError(), buf.str(buf +
message), LOG4CXX_LOCATION); }}
/**
Logs a error if the condition is not true.
@@ -711,7 +719,8 @@
*/
#define LOG4CXX_ASSERT(logger, condition, message) { \
if (!(condition) && logger->isErrorEnabled()) {\
- logger->forcedLog(::log4cxx::Level::getError(), message,
LOG4CXX_LOCATION); }}
+ ::log4cxx::helpers::MessageBuffer buf; \
+ logger->forcedLog(::log4cxx::Level::getError(), buf.str(buf +
message), LOG4CXX_LOCATION); }}
/**
@@ -722,7 +731,8 @@
*/
#define LOG4CXX_FATAL(logger, message) { \
if (logger->isFatalEnabled()) {\
- logger->forcedLog(::log4cxx::Level::getFatal(), message,
LOG4CXX_LOCATION); }}
+ ::log4cxx::helpers::MessageBuffer buf; \
+ logger->forcedLog(::log4cxx::Level::getFatal(), buf.str(buf +
message), LOG4CXX_LOCATION); }}
/**
Logs a localized message with no parameter.
Modified: logging/log4cxx/trunk/src/test/cpp/Makefile.am
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/test/cpp/Makefile.am?rev=579071&r1=579070&r2=579071&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/test/cpp/Makefile.am (original)
+++ logging/log4cxx/trunk/src/test/cpp/Makefile.am Mon Sep 24 22:10:47 2007
@@ -48,6 +48,7 @@
helpers/inetaddresstestcase.cpp \
helpers/iso8601dateformattestcase.cpp \
helpers/localechanger.cpp\
+ helpers/messagebuffertest.cpp \
helpers/optionconvertertestcase.cpp \
helpers/propertiestestcase.cpp \
helpers/relativetimedateformattestcase.cpp \
Modified: logging/log4cxx/trunk/src/test/cpp/streamtestcase.cpp
URL:
http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/test/cpp/streamtestcase.cpp?rev=579071&r1=579070&r2=579071&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/test/cpp/streamtestcase.cpp (original)
+++ logging/log4cxx/trunk/src/test/cpp/streamtestcase.cpp Mon Sep 24 22:10:47
2007
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <log4cxx/logstring.h>
-#include <log4cxx/stream.h>
+#include <ostream>
+#include <iomanip>
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
@@ -42,7 +42,7 @@
::std::basic_ostream<Elem, Tr>& operator<<(
::std::basic_ostream<Elem, Tr>&,
const ExceptionOnInsert&) {
- throw "Should have been short-circuited";
+ throw std::exception();
}
@@ -52,19 +52,18 @@
class StreamTestCase : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(StreamTestCase);
- CPPUNIT_TEST(testConstructor);
CPPUNIT_TEST(testSimple);
- CPPUNIT_TEST(testSimpleWithFlush);
- CPPUNIT_TEST(testSimpleWithoutFlush);
CPPUNIT_TEST(testMultiple);
CPPUNIT_TEST(testShortCircuit);
+ CPPUNIT_TEST_EXCEPTION(testInsertException, std::exception);
CPPUNIT_TEST(testScientific);
CPPUNIT_TEST(testPrecision);
CPPUNIT_TEST(testWidth);
- CPPUNIT_TEST(testGetStream);
- CPPUNIT_TEST(testGetStreamDebug);
- CPPUNIT_TEST(testInsertLevel);
- CPPUNIT_TEST(testInsertLocation);
+#if LOG4CXX_HAS_WCHAR_T
+ CPPUNIT_TEST(testWide);
+ CPPUNIT_TEST(testWideAppend);
+ CPPUNIT_TEST(testWideScientific);
+#endif
CPPUNIT_TEST_SUITE_END();
VectorAppenderPtr vectorAppender;
@@ -82,58 +81,35 @@
LogManager::shutdown();
}
- void testConstructor() {
- LoggerPtr root(Logger::getRootLogger());
- log4cxx::logstream stream(root, log4cxx::Level::getInfo());
- CPPUNIT_ASSERT_EQUAL(0, (int) stream.width());
- CPPUNIT_ASSERT_EQUAL(6, (int) stream.precision());
- }
-
void testSimple() {
LoggerPtr root(Logger::getRootLogger());
- log4cxx::logstream stream(root, log4cxx::Level::getInfo());
- stream << "This is a test" << LOG4CXX_ENDMSG;
+ LOG4CXX_INFO(root, "This is a test");
CPPUNIT_ASSERT_EQUAL((size_t) 1,
vectorAppender->getVector().size());
}
- void testSimpleWithFlush() {
- LoggerPtr root(Logger::getRootLogger());
- log4cxx::logstream stream(root, log4cxx::Level::getInfo());
- stream << "This is a test\n";
- stream.flush();
- CPPUNIT_ASSERT_EQUAL((size_t) 1,
vectorAppender->getVector().size());
- }
-
- void testSimpleWithoutFlush() {
- LoggerPtr root(Logger::getRootLogger());
- log4cxx::logstream stream(root, log4cxx::Level::getInfo());
- stream << "This is a test\n";
- CPPUNIT_ASSERT_EQUAL((size_t) 0, vectorAppender->getVector().size());
- }
-
void testMultiple() {
LoggerPtr root(Logger::getRootLogger());
- log4cxx::logstream stream(root, log4cxx::Level::getInfo());
- stream << "This is a test" << LOG4CXX_ENDMSG;
- stream << "This is another test message" << LOG4CXX_ENDMSG;
- CPPUNIT_ASSERT_EQUAL((size_t) 2,
vectorAppender->getVector().size());
+ LOG4CXX_INFO(root, "This is a test" << ": Details to follow");
+ CPPUNIT_ASSERT_EQUAL((size_t) 1,
vectorAppender->getVector().size());
}
void testShortCircuit() {
LoggerPtr logger(Logger::getLogger("StreamTestCase.shortCircuit"));
- logger->setLevel(log4cxx::Level::getInfo());
- log4cxx::logstream stream(logger, log4cxx::Level::getDebug());
+ logger->setLevel(Level::getInfo());
ExceptionOnInsert someObj;
- stream << someObj << LOG4CXX_ENDMSG;
+ LOG4CXX_DEBUG(logger, someObj);
CPPUNIT_ASSERT_EQUAL((size_t) 0, vectorAppender->getVector().size());
}
+ void testInsertException() {
+ LoggerPtr logger(Logger::getLogger("StreamTestCase.insertException"));
+ ExceptionOnInsert someObj;
+ LOG4CXX_INFO(logger, someObj);
+ }
+
void testScientific() {
LoggerPtr root(Logger::getRootLogger());
- log4cxx::logstream stream(root, log4cxx::Level::getInfo());
- stream //<< std::scientific
- << 0.000001115
- << LOG4CXX_ENDMSG;
+ LOG4CXX_INFO(root, std::scientific << 0.000001115);
spi::LoggingEventPtr event(vectorAppender->getVector()[0]);
LogString msg(event->getMessage());
CPPUNIT_ASSERT(msg.find(LOG4CXX_STR("e-")) != LogString::npos ||
@@ -142,11 +118,7 @@
void testPrecision() {
LoggerPtr root(Logger::getRootLogger());
- log4cxx::logstream stream(root, log4cxx::Level::getInfo());
- stream.precision(4);
- stream << std::fixed
- << 1.000001
- << LOG4CXX_ENDMSG;
+ LOG4CXX_INFO(root, std::setprecision(4) << 1.000001);
spi::LoggingEventPtr event(vectorAppender->getVector()[0]);
LogString msg(event->getMessage());
CPPUNIT_ASSERT(msg.find(LOG4CXX_STR("1.00000")) == LogString::npos);
@@ -155,65 +127,33 @@
void testWidth() {
LoggerPtr root(Logger::getRootLogger());
- log4cxx::logstream stream(root, log4cxx::Level::getInfo());
- stream.width(5);
- stream.precision(2);
- stream << std::fixed
- << '[' << 10.0 << L']'
- << LOG4CXX_ENDMSG;
+ LOG4CXX_INFO(root, '[' << std::fixed << std::setprecision(2) <<
std::setw(7) << std::right << std::setfill('_') << 10.0 << ']');
spi::LoggingEventPtr event(vectorAppender->getVector()[0]);
LogString msg(event->getMessage());
- CPPUNIT_ASSERT(msg.find(LOG4CXX_STR("[10.00]")) == LogString::npos);
+ CPPUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("[__10.00]")), msg);
}
#if LOG4CXX_HAS_WCHAR_T
- void addMessage(std::wostream& os) {
- os << L"Hello, World";
- }
-#endif
-
- void addMessage(std::ostream& os) {
- os << "Hello, World";
- }
-
- void testGetStream() {
- LoggerPtr root(Logger::getRootLogger());
- log4cxx::logstream stream(root, log4cxx::Level::getInfo());
- addMessage(stream.getStream());
- stream << LOG4CXX_ENDMSG;
- spi::LoggingEventPtr event(vectorAppender->getVector()[0]);
- LogString msg(event->getMessage());
- CPPUNIT_ASSERT(msg.find(LOG4CXX_STR("Hello, World")) !=
LogString::npos);
- }
-
+ void testWide() {
+ LoggerPtr root(Logger::getRootLogger());
+ LOG4CXX_INFO(root, L"This is a test");
+ CPPUNIT_ASSERT_EQUAL((size_t) 1,
vectorAppender->getVector().size());
+ }
- void testGetStreamDebug() {
- LoggerPtr logger(Logger::getLogger("StreamTestCase.getStreamDebug"));
- logger->setLevel(log4cxx::Level::getInfo());
- log4cxx::logstream stream(logger, log4cxx::Level::getDebug());
- addMessage(stream.getStream());
- stream << LOG4CXX_ENDMSG;
- CPPUNIT_ASSERT_EQUAL((size_t) 0, vectorAppender->getVector().size());
+ void testWideAppend() {
+ LoggerPtr root(Logger::getRootLogger());
+ LOG4CXX_INFO(root, L"This is a test" << L": Details to follow");
+ CPPUNIT_ASSERT_EQUAL((size_t) 1,
vectorAppender->getVector().size());
}
-
-
- void testInsertLevel() {
- LoggerPtr logger(Logger::getLogger("StreamTestCase.insertLevel"));
- logger->setLevel(log4cxx::Level::getInfo());
- log4cxx::logstream stream(logger, log4cxx::Level::getDebug());
- stream
- << log4cxx::Level::getWarn()
- << "This message must get through"
- << LOG4CXX_ENDMSG;
- CPPUNIT_ASSERT_EQUAL((size_t) 1, vectorAppender->getVector().size());
- }
-
- void testInsertLocation() {
- LoggerPtr logger(Logger::getRootLogger());
- log4cxx::logstream stream(logger, log4cxx::Level::getDebug());
- stream << LOG4CXX_LOCATION;
+
+ void testWideWidth() {
+ LoggerPtr root(Logger::getRootLogger());
+ LOG4CXX_INFO(root, L'[' << std::fixed << std::setprecision(2) <<
std::setw(7) << std::right << std::setfill(L'_') << 10.0 << L']');
+ spi::LoggingEventPtr event(vectorAppender->getVector()[0]);
+ LogString msg(event->getMessage());
+ CPPUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("[__10.00]")), msg);
}
-
+#endif
};
CPPUNIT_TEST_SUITE_REGISTRATION(StreamTestCase);