From 5f4108211d047da4b4702aa280cae9e2370e52b1 Mon Sep 17 00:00:00 2001 From: Andrei Savici <saviciat@ornl.gov> Date: Thu, 25 Apr 2013 13:17:01 -0400 Subject: [PATCH] Log channel for std::cout. Refs #6933 --- Code/Mantid/Framework/Kernel/CMakeLists.txt | 2 ++ .../Kernel/inc/MantidKernel/StdChannel.h | 16 ++++++++++++++++ .../Framework/Kernel/src/ConfigService.cpp | 4 ++++ Code/Mantid/Framework/Kernel/src/StdChannel.cpp | 12 ++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 Code/Mantid/Framework/Kernel/inc/MantidKernel/StdChannel.h create mode 100644 Code/Mantid/Framework/Kernel/src/StdChannel.cpp diff --git a/Code/Mantid/Framework/Kernel/CMakeLists.txt b/Code/Mantid/Framework/Kernel/CMakeLists.txt index 96d3beb6fe4..739416e925d 100644 --- a/Code/Mantid/Framework/Kernel/CMakeLists.txt +++ b/Code/Mantid/Framework/Kernel/CMakeLists.txt @@ -69,6 +69,7 @@ set ( SRC_FILES src/SobolSequence.cpp src/StartsWithValidator.cpp src/Statistics.cpp + src/StdChannel.cpp src/Strings.cpp src/TestChannel.cpp src/ThreadPool.cpp @@ -194,6 +195,7 @@ set ( INC_FILES inc/MantidKernel/SobolSequence.h inc/MantidKernel/StartsWithValidator.h inc/MantidKernel/Statistics.h + inc/MantidKernel/StdChannel.h inc/MantidKernel/Strings.h inc/MantidKernel/System.h inc/MantidKernel/Task.h diff --git a/Code/Mantid/Framework/Kernel/inc/MantidKernel/StdChannel.h b/Code/Mantid/Framework/Kernel/inc/MantidKernel/StdChannel.h new file mode 100644 index 00000000000..92950ae740f --- /dev/null +++ b/Code/Mantid/Framework/Kernel/inc/MantidKernel/StdChannel.h @@ -0,0 +1,16 @@ +#ifndef STDCHANNEL_H +#define STDCHANNEL_H + +#include <MantidKernel/DllConfig.h> +#include <Poco/ConsoleChannel.h> +namespace Poco{ +class MANTID_KERNEL_DLL StdChannel : public ConsoleChannel +{ + public: + /// Constructor for StdChannel + StdChannel(); + /// destructor + ~StdChannel(); +}; +} +#endif // STDCHANNEL_H diff --git a/Code/Mantid/Framework/Kernel/src/ConfigService.cpp b/Code/Mantid/Framework/Kernel/src/ConfigService.cpp index 15b6a9d480a..126ccc373b2 100644 --- a/Code/Mantid/Framework/Kernel/src/ConfigService.cpp +++ b/Code/Mantid/Framework/Kernel/src/ConfigService.cpp @@ -7,6 +7,7 @@ #include "MantidKernel/Strings.h" #include "MantidKernel/Logger.h" #include "MantidKernel/FilterChannel.h" +#include "MantidKernel/StdChannel.h" #include "MantidKernel/Exception.h" #include "MantidKernel/FacilityInfo.h" @@ -182,6 +183,9 @@ ConfigServiceImpl::ConfigServiceImpl() : //Register the FilterChannel with the Poco logging factory Poco::LoggingFactory::defaultFactory().registerChannelClass("FilterChannel", new Poco::Instantiator< Poco::FilterChannel, Poco::Channel>); + //Register StdChannel with Poco + Poco::LoggingFactory::defaultFactory().registerChannelClass("StdChannel", new Poco::Instantiator< + Poco::StdChannel, Poco::Channel>); // Define the directory to search for the Mantid.properties file. Poco::File f; diff --git a/Code/Mantid/Framework/Kernel/src/StdChannel.cpp b/Code/Mantid/Framework/Kernel/src/StdChannel.cpp new file mode 100644 index 00000000000..588ae6ed60d --- /dev/null +++ b/Code/Mantid/Framework/Kernel/src/StdChannel.cpp @@ -0,0 +1,12 @@ +#include <MantidKernel/StdChannel.h> +#include <iostream> + +namespace Poco { +StdChannel::StdChannel():ConsoleChannel(std::cout) +{ +} +StdChannel::~StdChannel() +{ +} + +} -- GitLab