mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-02-07 13:27:13 +01:00
Switched to POCO library for unified platform/library interface. Deprecated the external module API. It was creating more problems than solving. Removed most built-in libraries in favor of system libraries for easier maintenance. Cleaned and secured code with help from static analyzers.
106 lines
1.7 KiB
C++
106 lines
1.7 KiB
C++
//
|
|
// SplitterChannel.cpp
|
|
//
|
|
// Library: Foundation
|
|
// Package: Logging
|
|
// Module: SplitterChannel
|
|
//
|
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
|
// and Contributors.
|
|
//
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
//
|
|
|
|
|
|
#include "Poco/SplitterChannel.h"
|
|
#include "Poco/LoggingRegistry.h"
|
|
#include "Poco/StringTokenizer.h"
|
|
|
|
|
|
namespace Poco {
|
|
|
|
|
|
SplitterChannel::SplitterChannel()
|
|
{
|
|
}
|
|
|
|
|
|
SplitterChannel::~SplitterChannel()
|
|
{
|
|
try
|
|
{
|
|
close();
|
|
}
|
|
catch (...)
|
|
{
|
|
poco_unexpected();
|
|
}
|
|
}
|
|
|
|
|
|
void SplitterChannel::addChannel(Channel::Ptr pChannel)
|
|
{
|
|
poco_check_ptr (pChannel);
|
|
|
|
FastMutex::ScopedLock lock(_mutex);
|
|
_channels.push_back(pChannel);
|
|
}
|
|
|
|
|
|
void SplitterChannel::removeChannel(Channel::Ptr pChannel)
|
|
{
|
|
FastMutex::ScopedLock lock(_mutex);
|
|
|
|
for (ChannelVec::iterator it = _channels.begin(); it != _channels.end(); ++it)
|
|
{
|
|
if (*it == pChannel)
|
|
{
|
|
_channels.erase(it);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void SplitterChannel::setProperty(const std::string& name, const std::string& value)
|
|
{
|
|
if (name.compare(0, 7, "channel") == 0)
|
|
{
|
|
StringTokenizer tokenizer(value, ",;", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
|
|
for (StringTokenizer::Iterator it = tokenizer.begin(); it != tokenizer.end(); ++it)
|
|
{
|
|
addChannel(LoggingRegistry::defaultRegistry().channelForName(*it));
|
|
}
|
|
}
|
|
else Channel::setProperty(name, value);
|
|
}
|
|
|
|
|
|
void SplitterChannel::log(const Message& msg)
|
|
{
|
|
FastMutex::ScopedLock lock(_mutex);
|
|
|
|
for (auto& p: _channels)
|
|
{
|
|
p->log(msg);
|
|
}
|
|
}
|
|
|
|
|
|
void SplitterChannel::close()
|
|
{
|
|
FastMutex::ScopedLock lock(_mutex);
|
|
_channels.clear();
|
|
}
|
|
|
|
|
|
int SplitterChannel::count() const
|
|
{
|
|
FastMutex::ScopedLock lock(_mutex);
|
|
|
|
return (int) _channels.size();
|
|
}
|
|
|
|
|
|
} // namespace Poco
|