Boost logo

Boost-Commit :

From: john.groups_at_[hidden]
Date: 2007-11-09 23:44:17


Author: jtorjo
Date: 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
New Revision: 40980
URL: http://svn.boost.org/trac/boost/changeset/40980

Log:
[logging]
v0.11.5, 11 nov 2007
- applied patch from Jens Seidel - many thanks!
- added tags - need to document them

Added:
   sandbox/logging/boost/logging/format/formatter/tags.hpp (contents, props changed)
   sandbox/logging/boost/logging/tag/
   sandbox/logging/boost/logging/tag/defaults.hpp (contents, props changed)
   sandbox/logging/boost/logging/tags.hpp (contents, props changed)
Text files modified:
   sandbox/logging/boost/logging/detail/find_gather.hpp | 27 ++++++++-
   sandbox/logging/boost/logging/detail/format_msg_type.hpp | 2
   sandbox/logging/boost/logging/detail/fwd.hpp | 2
   sandbox/logging/boost/logging/detail/logger.hpp | 2
   sandbox/logging/boost/logging/detail/tss/tss.hpp | 12 ----
   sandbox/logging/boost/logging/detail/tss/tss_impl_pthread.hpp | 2
   sandbox/logging/boost/logging/detail/use_format_write.hpp | 2
   sandbox/logging/boost/logging/format.hpp | 4
   sandbox/logging/boost/logging/format/formatter/convert_format.hpp | 29 ++++++++++
   sandbox/logging/boost/logging/format/formatter/defaults.hpp | 6 +-
   sandbox/logging/boost/logging/format/formatter/thread_id.hpp | 4
   sandbox/logging/boost/logging/format/formatter/time.hpp | 16 +++---
   sandbox/logging/boost/logging/format/optimize.hpp | 2
   sandbox/logging/boost/logging/macros.hpp | 29 ++++++++++
   sandbox/logging/boost/logging/process_msg/ostream_like.hpp | 65 ++++++++++++-----------
   sandbox/logging/boost/logging/scenario.hpp | 12 ++--
   sandbox/logging/boost/logging/writer/on_dedicated_thread.hpp | 7 +
   sandbox/logging/lib/logging/internal/vc8/loggingvc8/loggingvc8.vcproj | 29 ++++++----
   sandbox/logging/lib/logging/tests/do_not_use/format/test_manip_w_msgroute.cpp | 2
   sandbox/logging/lib/logging/tests/do_not_use/format/test_simple_formatter.cpp | 2
   sandbox/logging/lib/logging/tests/do_not_use/testfast.cpp | 106 ++++++++++++---------------------------
   21 files changed, 196 insertions(+), 166 deletions(-)

Modified: sandbox/logging/boost/logging/detail/find_gather.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/find_gather.hpp (original)
+++ sandbox/logging/boost/logging/detail/find_gather.hpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -28,10 +28,22 @@
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // specialize logger for format_write class
     //
+ template<
+ class string_ ,
+ class param1 ,
+ class param2 ,
+ class param3 ,
+ class param4 ,
+ class param5 ,
+ class param6 ,
+ class param7 ,
+ class param8 ,
+ class param9 ,
+ class param10> struct tag_holder ;
 
     namespace gather { namespace ostream_like {
- template<class> struct return_str ;
- template<class, class> struct return_cache_str ;
+ template<class, class> struct return_str ;
+ template<class holder_type, class stream_type> struct return_tag_holder ;
     }}
 
     namespace optimize {
@@ -41,18 +53,23 @@
 
     namespace detail {
         template<class param> struct find_gather {};
- template<> struct find_gather< std::basic_string<char_type> > { typedef gather::ostream_like::return_str< std::basic_ostringstream<char_type> > type ; };
+ template<> struct find_gather< std::basic_string<char_type> > { typedef gather::ostream_like::return_str< std::basic_string<char_type>, std::basic_ostringstream<char_type> > type ; };
 
         template< class string_type>
         struct find_gather< boost::logging::optimize::cache_string_one_str<string_type> > {
- typedef gather::ostream_like::return_cache_str< boost::logging::optimize::cache_string_one_str<string_type>, std::basic_ostringstream<char_type> > type;
+ typedef gather::ostream_like::return_str< boost::logging::optimize::cache_string_one_str<string_type>, std::basic_ostringstream<char_type> > type;
         };
 
         template< class string_type>
         struct find_gather< boost::logging::optimize::cache_string_several_str<string_type,void*> > {
- typedef gather::ostream_like::return_cache_str< boost::logging::optimize::cache_string_several_str<string_type,void*>, std::basic_ostringstream<char_type> > type;
+ typedef gather::ostream_like::return_str< boost::logging::optimize::cache_string_several_str<string_type,void*>, std::basic_ostringstream<char_type> > type;
         };
 
+
+ template<class string, class p1, class p2, class p3, class p4, class p5, class p6, class p7, class p8, class p9, class p10>
+ struct find_gather< tag_holder<string,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10> > {
+ typedef gather::ostream_like::return_tag_holder< tag_holder<string,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10> , std::basic_ostringstream<char_type> > type;
+ };
     }
 
 }}

Modified: sandbox/logging/boost/logging/detail/format_msg_type.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/format_msg_type.hpp (original)
+++ sandbox/logging/boost/logging/detail/format_msg_type.hpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -36,6 +36,7 @@
     */
     template<class T = override> struct msg_type {
         typedef hold_string_type& type;
+ typedef hold_string_type raw_type;
     };
 }
 
@@ -46,6 +47,7 @@
     template<class T = override> struct msg_type {
         // by default - the default string
         typedef const hold_string_type& type;
+ typedef hold_string_type raw_type;
     };
 }
 

Modified: sandbox/logging/boost/logging/detail/fwd.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/fwd.hpp (original)
+++ sandbox/logging/boost/logging/detail/fwd.hpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -30,7 +30,7 @@
 // minimize inclusion of STL headers in our headers!!!
 #include <string>
 
-#define BOOST_LOGGING_STR(x) (const char_type*)ansi_unicode_char_holder ( x, L ## x)
+#define BOOST_LOG_STR(x) (const char_type*)ansi_unicode_char_holder ( x, L ## x)
 
 
 /*

Modified: sandbox/logging/boost/logging/detail/logger.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/logger.hpp (original)
+++ sandbox/logging/boost/logging/detail/logger.hpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -107,7 +107,7 @@
     
     */
     template<class gather_msg = default_, class write_msg = default_ > struct logger {
- typedef typename use_default<gather_msg, gather::ostream_like::return_str< std::basic_ostringstream<char_type> > > ::type gather_type;
+ typedef typename use_default<gather_msg, gather::ostream_like::return_str< std::basic_string<char_type>, std::basic_ostringstream<char_type> > > ::type gather_type;
         typedef write_msg write_type;
 
         typedef logger<gather_msg, write_msg> self;

Modified: sandbox/logging/boost/logging/detail/tss/tss.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/tss/tss.hpp (original)
+++ sandbox/logging/boost/logging/detail/tss/tss.hpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -21,10 +21,6 @@
 # pragma once
 #endif
 
-
-
-
-
 #if !defined(BOOST_LOG_NO_TSS)
 
 #include <boost/logging/detail/fwd.hpp>
@@ -80,13 +76,5 @@
 
 #endif // !BOOST_LOG_NO_TSS
 
-
-
-
-
-
-
-
-
 #endif
 

Modified: sandbox/logging/boost/logging/detail/tss/tss_impl_pthread.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/tss/tss_impl_pthread.hpp (original)
+++ sandbox/logging/boost/logging/detail/tss/tss_impl_pthread.hpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -50,7 +50,7 @@
     return slots;
 }
 
-extern "C" inline void cleanup_slots(void* p) {}
+extern "C" inline void cleanup_slots(void* ) {}
 
 inline void init_tss_data()
 {

Modified: sandbox/logging/boost/logging/detail/use_format_write.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/use_format_write.hpp (original)
+++ sandbox/logging/boost/logging/detail/use_format_write.hpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -14,7 +14,7 @@
 // See http://www.torjo.com/log2/ for more details
 
 #ifndef JT28092007_format_write_detail_HPP_DEFINED
-#error do not include this directly. Include logging/format/format_write.hpp instead
+#error do not include this directly. Include logging/format.hpp instead
 #endif
 
 #ifndef JT28092007_use_format_write_HPP_DEFINED

Modified: sandbox/logging/boost/logging/format.hpp
==============================================================================
--- sandbox/logging/boost/logging/format.hpp (original)
+++ sandbox/logging/boost/logging/format.hpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -233,7 +233,7 @@
     Example:
 
 @code
-typedef process_msg< gather::ostream_like::return_cache_str<> , format_write<...> > process;
+typedef process_msg< gather::ostream_like::return_str<> , format_write<...> > process;
 logger<process, filter::no_ts> g_l;
 #define L_ if ( !g_l) ; else g_l->read_msg().gather().out()
 
@@ -326,7 +326,7 @@
     Example:
 
     @code
- typedef process_msg< gather::ostream_like::return_cache_str<> ,
+ typedef process_msg< gather::ostream_like::return_str<> ,
         writer::format_write< format_base, destination_base, format_and_write::simple<cache_string>,
             msg_route::with_route<format_base,destination_base> > > process;
     logger<process, filter::no_ts> g_l;

Modified: sandbox/logging/boost/logging/format/formatter/convert_format.hpp
==============================================================================
--- sandbox/logging/boost/logging/format/formatter/convert_format.hpp (original)
+++ sandbox/logging/boost/logging/format/formatter/convert_format.hpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -24,7 +24,23 @@
 #include <boost/logging/detail/fwd.hpp>
 #include <boost/logging/format/optimize.hpp>
 
-namespace boost { namespace logging { namespace formatter {
+namespace boost { namespace logging {
+
+template<
+ class string_ ,
+ class param1 ,
+ class param2 ,
+ class param3 ,
+ class param4 ,
+ class param5 ,
+ class param6 ,
+ class param7 ,
+ class param8 ,
+ class param9 ,
+ class param10> struct tag_holder ;
+
+
+namespace formatter {
 
 
 /**
@@ -64,6 +80,11 @@
         template<class string> void write(const string_type & src, boost::logging::optimize::cache_string_several_str<string> & dest) {
             dest.prepend_string(src);
         }
+
+ template<class string, class p1, class p2, class p3, class p4, class p5, class p6, class p7, class p8, class p9, class p10> void write(const string_type & src, ::boost::logging::tag_holder<string,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10> & dest) {
+ write(src, static_cast<string&>(dest) );
+ }
+
     }
 
     /**
@@ -81,6 +102,9 @@
         template<class string> void write(const string_type & src, boost::logging::optimize::cache_string_several_str<string> & dest) {
             dest.append_string(src);
         }
+ template<class string, class p1, class p2, class p3, class p4, class p5, class p6, class p7, class p8, class p9, class p10> void write(const string_type & src, ::boost::logging::tag_holder<string,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10> & dest) {
+ write(src, static_cast<string&>(dest) );
+ }
     }
 
     /**
@@ -101,6 +125,9 @@
         template<class string> void write(string_type & src, boost::logging::optimize::cache_string_one_str<string> & dest) {
             dest.set_string_swap(src);
         }
+ template<class string, class p1, class p2, class p3, class p4, class p5, class p6, class p7, class p8, class p9, class p10> void write(const string_type & src, ::boost::logging::tag_holder<string,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10> & dest) {
+ write(src, static_cast<string&>(dest) );
+ }
     }
 }
 

Modified: sandbox/logging/boost/logging/format/formatter/defaults.hpp
==============================================================================
--- sandbox/logging/boost/logging/format/formatter/defaults.hpp (original)
+++ sandbox/logging/boost/logging/format/formatter/defaults.hpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -57,7 +57,7 @@
     idx_t() : non_const_context_base((int)0) {}
     template<class msg_type> void operator()(msg_type & str) const {
         std::basic_ostringstream<char_type> idx;
- idx << BOOST_LOGGING_STR("[") << ++context() << BOOST_LOGGING_STR("] ");
+ idx << BOOST_LOG_STR("[") << ++context() << BOOST_LOG_STR("] ");
 
         convert::write( idx.str(), str );
     }
@@ -72,7 +72,7 @@
 */
 template<class convert = do_convert_format::append> struct append_newline_t : is_generic, boost::logging::op_equal::always_equal {
     template<class msg_type> void operator()(msg_type & str) const {
- convert::write( (const char_type*)BOOST_LOGGING_STR("\n"), str );
+ convert::write( (const char_type*)BOOST_LOG_STR("\n"), str );
     }
 };
 
@@ -91,7 +91,7 @@
                 is_needed = false;
 
         if ( is_needed)
- convert::write( BOOST_LOGGING_STR("\n"), str );
+ convert::write( BOOST_LOG_STR("\n"), str );
     }
 };
 

Added: sandbox/logging/boost/logging/format/formatter/tags.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/format/formatter/tags.hpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -0,0 +1,61 @@
+// formatter_tags.hpp
+
+// Boost Logging library
+//
+// Author: John Torjo, www.torjo.com
+//
+// Copyright (C) 2007 John Torjo (see www.torjo.com for email)
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org for updates, documentation, and revision history.
+// See http://www.torjo.com/log2/ for more details
+
+
+#ifndef JT28092007_formatter_tags_HPP_DEFINED
+#define JT28092007_formatter_tags_HPP_DEFINED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/logging/detail/fwd.hpp>
+#include <boost/logging/tags.hpp>
+#include <boost/logging/detail/manipulator.hpp>
+
+
+namespace boost { namespace logging { namespace formatter {
+
+template<class type, class tag_type> struct uses_tag {
+ template<class tag_holder_type> void operator()(tag_holder_type & str) const {
+ typedef typename tag_holder_type::string_type string_type;
+ // automatic conversion - tag holder provides this
+ const tag_type & tag = str;
+
+ const type & self = reinterpret_cast<const type&>(*this);
+ self.write_tag(str, tag);
+ }
+};
+
+template<class convert = do_convert_format::prepend> struct file_line_t : is_generic, uses_tag< file_line_t<convert>, ::boost::logging::tag::file_line >, boost::logging::op_equal::always_equal {
+ template<class msg_type, class tag_type> void write_tag(msg_type & str, const tag_type & tag) const {
+ convert::write( tag.val, str);
+ }
+};
+
+typedef file_line_t<> file_line;
+
+template<class convert = do_convert_format::prepend> struct function_t : is_generic, uses_tag< function_t<convert>, ::boost::logging::tag::function >, boost::logging::op_equal::always_equal {
+ template<class msg_type, class tag_type> void write_tag(msg_type & str, const tag_type & tag) const {
+ convert::write( tag.val, str);
+ }
+};
+
+typedef function_t<> function;
+
+}}}
+
+#endif
+

Modified: sandbox/logging/boost/logging/format/formatter/thread_id.hpp
==============================================================================
--- sandbox/logging/boost/logging/format/formatter/thread_id.hpp (original)
+++ sandbox/logging/boost/logging/format/formatter/thread_id.hpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -37,7 +37,7 @@
 template<class convert = do_convert_format::prepend> struct thread_id_t : is_generic, boost::logging::op_equal::always_equal {
     template<class msg_type> void operator()(msg_type & msg) const {
         std::basic_ostringstream<char_type> out;
- out << BOOST_LOGGING_STR("[T")
+ out << BOOST_LOG_STR("[T")
     #if defined (BOOST_HAS_WINTHREADS)
             << ::GetCurrentThreadId()
     #elif defined (BOOST_HAS_PTHREADS)
@@ -45,7 +45,7 @@
     #elif defined (BOOST_HAS_MPTASKS)
             << MPCurrentTaskID()
     #endif
- << BOOST_LOGGING_STR("] ");
+ << BOOST_LOG_STR("] ");
 
         convert::write( out.str(), msg );
     }

Modified: sandbox/logging/boost/logging/format/formatter/time.hpp
==============================================================================
--- sandbox/logging/boost/logging/format/formatter/time.hpp (original)
+++ sandbox/logging/boost/logging/format/formatter/time.hpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -74,13 +74,13 @@
         assert( format.size() < 64);
 
         typedef hold_string_type::size_type uint;
- uint day_idx = format.find(BOOST_LOGGING_STR("$dd"));
- uint month_idx = format.find(BOOST_LOGGING_STR("$MM"));
- uint yy_idx = format.find(BOOST_LOGGING_STR("$yy"));
- uint yyyy_idx = format.find(BOOST_LOGGING_STR("$yyyy"));
- uint hour_idx = format.find(BOOST_LOGGING_STR("$hh"));
- uint min_idx = format.find(BOOST_LOGGING_STR("$mm"));
- uint sec_idx = format.find(BOOST_LOGGING_STR("$ss"));
+ uint day_idx = format.find(BOOST_LOG_STR("$dd"));
+ uint month_idx = format.find(BOOST_LOG_STR("$MM"));
+ uint yy_idx = format.find(BOOST_LOG_STR("$yy"));
+ uint yyyy_idx = format.find(BOOST_LOG_STR("$yyyy"));
+ uint hour_idx = format.find(BOOST_LOG_STR("$hh"));
+ uint min_idx = format.find(BOOST_LOG_STR("$mm"));
+ uint sec_idx = format.find(BOOST_LOG_STR("$ss"));
 
         typedef std::vector<index_info> array;
         array indexes;
@@ -110,7 +110,7 @@
         for ( typename array::iterator begin = indexes.begin(), end = indexes.end(); begin != end; ++begin) {
             m_format += format.substr( prev_idx, begin->src_idx - prev_idx);
             *begin->format_idx = idx;
- m_format += (begin->size == 4) ? BOOST_LOGGING_STR("%04d") : BOOST_LOGGING_STR("%02d");
+ m_format += (begin->size == 4) ? BOOST_LOG_STR("%04d") : BOOST_LOG_STR("%02d");
             prev_idx = begin->src_idx + begin->size + 1;
             ++idx;
         }

Modified: sandbox/logging/boost/logging/format/optimize.hpp
==============================================================================
--- sandbox/logging/boost/logging/format/optimize.hpp (original)
+++ sandbox/logging/boost/logging/format/optimize.hpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -69,6 +69,8 @@
             set_string(msg);
         }
 
+ cache_string_one_str() : m_reserve_prepend(10), m_reserve_append(10), m_grow_size(10), m_full_msg_computed(false) {}
+
         void set_string(const string_type & str) {
             m_str.resize( str.size() + m_reserve_prepend + m_reserve_append);
             std::copy( str.begin(), str.end(), m_str.begin() + m_reserve_prepend);

Modified: sandbox/logging/boost/logging/macros.hpp
==============================================================================
--- sandbox/logging/boost/logging/macros.hpp (original)
+++ sandbox/logging/boost/logging/macros.hpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <boost/logging/detail/log_keeper.hpp>
+#include <boost/current_function.hpp>
 
 namespace boost { namespace logging {
 
@@ -190,7 +191,7 @@
 */
 #define BOOST_LOG_FORMAT_MSG(msg_class) \
     namespace boost { namespace logging { namespace formatter { \
- template<> struct msg_type<override> { typedef msg_class & type; }; \
+ template<> struct msg_type<override> { typedef msg_class & type; typedef msg_class raw_type; }; \
     }}}
 
 /**
@@ -203,11 +204,35 @@
 */
 #define BOOST_LOG_DESTINATION_MSG(msg_class) \
     namespace boost { namespace logging { namespace destination { \
- template<> struct msg_type<override> { typedef const msg_class & type; }; \
+ template<> struct msg_type<override> { typedef const msg_class & type; typedef msg_class raw_type; }; \
     }}}
 
 
 
+
+
+
+
+
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Tags
+
+#define BOOST_LOG_STRINGIZE2(x) #x
+#define BOOST_LOG_STRINGIZE(x) BOOST_LOG_STRINGIZE2(x)
+#define BOOST_LOG_FILE_AND_LINE __FILE__ ":" BOOST_LOG_STRINGIZE(__LINE__)
+
+
+#define BOOST_LOG_TAG(tag_type) ::boost::logging::tag:: tag_type
+
+#define BOOST_LOG_TAB_LEVEL(lvl) BOOST_LOG_TAG(level)(::boost::logging::level ::lvl )
+
+#define BOOST_LOG_TAB_FILELINE BOOST_LOG_TAG(file_line) (BOOST_LOG_FILE_AND_LINE)
+
+#define BOOST_LOG_TAB_FUNCTION BOOST_LOG_TAG(function) (BOOST_CURRENT_FUNCTION)
+
+
 }}
 
 #endif

Modified: sandbox/logging/boost/logging/process_msg/ostream_like.hpp
==============================================================================
--- sandbox/logging/boost/logging/process_msg/ostream_like.hpp (original)
+++ sandbox/logging/boost/logging/process_msg/ostream_like.hpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -104,10 +104,12 @@
 };
 
 
-/**
- @brief Allows you to write to a log using the cool "<<" operator. The .msg() returns a string.
 
- Note that this is a very simple class.
+
+/**
+ @brief Allows you to write to a log using the cool "<<" operator. The .msg() returns a string - whatever you set as first template param.
+
+ By default, it's @ref boost::logging::optimize::cache_string_one_str "cache_string".
 
     @copydoc gather_the_message
 
@@ -115,17 +117,22 @@
     - boost::logging::gather
     - ostream_like
 
+
+ @bug right now prepend_size and append_size are ignored; because we can also return a cache_string_several_str<>. When fixing, watch the find_gather class!
 */
-template<class stream_type = std::basic_ostringstream<char_type> > struct return_str {
- // what does the gather_msg class return?
- typedef std::basic_string<char_type> & param;
+template<
+ class string = boost::logging::optimize::cache_string_one_str<hold_string_type> ,
+ class stream_type = std::basic_ostringstream<char_type> > struct return_str {
 
+ // what does the gather_msg class return?
+ typedef string & param;
+
     return_str() {}
     return_str(const return_str& other) : m_out(other.m_out.str()) {}
 
     stream_type & out() { return m_out; }
- /** returns a string */
- std::basic_string<char_type> msg() { return m_out.str(); }
+ /** @brief returns a string */
+ string msg() { return string( m_out.str() ); }
 private:
     stream_type m_out;
 };
@@ -133,37 +140,33 @@
 
 
 /**
- @brief Allows you to write to a log using the cool "<<" operator. The .msg() returns a @ref boost::logging::optimize::cache_string_one_str "cache_string".
-
- Returns a cache string
-
- @copydoc gather_the_message
-
- See also:
- - boost::logging::gather
- - ostream_like
-
+ @brief Returns a tag holder
 
- @bug right now prepend_size and append_size are ignored; because we can also return a cache_string_several_str<>. When fixing, watch the find_gather class!
+ See @ref boost::logging::tag namespace
 */
-template<
- class cache_string = boost::logging::optimize::cache_string_one_str<hold_string_type> ,
- class stream_type = std::basic_ostringstream<char_type> > struct return_cache_str {
-
+template<class holder_type, class stream_type> struct return_tag_holder {
     // what does the gather_msg class return?
- typedef cache_string & param;
+ typedef holder_type& param;
     
- return_cache_str() {}
- return_cache_str(const return_cache_str& other) : m_out(other.m_out.str()) {}
+ return_tag_holder() {}
+ return_tag_holder(const return_tag_holder& other) : m_out(other.m_out.str()), m_val(other.m_val) {}
 
- stream_type & out() { return m_out; }
- /** returns a cache_string */
- cache_string msg() { return cache_string( m_out.str() ); }
+
+ return_tag_holder & out() { return *this; }
+ template<class tag_type> return_tag_holder& set_tag(const tag_type & tag) {
+ m_val.set_tag(tag);
+ return *this;
+ }
+
+ template<class val_type> stream_type & operator<<(const val_type& val) { m_out << val; return m_out; }
+
+ /** @brief returns the holder */
+ holder_type & msg() { m_val.set_string( m_out.str() ); return m_val; }
 private:
+ holder_type m_val;
     stream_type m_out;
-};
-
 
+};
 
 
 }}}}

Modified: sandbox/logging/boost/logging/scenario.hpp
==============================================================================
--- sandbox/logging/boost/logging/scenario.hpp (original)
+++ sandbox/logging/boost/logging/scenario.hpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -65,7 +65,7 @@
     struct no_ts ;
     struct ts ;
     struct use_tss_once_init ;
-};
+}
 
 namespace level {
     template<int> struct holder_tss_with_cache ;
@@ -148,7 +148,7 @@
 #else
             typedef single_thread default_;
 #endif
- };
+ }
 
         /** @brief What's our "level" policy? */
         namespace level {
@@ -158,7 +158,7 @@
             struct use_levels {};
 
             typedef no_levels default_;
- };
+ }
     }
 
     /** @brief Logger %usage settings : logger_::change and logger_::favor
@@ -203,7 +203,7 @@
 #else
             typedef single_thread default_;
 #endif
- };
+ }
 
         /** @brief When logging, what should we %favor? */
         namespace favor {
@@ -228,7 +228,7 @@
 #else
             typedef single_thread default_;
 #endif
- };
+ }
 
         /** @brief How do you gather the message? */
         namespace gather {
@@ -239,7 +239,7 @@
             template<class gather_type> struct custom {};
 
             typedef ostream_like default_;
- };
+ }
     }
 
 

Added: sandbox/logging/boost/logging/tag/defaults.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/tag/defaults.hpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -0,0 +1,82 @@
+// tag_defaults.hpp
+
+// Boost Logging library
+//
+// Author: John Torjo, www.torjo.com
+//
+// Copyright (C) 2007 John Torjo (see www.torjo.com for email)
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org for updates, documentation, and revision history.
+// See http://www.torjo.com/log2/ for more details
+
+
+#ifndef JT28092007_tag_defaults_HPP_DEFINED
+#define JT28092007_tag_defaults_HPP_DEFINED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/logging/detail/fwd.hpp>
+#include <boost/logging/logging.hpp>
+#include <boost/thread/detail/config.hpp>
+
+namespace boost { namespace logging { namespace tag {
+
+
+struct file_line {
+ file_line(const char * val = "") : val(val) {}
+ const char * val;
+};
+
+struct level {
+ level(::boost::logging::level::type val = 0) : val(val) {}
+ ::boost::logging::level::type val;
+};
+
+struct time {
+ time() : val( ::time(0) ) {}
+ ::time_t val;
+};
+
+struct function {
+ function(const char* name = "") : val(name) {}
+ const char * val;
+};
+
+template<class severity_type = int> struct severity {
+ severity(severity_type val) : val(val) {}
+ severity_type val;
+};
+
+struct module {
+ module(const char* name = "") : val(name) {}
+ const char * val;
+};
+
+
+struct thread_id {
+ thread_id() {
+#if defined (BOOST_HAS_WINTHREADS)
+ val = ::GetCurrentThreadId();
+#elif defined (BOOST_HAS_PTHREADS)
+ val = pthread_self ();
+#endif
+ }
+
+#if defined (BOOST_HAS_WINTHREADS)
+ DWORD val;
+#elif defined (BOOST_HAS_PTHREADS)
+ pthread_t val;
+#endif
+};
+
+
+}}}
+
+#endif
+

Added: sandbox/logging/boost/logging/tags.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/tags.hpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -0,0 +1,151 @@
+// tags.hpp
+
+// Boost Logging library
+//
+// Author: John Torjo, www.torjo.com
+//
+// Copyright (C) 2007 John Torjo (see www.torjo.com for email)
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org for updates, documentation, and revision history.
+// See http://www.torjo.com/log2/ for more details
+
+
+#ifndef JT28092007_tags_HPP_DEFINED
+#define JT28092007_tags_HPP_DEFINED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/logging/detail/fwd.hpp>
+
+namespace boost { namespace logging {
+
+namespace detail {
+ struct void_1 {};
+ struct void_2 {};
+ struct void_3 {};
+ struct void_4 {};
+ struct void_5 {};
+ struct void_6 {};
+ struct void_7 {};
+ struct void_8 {};
+ struct void_9 {};
+ struct void_10 {};
+
+ template<class string_type> struct tag_holder_base {
+ // assumes m_string is convertible to string
+ operator const hold_string_type & () const { return m_string; }
+ protected:
+ string_type m_string;
+ };
+ template<> struct tag_holder_base<default_> {
+ // it's for the default string
+ protected:
+ hold_string_type m_string;
+ };
+}
+
+/** @brief Holds up to 10 @ref tag "tags".
+
+@param string_ The string class we use for holding logged messages. By default, std::(w)string. What you used to specify using BOOST_LOG_FORMAT_MSG.
+
+*/
+template<
+ class string_ = default_,
+ class param1 = detail::void_1,
+ class param2 = detail::void_2,
+ class param3 = detail::void_3,
+ class param4 = detail::void_4,
+ class param5 = detail::void_5,
+ class param6 = detail::void_6,
+ class param7 = detail::void_7,
+ class param8 = detail::void_8,
+ class param9 = detail::void_9,
+ class param10 = detail::void_10> struct tag_holder : detail::tag_holder_base<string_> {
+ typedef typename use_default<string_, hold_string_type>::type string_type;
+ typedef detail::tag_holder_base<string_> tag_base_type;
+
+ operator string_type & () { return tag_base_type::m_string; }
+ operator const string_type & () const { return tag_base_type::m_string; }
+
+ operator const param1& () const { return m_tag1; }
+ operator const param2& () const { return m_tag2; }
+ operator const param3& () const { return m_tag3; }
+ operator const param4& () const { return m_tag4; }
+ operator const param5& () const { return m_tag5; }
+ operator const param6& () const { return m_tag6; }
+ operator const param7& () const { return m_tag7; }
+ operator const param8& () const { return m_tag8; }
+ operator const param9& () const { return m_tag9; }
+ operator const param10& () const { return m_tag10; }
+
+ template<class tag_type> tag_holder& set_tag(const tag_type & val) {
+ set_tag_impl(val);
+ return *this;
+ }
+
+ template<class tag_type> const tag_type & get_tag() const {
+ return operator const tag_type&();
+ }
+
+ void set_string(const string_type & str) {
+ m_string = str;
+ }
+
+private:
+ void set_tag_impl(const param1 & tag) {
+ m_tag1 = tag;
+ }
+ void set_tag_impl(const param2 & tag) {
+ m_tag2 = tag;
+ }
+ void set_tag_impl(const param3 & tag) {
+ m_tag3 = tag;
+ }
+ void set_tag_impl(const param4 & tag) {
+ m_tag4 = tag;
+ }
+ void set_tag_impl(const param5 & tag) {
+ m_tag5 = tag;
+ }
+ void set_tag_impl(const param6 & tag) {
+ m_tag6 = tag;
+ }
+ void set_tag_impl(const param7 & tag) {
+ m_tag7 = tag;
+ }
+ void set_tag_impl(const param8 & tag) {
+ m_tag8 = tag;
+ }
+ void set_tag_impl(const param9 & tag) {
+ m_tag9 = tag;
+ }
+ void set_tag_impl(const param10 & tag) {
+ m_tag10 = tag;
+ }
+
+private:
+ param1 m_tag1;
+ param2 m_tag2;
+ param3 m_tag3;
+ param4 m_tag4;
+ param5 m_tag5;
+ param6 m_tag6;
+ param7 m_tag7;
+ param8 m_tag8;
+ param9 m_tag9;
+ param10 m_tag10;
+};
+
+
+}}
+
+#include <boost/logging/tag/defaults.hpp>
+
+#endif
+

Modified: sandbox/logging/boost/logging/writer/on_dedicated_thread.hpp
==============================================================================
--- sandbox/logging/boost/logging/writer/on_dedicated_thread.hpp (original)
+++ sandbox/logging/boost/logging/writer/on_dedicated_thread.hpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -122,10 +122,13 @@
         write_array();
     }
 
- void operator()(const msg_type & msg) const {
+// void operator()(const msg_type & msg) const {
+ void operator()(msg_type & msg) const {
         typedef typename context_type::ptr ptr;
         typedef typename context_type::thread_ptr thread_ptr;
- ptr new_msg(new msg_type(msg));
+ //ptr new_msg(new msg_type(msg));
+ ptr new_msg(new msg_type);
+ std::swap(msg, *new_msg);
 
         scoped_lock lk( non_const_context_base::context().cs);
         if ( !non_const_context_base::context().writer)

Modified: sandbox/logging/lib/logging/internal/vc8/loggingvc8/loggingvc8.vcproj
==============================================================================
--- sandbox/logging/lib/logging/internal/vc8/loggingvc8/loggingvc8.vcproj (original)
+++ sandbox/logging/lib/logging/internal/vc8/loggingvc8/loggingvc8.vcproj 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -510,7 +510,6 @@
>
                                 <FileConfiguration
                                         Name="Test|Win32"
- ExcludedFromBuild="true"
>
                                         <Tool
                                                 Name="VCCLCompilerTool"
@@ -732,6 +731,10 @@
>
                                         </File>
                                         <File
+ RelativePath="..\..\..\..\..\boost\logging\format\formatter\tags.hpp"
+ >
+ </File>
+ <File
                                                 RelativePath="..\..\..\..\..\boost\logging\format\formatter\thread_id.hpp"
>
                                         </File>
@@ -805,6 +808,18 @@
>
                                 </File>
                         </Filter>
+ <Filter
+ Name="tags"
+ >
+ <File
+ RelativePath="..\..\..\..\..\boost\logging\tag\defaults.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\boost\logging\tags.hpp"
+ >
+ </File>
+ </Filter>
                 </Filter>
                 <Filter
                         Name="internal docs"
@@ -814,10 +829,6 @@
>
                         </File>
                         <File
- RelativePath="..\..\..\..\..\..\..\..\uk\logging_internal\desc.txt"
- >
- </File>
- <File
                                 RelativePath="..\..\..\..\..\..\..\..\uk\logging_internal\old todo.txt"
>
                         </File>
@@ -1014,13 +1025,7 @@
>
                                 <FileConfiguration
                                         Name="Test|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="TestAll|Win32"
+ ExcludedFromBuild="true"
>
                                         <Tool
                                                 Name="VCCLCompilerTool"

Modified: sandbox/logging/lib/logging/tests/do_not_use/format/test_manip_w_msgroute.cpp
==============================================================================
--- sandbox/logging/lib/logging/tests/do_not_use/format/test_manip_w_msgroute.cpp (original)
+++ sandbox/logging/lib/logging/tests/do_not_use/format/test_manip_w_msgroute.cpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -118,7 +118,7 @@
 };
 
 typedef process_msg<
- gather::ostream_like::return_cache_str<> ,
+ gather::ostream_like::return_str<> ,
     writer::format_write<
         format_base,
         destination_base,

Modified: sandbox/logging/lib/logging/tests/do_not_use/format/test_simple_formatter.cpp
==============================================================================
--- sandbox/logging/lib/logging/tests/do_not_use/format/test_simple_formatter.cpp (original)
+++ sandbox/logging/lib/logging/tests/do_not_use/format/test_simple_formatter.cpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -98,7 +98,7 @@
 };
 
 typedef process_msg<
- gather::ostream_like::return_cache_str<> ,
+ gather::ostream_like::return_str<> ,
     writer::format_write<
         format_base,
         destination_base, format_and_write::simple<cache_string> > > process;

Modified: sandbox/logging/lib/logging/tests/do_not_use/testfast.cpp
==============================================================================
--- sandbox/logging/lib/logging/tests/do_not_use/testfast.cpp (original)
+++ sandbox/logging/lib/logging/tests/do_not_use/testfast.cpp 2007-11-09 23:44:15 EST (Fri, 09 Nov 2007)
@@ -17,93 +17,51 @@
 // See http://www.torjo.com/log2/ for more details
 
 
-/**
-_at_example your_scenario.cpp
 
-_at_copydoc your_scenario
+#define BOOST_LOG_COMPILE_FAST_OFF
+#include <boost/logging/format_fwd.hpp>
+#include <boost/logging/tags.hpp>
 
-_at_page your_scenario your_scenario.cpp Example
+using namespace boost::logging;
+typedef tag_holder< optimize::cache_string_one_str<>, tag::time, tag::file_line, tag::function> string;
 
+// Step 1: Optimize : use a cache string, to make formatting the message faster
+BOOST_LOG_FORMAT_MSG( string )
 
-This usage:
-- You have several loggers
-- You have one filter, which can be turned on or off
-- You want to format the message before it's written
-- Each logger has several log destinations
-- The logger and filter are specified using the boost::logging::scenario namespace
- - the filter is always accurate (but slow)
- - the filter does not use levels
- - the logger favors speed (on a dedicated thread)
- - the logger is initialized once, when only one thread is running
-
-Optimizations:
-- use a cache string (from optimize namespace), in order to make formatting the message faster
-
-Logs:
-- Error messages go into err.txt file
- - formatting - prefix each message by time, index, and append enter
-- Info output goes to console, and a file called out.txt
- - formatting - prefix each message by time and append enter
-- Debug messages go to the debug output window, and the console
- - formatting - prefix each message by time, and append enter
-
-
-Here's how the output will look like:
-
-The debug output window:
-_at_code
-18:59.24 this is so cool 1
-18:59.24 this is so cool again 2
-_at_endcode
-
-
-The console:
-_at_code
-18:59.24 this is so cool 1
-18:59.24 this is so cool again 2
-18:59.24 hello, world
-18:59.24 good to be back ;) 4
-_at_endcode
-
-
-The out.txt file:
-_at_code
-18:59.24 hello, world
-18:59.24 good to be back ;) 4
-_at_endcode
-
-
-The err.txt file
-_at_code
-18:59.24 [1] first error 3
-18:59.24 [2] second error 5
-_at_endcode
-*/
 
+// Step 3 : Specify your logging class(es)
+typedef logger_format_write< > log_type;
 
+#include <boost/logging/format.hpp>
+#include <boost/logging/writer/ts_write.hpp>
+#include <boost/logging/format/formatter/tags.hpp>
 
-#define BOOST_LOG_COMPILE_FAST_OFF
-#include <boost/logging/format_fwd.hpp>
 
-// Step 1: Optimize : use a cache string, to make formatting the message faster
-BOOST_LOG_FORMAT_MSG( optimize::cache_string_one_str<> )
+// Step 4: declare which filters and loggers you'll use (usually in a header file)
+BOOST_DECLARE_LOG_FILTER(g_log_filter, filter::no_ts )
+BOOST_DECLARE_LOG(g_l, log_type)
+BOOST_DEFINE_LOG_FILTER(g_log_filter, filter::no_ts )
+BOOST_DEFINE_LOG(g_l, log_type)
 
-#include <boost/logging/format_ts.hpp>
-using namespace boost::logging;
+#define L_ BOOST_LOG_USE_LOG_IF_FILTER(g_l, g_log_filter->is_enabled() ) .set_tag(BOOST_LOG_TAB_FILELINE ).set_tag(BOOST_LOG_TAB_FUNCTION)
 
-// Step 3 : Specify your logging class(es)
-// - the filter is always accurate (but slow)
-// - the filter does not use levels
-// - the logger favors speed (on a dedicated thread)
-// - the logger is initialized once, when only one thread is running
-using namespace boost::logging::scenario::usage;
-typedef use<filter_::change::always_accurate, filter_::level::no_levels, logger_::change::set_once_when_one_thread, logger_::favor::speed> finder;
 
 
 void your_scenario_example() {
- finder ::filter f;
- finder:: logger l;
- int i = 0;
+
+ g_l->writer().add_formatter( formatter::idx() );
+// g_l->writer().add_formatter( formatter::file_line() );
+ g_l->writer().add_formatter( formatter::function() );
+ g_l->writer().add_formatter( formatter::append_newline() );
+ g_l->writer().add_destination( destination::file("out.txt") );
+ g_l->writer().add_destination( destination::cout() );
+ g_l->writer().add_destination( destination::dbg_window() );
+
+ // Step 8: use it...
+ int i = 1;
+ L_ << "this is so cool " << i++;
+ L_ << "this is so cool again " << i++;
+
 }
 
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk