added Poco::EventChannel class

This commit is contained in:
Guenter Obiltschnig 2016-02-29 21:53:17 +01:00
parent 62a79e0cda
commit c22a36dc05
4 changed files with 98 additions and 1 deletions

View File

@ -13,7 +13,7 @@ objects = ArchiveStrategy Ascii ASCIIEncoding AsyncChannel \
BinaryReader BinaryWriter Bugcheck ByteOrder Channel Checksum Clock Configurable ConsoleChannel \
Condition CountingStream DateTime LocalDateTime DateTimeFormat DateTimeFormatter DateTimeParser \
Debugger DeflatingStream DigestEngine DigestStream DirectoryIterator DirectoryWatcher \
Environment Event Error EventArgs ErrorHandler Exception FIFOBufferStream FPEnvironment File \
Environment Event EventChannel Error EventArgs ErrorHandler Exception FIFOBufferStream FPEnvironment File \
FileChannel Formatter FormattingChannel Glob HexBinaryDecoder LineEndingConverter \
HexBinaryEncoder InflatingStream Latin1Encoding Latin2Encoding Latin9Encoding LogFile \
Logger LoggingFactory LoggingRegistry LogStream NamedEvent NamedMutex NullChannel \

View File

@ -0,0 +1,56 @@
//
// EventChannel.h
//
// $Id$
//
// Library: Foundation
// Package: Logging
// Module: EventChannel
//
// Definition of the EventChannel class.
//
// Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Foundation_EventChannel_INCLUDED
#define Foundation_EventChannel_INCLUDED
#include "Poco/Foundation.h"
#include "Poco/Channel.h"
#include "Poco/Message.h"
#include "Poco/BasicEvent.h"
namespace Poco {
class Foundation_API EventChannel: public Channel
/// The EventChannel fires the messageLogged event for every log message
/// received. This can be used to hook custom log message processing into
/// the logging framework.
{
public:
Poco::BasicEvent<const Message> messageLogged;
/// Fired when a message is logged by calling the log() method.
EventChannel();
/// Creates the EventChannel.
void log(const Message& msg);
/// Fires the messageLogged event.
protected:
~EventChannel();
/// Destroys the EventChannel.
};
} // namespace Poco
#endif // Foundation_EventChannel_INCLUDED

View File

@ -0,0 +1,39 @@
//
// EventChannel.cpp
//
// $Id$
//
// Library: Foundation
// Package: Logging
// Module: EventChannel
//
// Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/EventChannel.h"
namespace Poco {
EventChannel::EventChannel()
{
}
EventChannel::~EventChannel()
{
}
void EventChannel::log(const Message& msg)
{
messageLogged(this, msg);
}
} // namespace Poco

View File

@ -22,6 +22,7 @@
#include "Poco/FormattingChannel.h"
#include "Poco/SplitterChannel.h"
#include "Poco/NullChannel.h"
#include "Poco/EventChannel.h"
#if defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_NO_SYSLOGCHANNEL)
#include "Poco/SyslogChannel.h"
#endif
@ -103,6 +104,7 @@ void LoggingFactory::registerBuiltins()
_channelFactory.registerClass("SplitterChannel", new Instantiator<SplitterChannel, Channel>);
#endif
_channelFactory.registerClass("NullChannel", new Instantiator<NullChannel, Channel>);
_channelFactory.registerClass("EventChannel", new Instantiator<EventChannel, Channel>);
#if defined(POCO_OS_FAMILY_UNIX)
#ifndef POCO_NO_SYSLOGCHANNEL