[prev in list] [next in list] [prev in thread] [next in thread] 

List:       boost-commit
Subject:    [Boost-commit] svn:boost r41514 - in sandbox/logging:
From:       john.groups () torjo ! com
Date:       2007-11-30 21:27:27
Message-ID: 20071130212727.199732F815C () wowbagger ! osl ! iu ! edu
[Download RAW message or body]

Author: jtorjo
Date: 2007-11-30 16:27:25 EST (Fri, 30 Nov 2007)
New Revision: 41514
URL: http://svn.boost.org/trac/boost/changeset/41514

Log:
v0.12.7, 30 nov 2007
- added boost::logging::formatter::named_spacer
Text files modified: 
   sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp               |     3   \
  sandbox/logging/boost/logging/detail/raw_doc/todo.hpp                    |    12 -- \
  sandbox/logging/boost/logging/detail/ts/resource_finder.hpp              |    36 \
+++++                                     \
sandbox/logging/boost/logging/detail/ts/ts.hpp                           |     2      \
  sandbox/logging/boost/logging/format/array.hpp                           |     4    \
  sandbox/logging/boost/logging/format/formatter/named_spacer.hpp          |   238 \
+++++++++++++++++++++++++++++++++++++--   \
sandbox/logging/lib/logging/internal/vc8/loggingvc8/loggingvc8.vcproj    |     9 +    \
  sandbox/logging/lib/logging/internal/vc8/loggingvc8/test_now.cpp         |    11 +  \
  sandbox/logging/lib/logging/samples/scenarios/custom_fmt_dest.cpp        |     2    \
  sandbox/logging/lib/logging/samples/scenarios/ded_loger_one_filter.cpp   |     2    \
  sandbox/logging/lib/logging/samples/scenarios/mul_levels_mul_logers.cpp  |     2    \
  sandbox/logging/lib/logging/samples/scenarios/mul_levels_one_logger.cpp  |     2    \
  sandbox/logging/lib/logging/samples/scenarios/mul_loggers_one_filter.cpp |     2    \
  sandbox/logging/lib/logging/samples/scenarios/no_levels_with_route.cpp   |     2    \
  sandbox/logging/lib/logging/samples/scenarios/one_loger_one_filter.cpp   |     2    \
  sandbox/logging/lib/logging/samples/scenarios/ts_loger_one_filter.cpp    |     4    \
  sandbox/logging/lib/logging/samples/scenarios/using_tags.cpp             |    12 +  \
  sandbox/logging/lib/logging/samples/scenarios/your_scenario.cpp          |     2    \
  18 files changed, 304 insertions(+), 43 deletions(-)

Modified: sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp	(original)
+++ sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp	2007-11-30 16:27:25 \
EST (Fri, 30 Nov 2007) @@ -2,8 +2,9 @@
 @page page_changelog Changelog
 
 @section changelog_cur_ver Current Version: v0.12.6, 30 nov 2007
+- added boost::logging::formatter::named_spacer
 - created lock_resource_finder namespace - with existing resource lockers
-- added boost::logging::spacer
+- added boost::logging::formatter::spacer
 - removed copyright from examples (scenarios) - so that they're easier to read in \
                the documentation
 - added scoped logs
 - removed #ifdef SINGLE_TEST from scenarios

Modified: sandbox/logging/boost/logging/detail/raw_doc/todo.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/todo.hpp	(original)
+++ sandbox/logging/boost/logging/detail/raw_doc/todo.hpp	2007-11-30 16:27:25 EST \
(Fri, 30 Nov 2007) @@ -75,18 +75,6 @@
 
 @section todo_formatters Formatters
 
-- @c must_have      each formatter - should have a "syntax" - like: idx("[%] ") - \
                write [idx]<space>; idx("{%} ") - write {idx}<space>
-  Or, have a formatter that can call other formatters, like format("[%1] [%2] \
                {%3}"). Perhaps for starters, have a wrapper class
-  which calls original formatter and then wrappers?
-  actually - have a formatter that has a map of other formatters (std::string -> \
                formatter) - THEN you can string at runtime.
-  we should have the same for destinations as well TOTHINK how do we initialize \
                them? like - a file destination - how can i specify the file name?
-  have a spacer formatter which writes before & after - some text.
-  have a % formatter taht can write more formatters at the same time %1 %2- message \
                %3
-  have a named formatter that can write more formatters at the same time, but based \
                on name - make it easy to use, and somehow the default should
-  encompass all existing formatters TOTHINK the problem is still setting params at \
                the constructor of certain objects - like - time(%m:%s) etc.
-  we should make it as easy as possible; perhaps make it very easy for named \
                formatter - TOTHINK
-  maybe i can have an extra param as formatter - the "spacer" spacer<....>(construct \
                - pass to it,"[%])
-  the named formatter - leave that "normal" for later
 
 - @c high           new formatter - write a more "exact" time - up to the millisec \
or so; should use Boost.DateTime for higher-resolution timestamps.  

Modified: sandbox/logging/boost/logging/detail/ts/resource_finder.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/ts/resource_finder.hpp	(original)
+++ sandbox/logging/boost/logging/detail/ts/resource_finder.hpp	2007-11-30 16:27:25 \
EST (Fri, 30 Nov 2007) @@ -27,13 +27,25 @@
 
 #include <boost/logging/detail/fwd.hpp>
 
-namespace boost { namespace logging { namespace lock_resource_finder {
+namespace boost { namespace logging { 
+    
+    /** 
+        @brief Possible ways to lock resource for read/write
+    */
+    namespace lock_resource_finder {
+
+    /** 
+        @brief Locks a resource thread-safe - each time, at read/write (safe but \
rather inefficient) +    */
     template<class mutex = boost::logging::threading::mutex> struct ts {
             template<class lock_type> struct finder {
                 typedef typename boost::logging::locker::ts_resource<lock_type, \
mutex > type;  };
     };
 
+    /** 
+        @brief Does not lock the resouce at read/write access
+    */
     struct single_thread {
             template<class lock_type> struct finder {
                 typedef typename \
boost::logging::locker::ts_resource_single_thread<lock_type> type; @@ -41,18 +53,40 \
@@  };
 
 #if !defined( BOOST_LOG_NO_TSS) 
+    /** 
+        @brief Caches the resource on each thread, and refreshes it at @c \
refresh_secs period +    */
     template<int refresh_secs = 5, class mutex = boost::logging::threading::mutex > \
struct tss_with_cache {  template<class lock_type> struct finder {
                 typedef typename locker::tss_resource_with_cache<lock_type, \
refresh_secs, mutex > type;  };
     };
 
+    /** 
+        @brief Allows you to initialize this resource once even if multiple threads \
are running. Then, all threads will use the initialized value +    */
     template<class mutex = boost::logging::threading::mutex> struct tss_once_init {
             template<class lock_type> struct finder {
                 typedef typename boost::logging::locker::tss_resource_once_init \
<lock_type, mutex> type;  };
     };
 
+#else
+
+    // Not using TSS at all 
+
+    template<int = 5, class = boost::logging::threading::mutex > struct \
tss_with_cache { +            template<class lock_type> struct finder {
+                typedef typename locker::ts_resource_single_thread<lock_type> type;
+            };
+    };
+
+    template<class = boost::logging::threading::mutex> struct tss_once_init {
+            template<class lock_type> struct finder {
+                typedef typename locker::ts_resource_single_thread<lock_type> type;
+            };
+    };
+
 #endif
 
 

Modified: sandbox/logging/boost/logging/detail/ts/ts.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/ts/ts.hpp	(original)
+++ sandbox/logging/boost/logging/detail/ts/ts.hpp	2007-11-30 16:27:25 EST (Fri, 30 \
Nov 2007) @@ -23,6 +23,8 @@
 
 #include <boost/config.hpp>
 
+#include <boost/logging/detail/ts/ts_none.hpp>
+
 #ifdef BOOST_HAS_THREADS
     
     #ifdef BOOST_LOG_USE_BOOST_THREADS

Modified: sandbox/logging/boost/logging/format/array.hpp
==============================================================================
--- sandbox/logging/boost/logging/format/array.hpp	(original)
+++ sandbox/logging/boost/logging/format/array.hpp	2007-11-30 16:27:25 EST (Fri, 30 \
Nov 2007) @@ -66,6 +66,10 @@
         
         template<class derived> void del(derived val) {
             base_type * p = get_ptr(val);
+            del(p);
+        }
+
+        void del(base_type * p) {
             scoped_lock lk(m_cs);
             for ( typename array_type::iterator b = m_array.begin(), e = \
m_array.end(); b != e; ++b)  if ( b->get() == p) {

Modified: sandbox/logging/boost/logging/format/formatter/named_spacer.hpp
==============================================================================
--- sandbox/logging/boost/logging/format/formatter/named_spacer.hpp	(original)
+++ sandbox/logging/boost/logging/format/formatter/named_spacer.hpp	2007-11-30 \
16:27:25 EST (Fri, 30 Nov 2007) @@ -22,34 +22,248 @@
 #endif
 
 #include <boost/logging/detail/fwd.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/logging/detail/manipulator.hpp>
 
 namespace boost { namespace logging { namespace formatter {
 
 namespace detail {
-    template<class convert, class lock_resource, class format_base> struct \
                named_spacer_context {
-        typedef use_default<lock_resource, boost::logging::
 
+    template<class convert, class lock_resource, class format_base> struct \
named_spacer_context { +        typedef typename use_default<lock_resource, \
boost::logging::lock_resource_finder::tss_with_cache<> >::type lock_resource; +       \
typedef typename use_default<format_base, base<> >::type  format_base_type; +        \
typedef typename use_default<convert, \
boost::logging::formatter::do_convert_format::prepend> ::type convert_type; +        \
typedef ::boost::logging::array::shared_ptr_holder<format_base_type, \
boost::logging::threading::no_mutex > array; +        typedef hold_string_type \
string_type; +
+        struct write_step {
+            write_step(const string_type & prefix, format_base_type * fmt) : \
prefix(prefix), fmt(fmt) {} +            string_type prefix;
+            // could be null - in case formatter not found by name, or it's the last \
step +            format_base_type * fmt;
+        };
+
+        struct write_info {
+            array formatters;
+            typedef std::map<string_type, format_base_type* > coll;
+            coll name_to_formatter;
+
+            string_type format_string;
+
+            // how we write
+            typedef std::vector<write_step> write_step_array;
+            write_step_array write_steps;
+        };
         typedef typename lock_resource::template finder<write_info>::type data;
+        data m_data;
+
+        template<class formatter> void add(const string_type & name, formatter fmt) \
{ +            // care about if generic or not
+            typedef boost::logging::manipulator::is_generic is_generic;
+            add_impl<formatter>( name, fmt, \
boost::is_base_of<is_generic,formatter>() ); +            compute_write_steps();
+        }
+
+        void del(const string_type & name) {
+            {
+            data::write info(m_data);
+            format_base_type * p = info->name_to_formatter[name];
+            info->name_to_formatter.erase(name);
+            info->formatters.del(p);
+            }
+            compute_write_steps();
+        }
+
+        void format_string(const string_type & str) {
+            { data::write info(m_data);
+              info->format_string = str;
+            }
+            compute_write_steps();
+        }
+
+        template<class msg_type> void write(msg_type & msg) const {
+            // see type of convert
+            write_with_convert( msg, (convert_type*)0 );
+        }
+
+    private:
+        template<class msg_type> void write_with_convert(msg_type & msg, \
::boost::logging::formatter::do_convert_format::prepend*) const { +            // \
prepend +            data::read info(m_data);
+            typedef typename write_info::write_step_array array;
+            for ( typename array::const_reverse_iterator b = \
info->write_steps.rbegin(), e = info->write_steps.rend(); b != e; ++b) { +            \
if ( b->fmt) +                    (*(b->fmt))(msg);
+                convert_type::write( b->prefix, msg);
+            }
+        }
+        template<class msg_type> void write_with_convert(msg_type & msg, ...) const \
{ +            // append
+            data::read info(m_data);
+            typedef typename write_info::write_step_array array;
+            for ( typename array::const_iterator b = info->write_steps.begin(), e = \
info->write_steps.end(); b != e; ++b) { +                convert_type::write( \
b->prefix, msg); +                if ( b->fmt)
+                    (*(b->fmt))(msg);
+            }
+        }
+
+        static string_type unescape(string_type escaped) {
+            typedef typename string_type::size_type size_type;
+            size_type idx_start = 0;
+            while ( true) {
+                size_type found = escaped.find( BOOST_LOG_STR("%%"), idx_start );
+                if ( found != string_type::npos) {
+                    escaped.erase( escaped.begin() + found);
+                    ++idx_start;
+                }
+                else
+                    break;
+            }
+            return escaped;
+        }
+
+        // recomputes the write steps - note taht this takes place after each \
operation +        // for instance, the user might have first set the string and \
later added the formatters +        void compute_write_steps() {
+            typedef typename string_type::size_type size_type;
+
+            data::write info(m_data);
+            info->write_steps.clear();
+            string_type remaining = info->format_string;
+            size_type start_search_idx = 0;
+            while ( !remaining.empty() ) {
+                size_type idx = remaining.find('%', start_search_idx);
+                if ( idx != string_type::npos) {
+                    // see if just escaped
+                    if ( (idx < remaining.size() - 1) && remaining[idx + 1] == '%') \
{ +                        // we found an escaped char
+                        start_search_idx = idx + 2;
+                        continue;
+                    }
+
+                    // up to here, this is a spacer string
+                    start_search_idx = 0;
+                    string_type spacer = unescape( remaining.substr(0, idx) );
+                    remaining = remaining.substr(idx + 1);
+                    // find end of formatter name
+                    idx = remaining.find('%');
+                    format_base_type * fmt = 0;
+                    if ( idx != string_type::npos) {
+                        string_type name = remaining.substr(0, idx);
+                        remaining = remaining.substr(idx + 1);
+                        fmt = info->name_to_formatter[name];
+                    }
+                    // note: fmt could be null, in case 
+                    info->write_steps.push_back( write_step( spacer, fmt) );
+                }
+                else {
+                    // last part
+                    info->write_steps.push_back( write_step( unescape(remaining), 0) \
); +                    remaining.clear();
+                }
+            }
+        }
+
+    private:
+        // non-generic
+        template<class formatter> void add_impl(const string_type & name, formatter \
fmt, const boost::false_type& ) { +            data::write info(m_data);
+            format_base_type * p = info->formatters.append(fmt);
+            info->name_to_formatter[name] = p;
+        }
+        // generic manipulator
+        template<class formatter> void add_impl(const string_type & name, formatter \
fmt, const boost::true_type& ) { +            typedef \
boost::logging::manipulator::detail::generic_holder<formatter,format_base_type> \
holder; +
+            typedef typename formatter::convert_type formatter_convert_type;
+            // they must share the same type of conversion - otherwise when trying \
to prepend we could end up appending or vice versa +            BOOST_STATIC_ASSERT( \
(boost::is_same<formatter_convert_type, convert_type>::value) ); +
+            add_impl( name, holder(fmt), boost::false_type() );
+        }
+
         
     };
 }
-    // when adding generic ones, make sure I keep the same convert (append or \
                prepend)
-    // named_spacer<> - you specify the convert !!!
-        // if adding a generic formatter and convert is diff than ours, compile \
                error!
-    // also, allow adding more in one step : .add(..).add(..)....
 
-template<class lock_resource = default_, class convert = do_convert_format::prepend, \
class format_base = base<> >  +/** 
+@brief Allows you to contain multiple formatters, and specify a %spacer between \
them. You have a %spacer string, and within it, you can escape your contained \
formatters. +
+This allows you:
+- to hold multiple formatters
+- each formatter is given a name, when being added
+- you have a %spacer string, which contains what is to be prepended or appended to \
the string (by default, prepended) +- a formatter is escaped with @c '\%' chars, like \
this @c "%name%" +- if you want to write the @c '\%', just double it, like this: \
<tt>"this %% gets written"</tt> +
+Example:
+
+@code
+#define L_ BOOST_LOG_USE_LOG_IF_FILTER(g_l, g_log_filter->is_enabled() ) 
+
+g_l->writer().add_formatter( formatter::named_spacer("[%index%] %time% (T%thread%) \
") +        .add( "index", formatter::idx())
+        .add( "thread", formatter::thread_id())
+        .add( "time", formatter::time("$mm")) );
+@endcode
+
+Assuming you'd use the above in code
+@code
+int i = 1;
+L_ << "this is so cool " << i++;
+L_ << "this is so cool again " << i++;
+@endcode
+
+You could have an output like this:
+
+@code
+[1] 53 (T3536) this is so cool 1
+[2] 54 (T3536) this is so cool again 2
+@endcode
+
+
+@bug Use_tags.cpp example when on dedicated thread, fails with named_spacer. If \
using the old code, it works. +
+*/
+template< class convert = do_convert_format::prepend, class lock_resource = \
                default_, class format_base = default_ > 
         struct named_spacer_t : is_generic, non_const_context< \
                detail::named_spacer_context<convert,lock_resource,format_base> > {
-    // have array or so?
 
-    // allow to change the format string
-    // unknown % - ignore, treat as string
-    // % - escape char
-    // %% = %
+    typedef non_const_context< \
detail::named_spacer_context<convert,lock_resource,format_base> > context_base; +    \
typedef hold_string_type string_type; +
+    named_spacer_t(const string_type & str = string_type() ) {
+        if ( !str.empty() )
+            context_base::context().format_string(str);
+    }
+
+    named_spacer_t & string(const string_type & str) {
+        context_base::context().format_string(str);
+        return *this;
+    }
+
+    template<class formatter> named_spacer_t & add(const string_type & name, \
formatter fmt) { +        context_base::context().add(name, fmt);
+        return *this;
+    }
+
+    template<class msg_type> void operator()(msg_type & msg) const {
+        context_base::context().write(msg);
+    }
+
+    bool operator==(const named_spacer_t & other) const {
+        return &( context_base::context() ) == &( other.context_base::context() );
+    }
 
 };
 
+/** @brief named_spacer_t with default values. See named_spacer_t
 
+@copydoc named_spacer_t
+*/
+typedef named_spacer_t<> named_spacer;
 
 }}}
 

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-30 \
16:27:25 EST (Fri, 30 Nov 2007) @@ -328,6 +328,14 @@
 			<File
 				RelativePath=".\test_now.cpp"
 				>
+				<FileConfiguration
+					Name="Test|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+					/>
+				</FileConfiguration>
 			</File>
 		</Filter>
 		<Filter
@@ -866,7 +874,6 @@
 				>
 				<FileConfiguration
 					Name="Test|Win32"
-					ExcludedFromBuild="true"
 					>
 					<Tool
 						Name="VCCLCompilerTool"

Modified: sandbox/logging/lib/logging/internal/vc8/loggingvc8/test_now.cpp
==============================================================================
--- sandbox/logging/lib/logging/internal/vc8/loggingvc8/test_now.cpp	(original)
+++ sandbox/logging/lib/logging/internal/vc8/loggingvc8/test_now.cpp	2007-11-30 \
16:27:25 EST (Fri, 30 Nov 2007) @@ -39,6 +39,7 @@
 
 #include <boost/logging/format.hpp>
 #include <boost/logging/format/formatter/thread_id.hpp>
+#include <boost/logging/format/formatter/named_spacer.hpp>
 #include <boost/logging/writer/ts_write.hpp>
 
 using namespace boost::logging;
@@ -59,12 +60,18 @@
 BOOST_DEFINE_LOG(g_l, log_type)
 
 
+
 void one_logger_one_filter_example() {
     // Step 7: add formatters and destinations
     //         That is, how the message is to be formatted and where should it be \
written to  
-    g_l->writer().add_formatter( formatter::idx(), "[%] " );
-    g_l->writer().add_formatter( formatter::thread_id(), "{T%}-_ " );
+    g_l->writer().add_formatter( 
+        formatter::named_spacer("[%idx%] %time% (T%thread%) ")
+            .add( "idx", formatter::idx())
+            .add( "thread", formatter::thread_id())
+            .add( "time", formatter::time("$mm"))
+    );
+
     g_l->writer().add_formatter( formatter::append_newline_if_needed() );
     g_l->writer().add_destination( destination::file("out.txt") );
     g_l->writer().add_destination( destination::cout() );

Modified: sandbox/logging/lib/logging/samples/scenarios/custom_fmt_dest.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/custom_fmt_dest.cpp	(original)
+++ sandbox/logging/lib/logging/samples/scenarios/custom_fmt_dest.cpp	2007-11-30 \
16:27:25 EST (Fri, 30 Nov 2007) @@ -116,7 +116,7 @@
     // Step 7: add formatters and destinations
     //         That is, how the message is to be formatted and where should it be \
written to  
-    g_l->writer().add_formatter( formatter::idx() );
+    g_l->writer().add_formatter( formatter::idx(), "[%] " );
     g_l->writer().add_formatter( formatter::append_newline() );
     g_l->writer().add_formatter( secs_since_start() );
 

Modified: sandbox/logging/lib/logging/samples/scenarios/ded_loger_one_filter.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/ded_loger_one_filter.cpp	(original)
+++ sandbox/logging/lib/logging/samples/scenarios/ded_loger_one_filter.cpp	2007-11-30 \
16:27:25 EST (Fri, 30 Nov 2007) @@ -109,7 +109,7 @@
     // Step 7: add formatters and destinations
     //         That is, how the message is to be formatted and where should it be \
written to  
-    g_l->writer().add_formatter( formatter::idx() );
+    g_l->writer().add_formatter( formatter::idx(), "[%] "  );
     g_l->writer().add_formatter( formatter::time("$mm:$ss ") );
     g_l->writer().add_formatter( formatter::append_newline() );
     g_l->writer().add_destination( destination::file("out.txt") );

Modified: sandbox/logging/lib/logging/samples/scenarios/mul_levels_mul_logers.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/mul_levels_mul_logers.cpp	(original)
                
+++ sandbox/logging/lib/logging/samples/scenarios/mul_levels_mul_logers.cpp	2007-11-30 \
16:27:25 EST (Fri, 30 Nov 2007) @@ -96,7 +96,7 @@
     //         That is, how the message is to be formatted and where should it be \
written to  
     // Err log
-    g_log_err->writer().add_formatter( formatter::idx() );
+    g_log_err->writer().add_formatter( formatter::idx(), "[%] "  );
     g_log_err->writer().add_formatter( formatter::time("$hh:$mm.$ss ") );
     g_log_err->writer().add_formatter( formatter::append_newline() );
     g_log_err->writer().add_destination( destination::file("err.txt") );

Modified: sandbox/logging/lib/logging/samples/scenarios/mul_levels_one_logger.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/mul_levels_one_logger.cpp	(original)
                
+++ sandbox/logging/lib/logging/samples/scenarios/mul_levels_one_logger.cpp	2007-11-30 \
16:27:25 EST (Fri, 30 Nov 2007) @@ -53,7 +53,7 @@
 void test_mul_levels_one_logger() {
     // Step 7: add formatters and destinations
     //         That is, how the message is to be formatted...
-    g_l->writer().add_formatter( formatter::idx() );
+    g_l->writer().add_formatter( formatter::idx(), "[%] "  );
     g_l->writer().add_formatter( formatter::time("$hh:$mm.$ss ") );
     g_l->writer().add_formatter( formatter::append_newline() );
 

Modified: sandbox/logging/lib/logging/samples/scenarios/mul_loggers_one_filter.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/mul_loggers_one_filter.cpp	(original)
                
+++ sandbox/logging/lib/logging/samples/scenarios/mul_loggers_one_filter.cpp	2007-11-30 \
16:27:25 EST (Fri, 30 Nov 2007) @@ -93,7 +93,7 @@
     //         That is, how the message is to be formatted and where should it be \
written to  
     // Err log
-    g_log_err->writer().add_formatter( formatter::idx() );
+    g_log_err->writer().add_formatter( formatter::idx(), "[%] "  );
     g_log_err->writer().add_formatter( formatter::time("$hh:$mm.$ss ") );
     g_log_err->writer().add_formatter( formatter::append_newline() );
     g_log_err->writer().add_destination( destination::file("err.txt") );

Modified: sandbox/logging/lib/logging/samples/scenarios/no_levels_with_route.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/no_levels_with_route.cpp	(original)
+++ sandbox/logging/lib/logging/samples/scenarios/no_levels_with_route.cpp	2007-11-30 \
16:27:25 EST (Fri, 30 Nov 2007) @@ -80,7 +80,7 @@
 void no_levels_with_route_example() {
     // Step 7: add formatters and destinations
     //         That is, how the message is to be formatted...
-    g_l->writer().add_formatter( formatter::idx() );
+    g_l->writer().add_formatter( formatter::idx(), "[%] "  );
     g_l->writer().add_formatter( formatter::time("$hh:$mm.$ss ") );
     g_l->writer().add_formatter( formatter::append_newline() );
 

Modified: sandbox/logging/lib/logging/samples/scenarios/one_loger_one_filter.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/one_loger_one_filter.cpp	(original)
+++ sandbox/logging/lib/logging/samples/scenarios/one_loger_one_filter.cpp	2007-11-30 \
16:27:25 EST (Fri, 30 Nov 2007) @@ -62,7 +62,7 @@
     // Step 7: add formatters and destinations
     //         That is, how the message is to be formatted and where should it be \
written to  
-    g_l->writer().add_formatter( formatter::idx() );
+    g_l->writer().add_formatter( formatter::idx(), "[%] "  );
     g_l->writer().add_formatter( formatter::append_newline_if_needed() );
     g_l->writer().add_destination( destination::file("out.txt") );
     g_l->writer().add_destination( destination::cout() );

Modified: sandbox/logging/lib/logging/samples/scenarios/ts_loger_one_filter.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/ts_loger_one_filter.cpp	(original)
+++ sandbox/logging/lib/logging/samples/scenarios/ts_loger_one_filter.cpp	2007-11-30 \
16:27:25 EST (Fri, 30 Nov 2007) @@ -101,8 +101,8 @@
     // Step 7: add formatters and destinations
     //         That is, how the message is to be formatted and where should it be \
written to  
-    g_l->writer().add_formatter( formatter::idx() );
-    g_l->writer().add_formatter( formatter::thread_id() );
+    g_l->writer().add_formatter( formatter::idx(), "[%] "  );
+    g_l->writer().add_formatter( formatter::thread_id(), "[T%] "  );
     g_l->writer().add_formatter( formatter::append_newline() );
     g_l->writer().add_destination( destination::file("out.txt") );
     g_l->writer().add_destination( destination::cout() );

Modified: sandbox/logging/lib/logging/samples/scenarios/using_tags.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/using_tags.cpp	(original)
+++ sandbox/logging/lib/logging/samples/scenarios/using_tags.cpp	2007-11-30 16:27:25 \
EST (Fri, 30 Nov 2007) @@ -40,6 +40,7 @@
 
 #include <boost/logging/format_ts.hpp>
 #include <boost/logging/format/formatter/tags.hpp>
+#include <boost/logging/format/formatter/named_spacer.hpp>
 
 using namespace boost::logging;
 
@@ -70,10 +71,13 @@
 void using_tags_example() {
     // Step 7: add formatters and destinations
     //         That is, how the message is to be formatted and where should it be \
                written to
-    g_l->writer().add_formatter( formatter::tag::time("$mm:$ss ") );            // \
                time tag
-    g_l->writer().add_formatter( formatter::idx() );
-    g_l->writer().add_formatter( formatter::tag::thread_id() );                 // \
                thread_id tag
-    g_l->writer().add_formatter( formatter::tag::file_line() );                 // \
file/line tag +
+    g_l->writer().add_formatter( formatter::named_spacer( "%fileline% [T%thread_id%] \
[%idx%] %time%" ) +        .add( "time", formatter::tag::time("$mm:$ss ") )           \
// time tag +        .add( "idx", formatter::idx() )                            
+        .add( "thread_id", formatter::tag::thread_id() )                // thread_id \
tag +        .add( "fileline", formatter::tag::file_line() ) );              // \
file/line tag +
     g_l->writer().add_formatter( formatter::append_newline() );     
     g_l->writer().add_destination( destination::cout() );
     g_l->writer().add_destination( destination::file("out.txt") );

Modified: sandbox/logging/lib/logging/samples/scenarios/your_scenario.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/your_scenario.cpp	(original)
+++ sandbox/logging/lib/logging/samples/scenarios/your_scenario.cpp	2007-11-30 \
16:27:25 EST (Fri, 30 Nov 2007) @@ -120,7 +120,7 @@
     //         That is, how the message is to be formatted and where should it be \
written to  
     // Err log
-    g_log_err->writer().add_formatter( formatter::idx() );
+    g_log_err->writer().add_formatter( formatter::idx(), "[%] "  );
     g_log_err->writer().add_formatter( formatter::time("$hh:$mm.$ss ") );
     g_log_err->writer().add_formatter( formatter::append_newline() );
     g_log_err->writer().add_destination( destination::file("err.txt") );
_______________________________________________
Boost-commit mailing list
Boost-commit@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-commit


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic