From: <ibr...@us...> - 2010-07-09 14:44:37
|
Revision: 3618 http://tora.svn.sourceforge.net/tora/?rev=3618&view=rev Author: ibre5041 Date: 2010-07-09 14:44:31 +0000 (Fri, 09 Jul 2010) Log Message: ----------- Support for "null" sink logger. Note: this commit adds dependency on boost library Modified Paths: -------------- trunk/tora/src/tologger.h Modified: trunk/tora/src/tologger.h =================================================================== --- trunk/tora/src/tologger.h 2010-07-09 14:04:38 UTC (rev 3617) +++ trunk/tora/src/tologger.h 2010-07-09 14:44:31 UTC (rev 3618) @@ -11,6 +11,11 @@ #include <iostream> +#include <boost/iostreams/device/null.hpp> +#include <boost/iostreams/stream.hpp> +using namespace boost; +using namespace boost::iostreams; + typedef Tdecorator< TSLOG_TYPELIST_6(dashDecorator<4>, tidDecorator<qt_thread_manager>, @@ -20,14 +25,49 @@ charDecorator<'\n'> )> toDecorator; + +struct s_null_sink : public boost::iostreams::stream_buffer<boost::iostreams::null_sink> +{ + s_null_sink() + { + open(boost::iostreams::null_sink() ); + } +}; + template< int idxLog> -thread_safe_log templ_get_log_ownthread( int_to_type< idxLog> * = NULL ) +inline thread_safe_log templ_get_log_ownthread( int_to_type< idxLog> * = NULL ) { /* static std::ofstream out( get_out_name< idxLog>( false).c_str() ); */ +#ifdef DEBUG static internal_thread_safe_log_ownthread log( std::cout ); +#else + static s_null_sink nsink; + static std::ostream out(&nsink); + static internal_thread_safe_log_ownthread log( out ); +#endif return thread_safe_log( log); } +// tonoblockquery<3> - debugging(disabled) +template<> +inline thread_safe_log templ_get_log_ownthread(int_to_type<3>*) +{ + static s_null_sink nsink; + static std::ostream out(&nsink); + static internal_thread_safe_log_ownthread log( out ); + return thread_safe_log( log); +} + +// tonoblockquery<4> - data read(disabled) +template<> +inline thread_safe_log templ_get_log_ownthread(int_to_type<4>*) +{ + static s_null_sink nsink; + static std::ostream out(&nsink); + static internal_thread_safe_log_ownthread log( out ); + return thread_safe_log( log); +} + /* thread_safe_log templ_get_log_ownthread<1>( int_to_type< 1> * = NULL ) { @@ -44,6 +84,8 @@ case 0: return templ_get_log_ownthread< 0>(); // tooracleconnection log case 1: return templ_get_log_ownthread< 1>(); // exception log case 2: return templ_get_log_ownthread< 2>(); // qDebug log + case 3: return templ_get_log_ownthread< 3>(); // tonoblockquery log + case 4: return templ_get_log_ownthread< 4>(); // data read log default: assert( false); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |