|
|
Choosing A Webhost: |
CVS update of carob/src (Common.cpp): msg#00114db.carob.cvs
Date: Tuesday, February 28, 2006 @ 11:59:54 Author: gilles Path: /cvsroot/carob/carob/src Modified: Common.cpp (1.25 -> 1.26) Added double check on logLevel before logging Removed common logging function that has become obsolete since log4cxx addition ------------+ Common.cpp | 102 ++++++++++++++++++++++++++--------------------------------- 1 files changed, 46 insertions(+), 56 deletions(-) Index: carob/src/Common.cpp diff -u carob/src/Common.cpp:1.25 carob/src/Common.cpp:1.26 --- carob/src/Common.cpp:1.25 Tue Feb 14 18:35:47 2006 +++ carob/src/Common.cpp Tue Feb 28 11:59:54 2006 @@ -64,57 +64,6 @@ #define NAME_OF_ANY_UTF8_LOCALE_AVAILABLE "en_US.utf8" -namespace { - inline void - carobLog(const CarobNS::LogLevel& level, const wstring& fctName, const wstring& msg) - { -#ifdef CAROB_USE_LOG4CXX - // Log4cxx <= 0.9.7 doesn't accept wstrings - we have to convert the string - std::string tmp = CarobNS::StaticCodecs::toString(fctName + L": " + msg); -#endif - if (level == CarobNS::LOG_LEVEL_DEBUG) - { -#ifdef CAROB_USE_LOG4CXX - LOG4CXX_DEBUG(logger, tmp); -#else - wcerr << DEBUG_PRE << L'(' << fctName << L") " << msg << endl; -#endif - } - else if (level == CarobNS::LOG_LEVEL_INFO) - { -#ifdef CAROB_USE_LOG4CXX - LOG4CXX_INFO(logger, tmp); -#else - wcerr << INFO_PRE << L'(' << fctName << L") " << msg << endl; -#endif - } - else if (level == CarobNS::LOG_LEVEL_WARN) - { -#ifdef CAROB_USE_LOG4CXX - LOG4CXX_WARN(logger, tmp); -#else - wcerr << WARN_PRE << L'(' << fctName << L") " << msg << endl; -#endif - } - else if (level == CarobNS::LOG_LEVEL_ERROR) - { -#ifdef CAROB_USE_LOG4CXX - LOG4CXX_ERROR(logger, tmp); -#else - wcerr << ERROR_PRE << L'(' << fctName << L") " << msg << endl; -#endif - } - else //if (level == CarobNS::LOG_LEVEL_FATAL) - { -#ifdef CAROB_USE_LOG4CXX - LOG4CXX_FATAL(logger, tmp); -#else - wcerr << FATAL_PRE << L'(' << fctName << L") " << msg << endl; -#endif - } - } -} - void CarobNS::setLogLevel(const LogLevel l) { #ifdef CAROB_USE_LOG4CXX @@ -136,23 +85,64 @@ void CarobNS::logDebug(const wstring& fctName, const wstring& s) { - carobLog(LOG_LEVEL_DEBUG, fctName, s); + if (isDebugEnabled()) + { +#ifdef CAROB_USE_LOG4CXX + // Log4cxx <= 0.9.7 doesn't accept wstrings - we have to convert the string + std::string tmp = CarobNS::StaticCodecs::toString(fctName + L": " + s); + LOG4CXX_DEBUG(logger, tmp); +#else + wcerr << DEBUG_PRE << L'(' << fctName << L") " << s << endl; +#endif + } } void CarobNS::logInfo(const wstring& fctName, const wstring& s) { - carobLog(LOG_LEVEL_INFO, fctName, s); + if (isInfoEnabled()) + { +#ifdef CAROB_USE_LOG4CXX + std::string tmp = CarobNS::StaticCodecs::toString(fctName + L": " + s); + LOG4CXX_INFO(logger, tmp); +#else + wcerr << INFO_PRE << L'(' << fctName << L") " << s << endl; +#endif + } } void CarobNS::logWarn(const wstring& fctName, const wstring& s) { - carobLog(LOG_LEVEL_WARN, fctName, s); + if (isWarnEnabled()) + { +#ifdef CAROB_USE_LOG4CXX + std::string tmp = CarobNS::StaticCodecs::toString(fctName + L": " + s); + LOG4CXX_WARN(logger, tmp); +#else + wcerr << WARN_PRE << L'(' << fctName << L") " << s << endl; +#endif + } } void CarobNS::logError(const wstring& fctName, const wstring& s) { - carobLog(LOG_LEVEL_ERROR, fctName, s); + if (isErrorEnabled()) + { +#ifdef CAROB_USE_LOG4CXX + std::string tmp = CarobNS::StaticCodecs::toString(fctName + L": " + s); + LOG4CXX_ERROR(logger, tmp); +#else + wcerr << ERROR_PRE << L'(' << fctName << L") " << s << endl; +#endif + } } void CarobNS::logFatal(const wstring& fctName, const wstring& s) { - carobLog(LOG_LEVEL_FATAL, fctName, s); + if (isFatalEnabled()) + { +#ifdef CAROB_USE_LOG4CXX + std::string tmp = CarobNS::StaticCodecs::toString(fctName + L": " + s); + LOG4CXX_FATAL(logger, tmp); +#else + wcerr << FATAL_PRE << L'(' << fctName << L") " << s << endl; +#endif + } } bool CarobNS::isDebugEnabled()
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | CVS update of libmysequoia (3 files), csaba-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
|---|---|
| Next by Date: | CVS update of libmysequoia/src (CarobMySQL.cpp), csaba-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Previous by Thread: | CVS update of carob/include (2 files), gilles-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Next by Thread: | CVS update of carob/include (CarobException.hpp), marc-Tt5JLJuBijYiZlD9aYmxOGD2FQJk+8+b |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home
| advertise | OSDir is
an inevitable website.
|