[prev in list] [next in list] [prev in thread] [next in thread]
List: log4cxx-dev
Subject: svn commit: r577896 - in /logging/log4cxx/trunk/src: main/cpp/level.cpp
From: carnold () apache ! org
Date: 2007-09-20 19:52:02
Message-ID: 20070920195205.0B9871A9832 () eris ! apache ! org
[Download RAW message or body]
Author: carnold
Date: Thu Sep 20 12:52:01 2007
New Revision: 577896
URL: http://svn.apache.org/viewvc?rev=577896&view=rev
Log:
LOGCXX-86: Add Trace Level
Modified:
logging/log4cxx/trunk/src/main/cpp/level.cpp
logging/log4cxx/trunk/src/main/include/log4cxx/level.h
logging/log4cxx/trunk/src/main/include/log4cxx/logger.h
logging/log4cxx/trunk/src/test/cpp/leveltestcase.cpp
Modified: logging/log4cxx/trunk/src/main/cpp/level.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/cpp/level.cpp?rev=577896&r1=577895&r2=577896&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/cpp/level.cpp (original)
+++ logging/log4cxx/trunk/src/main/cpp/level.cpp Thu Sep 20 12:52:01 2007
@@ -56,6 +56,12 @@
return level;
}
+const LevelPtr& Level::getTrace() {
+ static LevelPtr level(new Level(Level::TRACE_INT, LOG4CXX_STR("TRACE"), 7));
+ return level;
+}
+
+
const LevelPtr& Level::getAll() {
static LevelPtr level(new Level(Level::ALL_INT, LOG4CXX_STR("ALL"), 7));
return level;
@@ -94,6 +100,7 @@
{
case ALL_INT: return getAll();
case DEBUG_INT: return getDebug();
+ case TRACE_INT: return getTrace();
case INFO_INT: return getInfo();
case WARN_INT: return getWarn();
case ERROR_INT: return getError();
@@ -119,6 +126,9 @@
if (StringHelper::equalsIgnoreCase(sArg, "DEBUG", "debug")) {
return getDebug();
}
+ if (StringHelper::equalsIgnoreCase(sArg, "TRACE", "trace")) {
+ return getTrace();
+ }
if (StringHelper::equalsIgnoreCase(sArg, "ERROR", "error")) {
return getError();
}
@@ -156,6 +166,9 @@
if (len == 5) {
if (StringHelper::equalsIgnoreCase(sArg, L"DEBUG", L"debug")) {
return getDebug();
+ }
+ if (StringHelper::equalsIgnoreCase(sArg, L"TRACE", L"trace")) {
+ return getTrace();
}
if (StringHelper::equalsIgnoreCase(sArg, L"ERROR", L"error")) {
return getError();
Modified: logging/log4cxx/trunk/src/main/include/log4cxx/level.h
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/main/include/log4cxx/level.h?rev=577896&r1=577895&r2=577896&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/include/log4cxx/level.h (original)
+++ logging/log4cxx/trunk/src/main/include/log4cxx/level.h Thu Sep 20 12:52:01 2007
@@ -121,6 +121,7 @@
static const LevelPtr& getWarn();
static const LevelPtr& getInfo();
static const LevelPtr& getDebug();
+ static const LevelPtr& getTrace();
static const LevelPtr& getOff();
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=577896&r1=577895&r2=577896&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/main/include/log4cxx/logger.h (original)
+++ logging/log4cxx/trunk/src/main/include/log4cxx/logger.h Thu Sep 20 12:52:01 2007
@@ -445,6 +445,15 @@
bool isFatalEnabled() const;
/**
+ Check whether this logger is enabled for the trace level.
+ See also #isDebugEnabled.
+
+ @return bool - <code>true</code> if this logger is enabled
+ for level trace, <code>false</code> otherwise.
+ */
+ bool isTraceEnabled() const;
+
+ /**
Log a localized and parameterized message.
First, the user supplied
@@ -539,15 +548,10 @@
public:
/**
- Set the level of this Logger. If you are passing any of
- <code>Level#DEBUG</code>, <code>Level#INFO</code>,
- <code>Level#WARN</code>, <code>Level#ERROR</code>,
- <code>Level#FATAL</code> as a parameter, you need to case them as
- Level.
+ Set the level of this Logger.
<p>As in <pre> logger->setLevel(Level::getDebug()); </pre>
-
<p>Null values are admitted. */
virtual void setLevel(const LevelPtr& level);
@@ -578,7 +582,26 @@
void warn(const std::string& msg, const log4cxx::spi::LocationInfo& \
location); void warn(const std::string& msg);
+ /**
+ Log a message string with the {@link Level#TRACE TRACE} level.
+ <p>This method first checks if this logger is <code>TRACE</code>
+ enabled by comparing the level of this logger with the {@link
+ Level#TRACE TRACE} level. If this logger is
+ <code>TRACE</code> enabled, it proceeds to call all the
+ registered appenders in this logger and also higher in the
+ hierarchy depending on the value of the additivity flag.
+
+ @param message the message string to log.
+ @param file the file where the log statement was written.
+ @param line the line where the log statement was written.
+ */
+#if LOG4CXX_HAS_WCHAR_T
+ void trace(const std::wstring& msg, const log4cxx::spi::LocationInfo& \
location); + void trace(const std::wstring& msg);
+#endif
+ void trace(const std::string& msg, const log4cxx::spi::LocationInfo& \
location); + void trace(const std::string& msg);
inline const log4cxx::helpers::Mutex& getMutex() const { return mutex; }
@@ -637,6 +660,17 @@
#define LOG4CXX_DEBUG(logger, message) { \
if (LOG4CXX_UNLIKELY(logger->isDebugEnabled())) {\
logger->forcedLog(::log4cxx::Level::getDebug(), message, \
LOG4CXX_LOCATION); }} +
+/**
+Logs a message to a specified logger with the TRACE level.
+
+@param logger the logger to be used.
+@param message the message string to log.
+*/
+#define LOG4CXX_TRACE(logger, message) { \
+ if (LOG4CXX_UNLIKELY(logger->isTraceEnabled())) {\
+ logger->forcedLog(::log4cxx::Level::getTrace(), message, \
LOG4CXX_LOCATION); }} +
/**
Logs a message to a specified logger with the INFO level.
Modified: logging/log4cxx/trunk/src/test/cpp/leveltestcase.cpp
URL: http://svn.apache.org/viewvc/logging/log4cxx/trunk/src/test/cpp/leveltestcase.cpp?rev=577896&r1=577895&r2=577896&view=diff
==============================================================================
--- logging/log4cxx/trunk/src/test/cpp/leveltestcase.cpp (original)
+++ logging/log4cxx/trunk/src/test/cpp/leveltestcase.cpp Thu Sep 20 12:52:01 2007
@@ -29,6 +29,13 @@
{
CPPUNIT_TEST_SUITE(LevelTestCase);
CPPUNIT_TEST(testToLevelFatal);
+ CPPUNIT_TEST(testTraceInt);
+ CPPUNIT_TEST(testTrace);
+ CPPUNIT_TEST(testIntToTrace);
+ CPPUNIT_TEST(testStringToTrace);
+#if LOG4CXX_HAS_WCHAR_T
+ CPPUNIT_TEST(testWideStringToTrace);
+#endif
CPPUNIT_TEST_SUITE_END();
public:
@@ -37,6 +44,49 @@
LevelPtr level(Level::toLevel(LOG4CXX_TEST_STR("fATal")));
CPPUNIT_ASSERT_EQUAL((int) Level::FATAL_INT, level->toInt());
}
+
+ /**
+ * Tests Level::TRACE_INT.
+ */
+ void testTraceInt() {
+ CPPUNIT_ASSERT_EQUAL(5000, (int) Level::TRACE_INT);
+ }
+
+ /**
+ * Tests Level.TRACE.
+ */
+ void testTrace() {
+ CPPUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("TRACE")), \
Level::getTrace()->toString()); + CPPUNIT_ASSERT_EQUAL(5000, \
Level::getTrace()->toInt()); + CPPUNIT_ASSERT_EQUAL(7, \
Level::getTrace()->getSyslogEquivalent()); + }
+
+ /**
+ * Tests Level.toLevel(Level.TRACE_INT).
+ */
+ void testIntToTrace() {
+ LevelPtr trace(Level::toLevel(5000));
+ CPPUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("TRACE")), trace->toString());
+ }
+
+ /**
+ * Tests Level.toLevel("TRACE");
+ */
+ void testStringToTrace() {
+ LevelPtr trace(Level::toLevel("TRACE"));
+ CPPUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("TRACE")), trace->toString());
+ }
+
+#if LOG4CXX_HAS_WCHAR_T
+ /**
+ * Tests Level.toLevel(L"TRACE");
+ */
+ void testWideStringToTrace() {
+ LevelPtr trace(Level::toLevel(L"TRACE"));
+ CPPUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("TRACE")), trace->toString());
+ }
+#endif
+
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic