trunk/branch integration: Logger()

This commit is contained in:
Marian Krivos 2011-08-22 17:09:02 +00:00
parent 47f0c97f8e
commit d224069050
3 changed files with 44 additions and 9 deletions

View File

@ -130,6 +130,12 @@ void Logger::log(const Exception& exc)
}
void Logger::log(const Exception& exc, const char* file, int line)
{
error(exc.displayText(), file, line);
}
void Logger::dump(const std::string& msg, const void* buffer, std::size_t length, Message::Priority prio)
{
if (_level >= prio && _pChannel)
@ -150,8 +156,11 @@ void Logger::setLevel(const std::string& name, int level)
std::string::size_type len = name.length();
for (LoggerMap::iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it)
{
if (len == 0 || it->first.compare(0, len, name) == 0 && (it->first.length() == len || it->first[len] == '.'))
if (len == 0 ||
(it->first.compare(0, len, name) == 0 && (it->first.length() == len || it->first[len] == '.')))
{
it->second->setLevel(level);
}
}
}
}
@ -166,8 +175,11 @@ void Logger::setChannel(const std::string& name, Channel* pChannel)
std::string::size_type len = name.length();
for (LoggerMap::iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it)
{
if (len == 0 || it->first.compare(0, len, name) == 0 && (it->first.length() == len || it->first[len] == '.'))
if (len == 0 ||
(it->first.compare(0, len, name) == 0 && (it->first.length() == len || it->first[len] == '.')))
{
it->second->setChannel(pChannel);
}
}
}
}
@ -182,8 +194,11 @@ void Logger::setProperty(const std::string& loggerName, const std::string& prope
std::string::size_type len = loggerName.length();
for (LoggerMap::iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it)
{
if (len == 0 || it->first.compare(0, len, loggerName) == 0 && (it->first.length() == len || it->first[len] == '.'))
if (len == 0 ||
(it->first.compare(0, len, loggerName) == 0 && (it->first.length() == len || it->first[len] == '.')))
{
it->second->setProperty(propertyName, value);
}
}
}
}
@ -445,10 +460,14 @@ public:
};
void Logger::add(Logger* pLogger)
namespace
{
static AutoLoggerShutdown als;
}
void Logger::add(Logger* pLogger)
{
if (!_pLoggerMap)
_pLoggerMap = new LoggerMap;
_pLoggerMap->insert(LoggerMap::value_type(pLogger->name(), pLogger));

View File

@ -48,7 +48,7 @@
#if defined(POCO_OS_FAMILY_VMS)
#include "Poco/OpcomChannel.h"
#endif
#if defined(POCO_OS_FAMILY_WINDOWS)
#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(_WIN32_WCE)
#include "Poco/EventLogChannel.h"
#include "Poco/WindowsConsoleChannel.h"
#endif
@ -93,9 +93,14 @@ Formatter* LoggingFactory::createFormatter(const std::string& className) const
}
LoggingFactory& LoggingFactory::defaultFactory()
namespace
{
static SingletonHolder<LoggingFactory> sh;
}
LoggingFactory& LoggingFactory::defaultFactory()
{
return *sh.get();
}
@ -103,23 +108,29 @@ LoggingFactory& LoggingFactory::defaultFactory()
void LoggingFactory::registerBuiltins()
{
_channelFactory.registerClass("AsyncChannel", new Instantiator<AsyncChannel, Channel>);
#if defined(POCO_OS_FAMILY_WINDOWS)
#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(_WIN32_WCE)
_channelFactory.registerClass("ConsoleChannel", new Instantiator<WindowsConsoleChannel, Channel>);
#else
_channelFactory.registerClass("ConsoleChannel", new Instantiator<ConsoleChannel, Channel>);
#endif
#ifndef POCO_NO_FILECHANNEL
_channelFactory.registerClass("FileChannel", new Instantiator<FileChannel, Channel>);
#endif
_channelFactory.registerClass("FormattingChannel", new Instantiator<FormattingChannel, Channel>);
#ifndef POCO_NO_SPLITTERCHANNEL
_channelFactory.registerClass("SplitterChannel", new Instantiator<SplitterChannel, Channel>);
#endif
_channelFactory.registerClass("NullChannel", new Instantiator<NullChannel, Channel>);
#if defined(POCO_OS_FAMILY_UNIX)
#ifndef POCO_NO_SYSLOGCHANNEL
_channelFactory.registerClass("SyslogChannel", new Instantiator<SyslogChannel, Channel>);
#endif
#endif
#if defined(POCO_OS_FAMILY_VMS)
_channelFactory.registerClass("OpcomChannel", new Instantiator<OpcomChannel, Channel>);
#endif
#if defined(POCO_OS_FAMILY_WINDOWS)
#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(_WIN32_WCE)
_channelFactory.registerClass("EventLogChannel", new Instantiator<EventLogChannel, Channel>);
#endif

View File

@ -124,9 +124,14 @@ void LoggingRegistry::clear()
}
LoggingRegistry& LoggingRegistry::defaultRegistry()
namespace
{
static SingletonHolder<LoggingRegistry> sh;
}
LoggingRegistry& LoggingRegistry::defaultRegistry()
{
return *sh.get();
}