mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-16 06:56:41 +02:00
added Poco::EventChannel class
This commit is contained in:
parent
62a79e0cda
commit
c22a36dc05
@ -13,7 +13,7 @@ objects = ArchiveStrategy Ascii ASCIIEncoding AsyncChannel \
|
|||||||
BinaryReader BinaryWriter Bugcheck ByteOrder Channel Checksum Clock Configurable ConsoleChannel \
|
BinaryReader BinaryWriter Bugcheck ByteOrder Channel Checksum Clock Configurable ConsoleChannel \
|
||||||
Condition CountingStream DateTime LocalDateTime DateTimeFormat DateTimeFormatter DateTimeParser \
|
Condition CountingStream DateTime LocalDateTime DateTimeFormat DateTimeFormatter DateTimeParser \
|
||||||
Debugger DeflatingStream DigestEngine DigestStream DirectoryIterator DirectoryWatcher \
|
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 \
|
FileChannel Formatter FormattingChannel Glob HexBinaryDecoder LineEndingConverter \
|
||||||
HexBinaryEncoder InflatingStream Latin1Encoding Latin2Encoding Latin9Encoding LogFile \
|
HexBinaryEncoder InflatingStream Latin1Encoding Latin2Encoding Latin9Encoding LogFile \
|
||||||
Logger LoggingFactory LoggingRegistry LogStream NamedEvent NamedMutex NullChannel \
|
Logger LoggingFactory LoggingRegistry LogStream NamedEvent NamedMutex NullChannel \
|
||||||
|
56
Foundation/include/Poco/EventChannel.h
Normal file
56
Foundation/include/Poco/EventChannel.h
Normal 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
|
39
Foundation/src/EventChannel.cpp
Normal file
39
Foundation/src/EventChannel.cpp
Normal 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
|
@ -22,6 +22,7 @@
|
|||||||
#include "Poco/FormattingChannel.h"
|
#include "Poco/FormattingChannel.h"
|
||||||
#include "Poco/SplitterChannel.h"
|
#include "Poco/SplitterChannel.h"
|
||||||
#include "Poco/NullChannel.h"
|
#include "Poco/NullChannel.h"
|
||||||
|
#include "Poco/EventChannel.h"
|
||||||
#if defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_NO_SYSLOGCHANNEL)
|
#if defined(POCO_OS_FAMILY_UNIX) && !defined(POCO_NO_SYSLOGCHANNEL)
|
||||||
#include "Poco/SyslogChannel.h"
|
#include "Poco/SyslogChannel.h"
|
||||||
#endif
|
#endif
|
||||||
@ -103,6 +104,7 @@ void LoggingFactory::registerBuiltins()
|
|||||||
_channelFactory.registerClass("SplitterChannel", new Instantiator<SplitterChannel, Channel>);
|
_channelFactory.registerClass("SplitterChannel", new Instantiator<SplitterChannel, Channel>);
|
||||||
#endif
|
#endif
|
||||||
_channelFactory.registerClass("NullChannel", new Instantiator<NullChannel, Channel>);
|
_channelFactory.registerClass("NullChannel", new Instantiator<NullChannel, Channel>);
|
||||||
|
_channelFactory.registerClass("EventChannel", new Instantiator<EventChannel, Channel>);
|
||||||
|
|
||||||
#if defined(POCO_OS_FAMILY_UNIX)
|
#if defined(POCO_OS_FAMILY_UNIX)
|
||||||
#ifndef POCO_NO_SYSLOGCHANNEL
|
#ifndef POCO_NO_SYSLOGCHANNEL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user