mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-23 08:52:31 +02:00
trunk/branch integration: Logger()
This commit is contained in:
parent
47f0c97f8e
commit
d224069050
@ -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)
|
void Logger::dump(const std::string& msg, const void* buffer, std::size_t length, Message::Priority prio)
|
||||||
{
|
{
|
||||||
if (_level >= prio && _pChannel)
|
if (_level >= prio && _pChannel)
|
||||||
@ -150,10 +156,13 @@ void Logger::setLevel(const std::string& name, int level)
|
|||||||
std::string::size_type len = name.length();
|
std::string::size_type len = name.length();
|
||||||
for (LoggerMap::iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it)
|
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);
|
it->second->setLevel(level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -166,10 +175,13 @@ void Logger::setChannel(const std::string& name, Channel* pChannel)
|
|||||||
std::string::size_type len = name.length();
|
std::string::size_type len = name.length();
|
||||||
for (LoggerMap::iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it)
|
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);
|
it->second->setChannel(pChannel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -182,10 +194,13 @@ void Logger::setProperty(const std::string& loggerName, const std::string& prope
|
|||||||
std::string::size_type len = loggerName.length();
|
std::string::size_type len = loggerName.length();
|
||||||
for (LoggerMap::iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it)
|
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);
|
it->second->setProperty(propertyName, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -445,10 +460,14 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void Logger::add(Logger* pLogger)
|
namespace
|
||||||
{
|
{
|
||||||
static AutoLoggerShutdown als;
|
static AutoLoggerShutdown als;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Logger::add(Logger* pLogger)
|
||||||
|
{
|
||||||
if (!_pLoggerMap)
|
if (!_pLoggerMap)
|
||||||
_pLoggerMap = new LoggerMap;
|
_pLoggerMap = new LoggerMap;
|
||||||
_pLoggerMap->insert(LoggerMap::value_type(pLogger->name(), pLogger));
|
_pLoggerMap->insert(LoggerMap::value_type(pLogger->name(), pLogger));
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
#if defined(POCO_OS_FAMILY_VMS)
|
#if defined(POCO_OS_FAMILY_VMS)
|
||||||
#include "Poco/OpcomChannel.h"
|
#include "Poco/OpcomChannel.h"
|
||||||
#endif
|
#endif
|
||||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(_WIN32_WCE)
|
||||||
#include "Poco/EventLogChannel.h"
|
#include "Poco/EventLogChannel.h"
|
||||||
#include "Poco/WindowsConsoleChannel.h"
|
#include "Poco/WindowsConsoleChannel.h"
|
||||||
#endif
|
#endif
|
||||||
@ -93,9 +93,14 @@ Formatter* LoggingFactory::createFormatter(const std::string& className) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LoggingFactory& LoggingFactory::defaultFactory()
|
namespace
|
||||||
{
|
{
|
||||||
static SingletonHolder<LoggingFactory> sh;
|
static SingletonHolder<LoggingFactory> sh;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LoggingFactory& LoggingFactory::defaultFactory()
|
||||||
|
{
|
||||||
return *sh.get();
|
return *sh.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,23 +108,29 @@ LoggingFactory& LoggingFactory::defaultFactory()
|
|||||||
void LoggingFactory::registerBuiltins()
|
void LoggingFactory::registerBuiltins()
|
||||||
{
|
{
|
||||||
_channelFactory.registerClass("AsyncChannel", new Instantiator<AsyncChannel, Channel>);
|
_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>);
|
_channelFactory.registerClass("ConsoleChannel", new Instantiator<WindowsConsoleChannel, Channel>);
|
||||||
#else
|
#else
|
||||||
_channelFactory.registerClass("ConsoleChannel", new Instantiator<ConsoleChannel, Channel>);
|
_channelFactory.registerClass("ConsoleChannel", new Instantiator<ConsoleChannel, Channel>);
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef POCO_NO_FILECHANNEL
|
||||||
_channelFactory.registerClass("FileChannel", new Instantiator<FileChannel, Channel>);
|
_channelFactory.registerClass("FileChannel", new Instantiator<FileChannel, Channel>);
|
||||||
|
#endif
|
||||||
_channelFactory.registerClass("FormattingChannel", new Instantiator<FormattingChannel, Channel>);
|
_channelFactory.registerClass("FormattingChannel", new Instantiator<FormattingChannel, Channel>);
|
||||||
|
#ifndef POCO_NO_SPLITTERCHANNEL
|
||||||
_channelFactory.registerClass("SplitterChannel", new Instantiator<SplitterChannel, Channel>);
|
_channelFactory.registerClass("SplitterChannel", new Instantiator<SplitterChannel, Channel>);
|
||||||
|
#endif
|
||||||
_channelFactory.registerClass("NullChannel", new Instantiator<NullChannel, Channel>);
|
_channelFactory.registerClass("NullChannel", new Instantiator<NullChannel, Channel>);
|
||||||
|
|
||||||
#if defined(POCO_OS_FAMILY_UNIX)
|
#if defined(POCO_OS_FAMILY_UNIX)
|
||||||
|
#ifndef POCO_NO_SYSLOGCHANNEL
|
||||||
_channelFactory.registerClass("SyslogChannel", new Instantiator<SyslogChannel, Channel>);
|
_channelFactory.registerClass("SyslogChannel", new Instantiator<SyslogChannel, Channel>);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#if defined(POCO_OS_FAMILY_VMS)
|
#if defined(POCO_OS_FAMILY_VMS)
|
||||||
_channelFactory.registerClass("OpcomChannel", new Instantiator<OpcomChannel, Channel>);
|
_channelFactory.registerClass("OpcomChannel", new Instantiator<OpcomChannel, Channel>);
|
||||||
#endif
|
#endif
|
||||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(_WIN32_WCE)
|
||||||
_channelFactory.registerClass("EventLogChannel", new Instantiator<EventLogChannel, Channel>);
|
_channelFactory.registerClass("EventLogChannel", new Instantiator<EventLogChannel, Channel>);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -124,9 +124,14 @@ void LoggingRegistry::clear()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LoggingRegistry& LoggingRegistry::defaultRegistry()
|
namespace
|
||||||
{
|
{
|
||||||
static SingletonHolder<LoggingRegistry> sh;
|
static SingletonHolder<LoggingRegistry> sh;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LoggingRegistry& LoggingRegistry::defaultRegistry()
|
||||||
|
{
|
||||||
return *sh.get();
|
return *sh.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user