Boost logo

Boost-Commit :

From: john.groups_at_[hidden]
Date: 2007-10-20 06:37:02


Author: jtorjo
Date: 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
New Revision: 40207
URL: http://svn.boost.org/trac/boost/changeset/40207

Log:
v0.8, 20 oct 2007
- added use_format_write class
- removed the filter from the logger class (need to update documentation)
- added Common scenario

Added:
   sandbox/logging/boost/logging/detail/raw_doc/old_examples.hpp (contents, props changed)
   sandbox/logging/boost/logging/detail/use_format_write.hpp (contents, props changed)
   sandbox/logging/boost/logging/format_all.hpp (contents, props changed)
   sandbox/logging/lib/logging/samples/scenarios/
   sandbox/logging/lib/logging/samples/scenarios/mul_levels_one_logger.cpp (contents, props changed)
   sandbox/logging/lib/logging/tests/obsolete.txt (contents, props changed)
Properties modified:
   sandbox/logging/lib/logging/doc/ (props changed)
Text files modified:
   sandbox/logging/boost/logging/defaults.hpp | 15 +++
   sandbox/logging/boost/logging/detail/fwd.hpp | 35 +++++++++
   sandbox/logging/boost/logging/detail/manipulator.hpp | 54 +++++++++++--
   sandbox/logging/boost/logging/detail/raw_doc/common_usage.hpp | 39 +++++----
   sandbox/logging/boost/logging/detail/raw_doc/fixme.hpp | 26 +++++-
   sandbox/logging/boost/logging/detail/raw_doc/main.hpp | 147 ++-------------------------------------
   sandbox/logging/boost/logging/detail/raw_doc/table_of_contents.hpp | 4
   sandbox/logging/boost/logging/detail/raw_doc/workflow.hpp | 3
   sandbox/logging/boost/logging/detail/util.hpp | 14 +++
   sandbox/logging/boost/logging/filter.hpp | 79 +++++++++-----------
   sandbox/logging/boost/logging/format.hpp | 10 +
   sandbox/logging/boost/logging/format/destination/convert_destination.hpp | 18 ++--
   sandbox/logging/boost/logging/format/destination/defaults.hpp | 23 ++++-
   sandbox/logging/boost/logging/format/destination/file.hpp | 52 +++++++++----
   sandbox/logging/boost/logging/format/destination/rolling_file.hpp | 54 +++++--------
   sandbox/logging/boost/logging/format/destination/shared_memory.hpp | 18 +++-
   sandbox/logging/boost/logging/format/formatter/convert_format.hpp | 25 +++++-
   sandbox/logging/boost/logging/format/formatter/defaults.hpp | 17 ++-
   sandbox/logging/boost/logging/format/formatter/thread_id.hpp | 12 ++-
   sandbox/logging/boost/logging/format/formatter/time.hpp | 66 ++++++++++-------
   sandbox/logging/boost/logging/format/op_equal.hpp | 75 +-------------------
   sandbox/logging/boost/logging/level.hpp | 7 +
   sandbox/logging/boost/logging/logging.hpp | 2
   sandbox/logging/boost/logging/macros.hpp | 85 +++++++++++++++++++++++
   sandbox/logging/boost/logging/writer/format_write.hpp | 14 ++-
   sandbox/logging/lib/logging/samples/vc8/loggingvc8/loggingvc8.vcproj | 23 +++++
   sandbox/logging/lib/logging/src/changelog.txt | 4 +
   27 files changed, 505 insertions(+), 416 deletions(-)

Modified: sandbox/logging/boost/logging/defaults.hpp
==============================================================================
--- sandbox/logging/boost/logging/defaults.hpp (original)
+++ sandbox/logging/boost/logging/defaults.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -74,16 +74,28 @@
         struct no_ts;
     }
 
+ namespace level {
+ struct holder_no_ts ;
+ struct holder_ts ;
+ struct holder_tls_with_cache ;
+ }
+
 
 
     struct default_types {
+#ifdef UNICODE
+ typedef wchar_t char_type;
+#else
         typedef char char_type;
+#endif
         // this is the type we use to hold a string, internally
- typedef std::string hold_string_type;
+ typedef std::basic_string<char_type> hold_string_type;
 
         // default filter type
         typedef filter::no_ts filter_type;
 
+ typedef level::holder_no_ts level_holder_type;
+
         struct lock_resource {
             template<class lock_type> struct finder {
                 typedef typename locker::ts_resource<lock_type> type;
@@ -91,7 +103,6 @@
         };
 
         typedef boost::logging::threading::mutex mutex;
-
     };
 
     // FIXME we need defaults for different scenarios!

Modified: sandbox/logging/boost/logging/detail/fwd.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/fwd.hpp (original)
+++ sandbox/logging/boost/logging/detail/fwd.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -30,7 +30,7 @@
 // minimize inclusion of STL headers in our headers!!!
 #include <string>
 
-
+#define BOOST_LOGGING_STR(x) ansi_unicode_char_holder ( x, L ## x)
 
 
 /*
@@ -46,6 +46,7 @@
     typedef types<override>::hold_string_type hold_string_type;
     typedef types<override>::filter_type filter_type;
     typedef types<override>::mutex mutex;
+ typedef types<override>::level_holder_type level_holder_type;
 
     namespace writer {}
 
@@ -55,6 +56,38 @@
         just in case you're doing a typo - "write" instead of "writer"
     */
     namespace write = writer;
+
+
+
+
+
+
+namespace detail {
+ template<class self_type, class type> struct flag_with_self_type {
+ flag_with_self_type(self_type * self, const type& val = type() ) : m_val(val), m_self(self) {}
+ flag_with_self_type(const flag_with_self_type & other) : m_val(other.m_val) {}
+
+ const type & operator()() const { return m_val; }
+ self_type & operator()(const type & val) {
+ m_val = val; return *m_self;
+ }
+
+ void operator=(const self_type & other) {
+ m_val = other.m_val;
+ }
+
+ private:
+ type m_val;
+ self_type * m_self;
+ };
+
+ template<class self_type> struct flag {
+ template<class val_type> struct t : flag_with_self_type<self_type,val_type> {
+ t(self_type * self, const val_type& val = val_type() ) : flag_with_self_type(self,val) {}
+ };
+ };
+}
+
 }}
 
 

Modified: sandbox/logging/boost/logging/detail/manipulator.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/manipulator.hpp (original)
+++ sandbox/logging/boost/logging/detail/manipulator.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -21,17 +21,16 @@
 # pragma once
 #endif
 
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+// 'class1' : inherits 'class2::member' via dominance
+#pragma warning ( disable : 4250)
+#endif
+
 #include <boost/logging/detail/fwd.hpp>
 
 namespace boost { namespace logging {
 
 
-typedef enum implement_op_equal {
- op_equal_no_context,
- op_equal_has_context
-};
-
-
 /**
 @brief Manipulators = Formatters and/or destinations.
 
@@ -125,6 +124,8 @@
 In the above case, if you were to write:
 
 @code
+#define L_ ... // defining the logger
+
 int i = 1;
 L_ << "this is so cool" << i++;
 @endcode
@@ -262,19 +263,33 @@
 
     typedef typename boost::remove_const<param>::type non_const_param;
     // used as msg_type in format_and_write classes
- typedef typename boost::remove_reference<non_const_param> raw_param;
+ typedef typename boost::remove_reference<non_const_param>::type raw_param;
 
     virtual ~base() {}
     virtual void operator()(param val) const = 0;
 };
 
 
+
+
+/**
+ @brief When you implement your manipulator class, how is operator== to be implemented?
+*/
+struct implement_op_equal {
+ typedef enum type {
+ /// manipulator has no context - that is, any two values of this type are considered equal (operator== will automatically return true)
+ no_context,
+ /// manipulator has context - that is, you <b>have to</b> implement operator== in your manipulator class
+ has_context
+ };
+};
+
 namespace detail {
- template<implement_op_equal> struct op_equal_base {
+ template<implement_op_equal::type> struct op_equal_base {
         bool operator==(const op_equal_base& ) const { return true; }
     };
 
- template<> struct op_equal_base<op_equal_has_context> {};
+ template<> struct op_equal_base<implement_op_equal::has_context> {};
 }
 
 /**
@@ -282,7 +297,7 @@
 
     x
 */
-template<class type, class base_type, implement_op_equal op_e> struct class_
+template<class type, class base_type, implement_op_equal::type op_e> struct class_
     : base_type,
       detail::op_equal_base<op_e>,
       boost::logging::op_equal::same_type_op_equal<type> {
@@ -379,12 +394,20 @@
 namespace detail {
 
     // holds the generic manipulator, and forwards to it
- template<class generic_type, class manipulator_base> struct generic_holder : manipulator_base {
+ template<class generic_type, class manipulator_base> struct generic_holder
+ : class_<
+ generic_holder<generic_type,manipulator_base>,
+ manipulator_base,
+ implement_op_equal::has_context> {
         typedef typename manipulator_base::param param;
 
         generic_type m_val;
         generic_holder(const generic_type & val) : m_val(val) {}
 
+ bool operator==(const generic_holder& other) const {
+ return m_val == other.m_val;
+ }
+
         virtual void operator()(param val) const {
             m_val.operator()(val);
         }
@@ -428,6 +451,10 @@
     */
     typedef boost::logging::manipulator::is_generic is_generic;
 
+ /**
+ @sa boost::logging::manipulator::implement_op_equal
+ */
+ typedef boost::logging::manipulator::implement_op_equal implement_op_equal;
 }
 
 /**
@@ -454,6 +481,11 @@
         @sa boost::logging::manipulator::is_generic
     */
     typedef boost::logging::manipulator::is_generic is_generic;
+
+ /**
+ @sa boost::logging::manipulator::implement_op_equal
+ */
+ typedef boost::logging::manipulator::implement_op_equal implement_op_equal;
 }
 
 }}

Modified: sandbox/logging/boost/logging/detail/raw_doc/common_usage.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/common_usage.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/common_usage.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -3,28 +3,31 @@
 /**
 @page common_usage Scenario 1: Common Usage
 
-define the class_ - with @param
+Scenario 1 should be the most common:
+- You have multiple levels (in this example: debug < info < error)
+- You want to format the message before it's written
+ (in this example: prefix it by index, by time, and append an enter to it)
+- You have <b>one log</b>, which writes to several log destinations
+ (in this example: the console, the output window, and a file
+
+In our example, the output will be written to the console, debug window, and "out.txt" file.
+It will look similar to this one:
+
+@code
+12:59.27 [1] this is so cool 1
+12:59.27 [2] hello, world
+12:59.27 [3] good to be back ;) 2
+@endcode
+
+To take a look at the code for example, see:
+
+@htmlonly
+Scenario 1 Code
+@endhtmlonly
 
-- with levels
-- write to different thingies
-- etc
-
-Explain about samples!
 
 
 
-have 3 scenarios
-- several levels, same log
-- several levels, different logs
-- with custom router FIXME (that is, use cache_string_several_str())
-- one logger; several levels - use a sink (that is, see how we find "is_enabled")
- - we can simply use the level.is_enabled(xxx) question, and then write to the log
-- no levels
-- etc
-- fastest , no <<
-- fastest , using <<
-- using your own formatters and destinations integrated
-
 */
 
 }}

Modified: sandbox/logging/boost/logging/detail/raw_doc/fixme.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/fixme.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/fixme.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -1,9 +1,28 @@
 /*
-compile all!
+FIXME change the workflow & logger's definition - it doesn't need a filter, but it can have one!
+
+
+
+
+scenarios:
+have 3 scenarios
+- several levels, same log
+- several levels, different logs
+- with custom router FIXME (that is, use cache_string_several_str())
+- one logger; several levels - use a sink (that is, see how we find "is_enabled")
+ - we can simply use the level.is_enabled(xxx) question, and then write to the log
+- no levels
+- etc
+- fastest , no <<
+- fastest , using <<
+- using your own formatters and destinations integrated
+
+
+FIXME after showing scenarios, show customizing?
+
+
 
 
-in examples:
-write the results of each!!!!
 
 
 
@@ -17,7 +36,6 @@
 
 writer namespace , etc.
 compilers
-where the code is - boost-sandbox
 
 
 convert- also explain that you can convert from str x to y; for instance write_time can actually append the time (instead of prepending it - default)!

Modified: sandbox/logging/boost/logging/detail/raw_doc/main.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/main.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/main.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -4,7 +4,8 @@
 @page main_intro Boost Logging Library v2 : Introduction
 
 - @ref main_motivation
-- @ref main_examples
+- @ref main_example1
+- @ref main_example2
 
 @section main_motivation Motivation
 
@@ -36,147 +37,19 @@
       you can define your own writing mechanism
 - Easy manipulation of the logs (turning on/off, setting formatters, destinations, etc)
 
+@section main_example1 Example 1 (Common Scenario)
 
-_at_section main_examples Examples
+First example is the common scenario:
+- You have multiple levels
+- You want to format the message before it's written
+- You have <b>one log</b>, which writes to several log destinations
 
-To see all its power, here are a few examples:
+@ref common_usage "Take a look"
 
+@section main_example2 Example 2
 
+More examples coming soon!
 
-\n\n
-Example 1: you choose to use the <i>L_(msg)</i> sytax:
-
-_at_code
-#include <boost/logging/logging.hpp>
-
-using namespace boost::logging;
-struct write_to_cout_and_file { ... };
-
-// defining the logs
-logger<write_to_cout_and_file, filter::no_ts> g_single_log("out.txt");
-#define L_(x) if ( g_single_log) g_single_log.process_msg()(x)
-
-// code
-L_("reading word " + word);
-_at_endcode
-
-
-
-\n\n
-Example 2: you choose to use the <i>L_ << "some " << " cool " << "log message"</i> syntax
-
-_at_code
-#include <boost/logging/logging.hpp>
-#include <boost/logging/process_msg.hpp>
-
-struct write_to_file { ... };
-struct write_to_cout { ... };
-struct write_to_dbg { ... };
-
-using namespace boost::logging;
-
-// defining the logs
-typedef process_msg< gather::ostream_like::return_str<>, write_to_cout> processor_cout;
-typedef process_msg< gather::ostream_like::return_str<>, write_to_file> processor_file;
-typedef process_msg< gather::ostream_like::return_str<>, write_to_dbg> processor_dbg;
-
-logger<processor_cout, filter::no_ts> g_log_app;
-logger<processor_file, filter::no_ts> g_log_err("err.txt");
-logger<processor_dbg, filter::no_ts> g_log_dbg;
-
-#define LAPP_ if ( !g_log_app) ; else g_log_app->read_msg().gather().out()
-#define LERR_ if ( !g_log_err) ; else g_log_err->read_msg().gather().out()
-#define LDBG_ if ( !g_log_dbg) ; else g_log_dbg->read_msg().gather().out()
-
-// code
-LAPP_ << idx << " : reading word " << word;
-LERR_ << "error at " << idx << ", while reading " << word;
-LDBG_ << "debug info: " << idx << ", reading " << word;
-_at_endcode
-
-
-
-\n\n
-Example 3: you choose to use the same syntax as Example 2, but also use formatters and destinations.
-
-_at_code
-#include <boost/logging/logging.hpp>
-#include <boost/logging/format/optimize.hpp>
-#include <boost/logging/process_msg/ostream_like.hpp>
-#include <boost/logging/format.hpp>
-
-using namespace boost::logging;
-
-...
-
-typedef optimize::cache_string_one_str<> cache_string;
-typedef process_msg<
- gather::ostream_like::return_cache_str<> ,
- format_write<
- format_base,
- destination_base, format_and_write::simple<cache_string> > > process;
-logger<process, filter::no_ts> g_l;
-
-#define L_ if ( !g_l) ; else g_l->read_msg().gather().out()
-
-int main() {
- // add formatters : [idx] [time] message [enter]
- g_l->writer().add_formatter( write_idx() );
- g_l->writer().add_formatter( write_time() );
- g_l->writer().add_formatter( append_enter() );
-
- // write to cout and file
- g_l->writer().add_destination( write_to_cout() );
- g_l->writer().add_destination( write_to_file("out.txt") );
-
- int i = 1;
- L_ << "will be prefixed by index and time , enter is appended as well " << i++;
-}
-
-_at_endcode
-
-
-
-\n\n
-Example 4: you choose to use levels
-
-_at_code
-using namespace boost::logging;
-
-struct write_to_file { ... };
-
-typedef process_msg< gather::ostream_like::return_str<>, write_to_file> processor;
-
-level::holder_no_ts level_holder;
-
-typedef logger<processor, filter_level<level::holder_no_ts, level::debug> > debug_logger;
-typedef logger<processor, filter_level<level::holder_no_ts, level::error> > error_logger;
-typedef logger<processor, filter_level<level::holder_no_ts, level::info> > info_logger;
-
-// debug info goes into "dbg.txt" file
-// error info goes into "err.txt" file
-// app info goes into "out.txt" file
-debug_logger g_log_dbg( init_both, "dbg.txt", &level_holder );
-error_logger g_log_err( init_both, "err.txt", &level_holder );
-info_logger g_log_app( init_both, "out.txt", &level_holder );
-
-
-#define LAPP_ if ( !g_log_app) ; else g_log_app->read_msg().gather().out()
-#define LERR_ if ( !g_log_err) ; else g_log_err->read_msg().gather().out()
-#define LDBG_ if ( !g_log_dbg) ; else g_log_dbg->read_msg().gather().out()
-
-int main() {
- // set level at this time, print everything
- level_holder.set_enabled(level::info);
- ...
- LAPP_ << "info at : " << idx << " : reading word " << word;
- ...
- // only errors and above
- level_holder.set_enabled(level::error);
- LDBG_ << "this will not be printed";
-}
-
-_at_endcode
 
 
 */

Added: sandbox/logging/boost/logging/detail/raw_doc/old_examples.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/detail/raw_doc/old_examples.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -0,0 +1,153 @@
+namespace boost { namespace logging {
+
+/**
+@page old_examples Old examples - to be removed
+
+
+
+
+@section main_examples Examples
+
+To see all its power, here are a few examples:
+
+
+
+\n\n
+Example 1: you choose to use the <i>L_(msg)</i> sytax:
+
+@code
+#include <boost/logging/logging.hpp>
+
+using namespace boost::logging;
+struct write_to_cout_and_file { ... };
+
+// defining the logs
+logger<write_to_cout_and_file, filter::no_ts> g_single_log("out.txt");
+#define L_(x) if ( g_single_log) g_single_log.process_msg()(x)
+
+// code
+L_("reading word " + word);
+@endcode
+
+
+
+\n\n
+Example 2: you choose to use the <i>L_ << "some " << " cool " << "log message"</i> syntax
+
+@code
+#include <boost/logging/logging.hpp>
+#include <boost/logging/process_msg.hpp>
+
+struct write_to_file { ... };
+struct write_to_cout { ... };
+struct write_to_dbg { ... };
+
+using namespace boost::logging;
+
+// defining the logs
+typedef process_msg< gather::ostream_like::return_str<>, write_to_cout> processor_cout;
+typedef process_msg< gather::ostream_like::return_str<>, write_to_file> processor_file;
+typedef process_msg< gather::ostream_like::return_str<>, write_to_dbg> processor_dbg;
+
+logger<processor_cout, filter::no_ts> g_log_app;
+logger<processor_file, filter::no_ts> g_log_err("err.txt");
+logger<processor_dbg, filter::no_ts> g_log_dbg;
+
+#define LAPP_ if ( !g_log_app) ; else g_log_app->read_msg().gather().out()
+#define LERR_ if ( !g_log_err) ; else g_log_err->read_msg().gather().out()
+#define LDBG_ if ( !g_log_dbg) ; else g_log_dbg->read_msg().gather().out()
+
+// code
+LAPP_ << idx << " : reading word " << word;
+LERR_ << "error at " << idx << ", while reading " << word;
+LDBG_ << "debug info: " << idx << ", reading " << word;
+@endcode
+
+
+
+\n\n
+Example 3: you choose to use the same syntax as Example 2, but also use formatters and destinations.
+
+@code
+#include <boost/logging/logging.hpp>
+#include <boost/logging/format/optimize.hpp>
+#include <boost/logging/process_msg/ostream_like.hpp>
+#include <boost/logging/format.hpp>
+
+using namespace boost::logging;
+
+...
+
+typedef optimize::cache_string_one_str<> cache_string;
+typedef process_msg<
+ gather::ostream_like::return_cache_str<> ,
+ format_write<
+ format_base,
+ destination_base, format_and_write::simple<cache_string> > > process;
+logger<process, filter::no_ts> g_l;
+
+#define L_ if ( !g_l) ; else g_l->read_msg().gather().out()
+
+int main() {
+ // add formatters : [idx] [time] message [enter]
+ g_l->writer().add_formatter( write_idx() );
+ g_l->writer().add_formatter( write_time() );
+ g_l->writer().add_formatter( append_enter() );
+
+ // write to cout and file
+ g_l->writer().add_destination( write_to_cout() );
+ g_l->writer().add_destination( write_to_file("out.txt") );
+
+ int i = 1;
+ L_ << "will be prefixed by index and time , enter is appended as well " << i++;
+}
+
+@endcode
+
+
+
+\n\n
+Example 4: you choose to use levels
+
+@code
+using namespace boost::logging;
+
+struct write_to_file { ... };
+
+typedef process_msg< gather::ostream_like::return_str<>, write_to_file> processor;
+
+level::holder_no_ts level_holder;
+
+typedef logger<processor, filter_level<level::holder_no_ts, level::debug> > debug_logger;
+typedef logger<processor, filter_level<level::holder_no_ts, level::error> > error_logger;
+typedef logger<processor, filter_level<level::holder_no_ts, level::info> > info_logger;
+
+// debug info goes into "dbg.txt" file
+// error info goes into "err.txt" file
+// app info goes into "out.txt" file
+debug_logger g_log_dbg( init_both, "dbg.txt", &level_holder );
+error_logger g_log_err( init_both, "err.txt", &level_holder );
+info_logger g_log_app( init_both, "out.txt", &level_holder );
+
+
+#define LAPP_ if ( !g_log_app) ; else g_log_app->read_msg().gather().out()
+#define LERR_ if ( !g_log_err) ; else g_log_err->read_msg().gather().out()
+#define LDBG_ if ( !g_log_dbg) ; else g_log_dbg->read_msg().gather().out()
+
+int main() {
+ // set level at this time, print everything
+ level_holder.set_enabled(level::info);
+ ...
+ LAPP_ << "info at : " << idx << " : reading word " << word;
+ ...
+ // only errors and above
+ level_holder.set_enabled(level::error);
+ LDBG_ << "this will not be printed";
+}
+
+@endcode
+
+
+*/
+
+}}

Modified: sandbox/logging/boost/logging/detail/raw_doc/table_of_contents.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/table_of_contents.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/table_of_contents.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -3,9 +3,11 @@
 /**
 @mainpage Boost Logging Library v2 - Table of contents
 
+
 - @ref main_intro
     - @ref main_motivation
- - @ref main_examples
+ - @ref main_example1
+ - @ref main_example2
 - @ref workflow
     - @ref workflow_introduction
     - @ref workflow_filter

Modified: sandbox/logging/boost/logging/detail/raw_doc/workflow.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/workflow.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/workflow.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -11,7 +11,8 @@
 - @ref workflow_2b
 
 
-
+@attention
+The filter is not kept in the logger anymore. They are different concepts. Need to update these pages
 
 @section workflow_introduction Introduction
 

Added: sandbox/logging/boost/logging/detail/use_format_write.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/detail/use_format_write.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -0,0 +1,94 @@
+// Template.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_TEMPLATE_HPP_DEFINED
+#define JT28092007_TEMPLATE_HPP_DEFINED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/logging/detail/fwd.hpp>
+#include <boost/logging/format/optimize.hpp>
+#include <boost/logging/process_msg/ostream_like.hpp>
+
+namespace boost { namespace logging {
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // specialize logger for format_write class
+ //
+
+
+ namespace detail {
+ template<class param> struct find_gather {};
+ template<> struct find_gather< std::basic_string<char_type> > { typedef gather::ostream_like::return_str<> 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> > type;
+ };
+
+ template< class string_type>
+ struct find_gather< boost::logging::optimize::cache_string_several_str<string_type> > {
+ typedef gather::ostream_like::return_cache_str< boost::logging::optimize::cache_string_several_str<string_type> > type;
+ };
+ }
+
+/**
+@brief Makes it easier to use a logger with format_write class
+
+You just define your <tt>logger<...> </tt> class like this:
+
+@code
+typedef logger< use_format_write<format_base,destination_base> logger_type;
+@endcode
+
+instead of
+
+@code
+typedef logger< process_msg<
+ gather::ostream_like::return_str<>,
+ writer::format_write<formatter_base,destination_base> > > logger_type;
+@endcode
+
+FIXME need to have more template params
+
+@param format_base your formatter base class
+@param destination_base your destination base class
+*/
+template<class format_base, class destination_base> struct use_format_write {
+ typedef typename format_base::raw_param format_param;
+ typedef typename detail::find_gather<format_param>::type gather_type;
+};
+
+template<class format_base, class destination_base> struct logger< use_format_write<format_base, destination_base> >
+ : logger_base<
+ process_msg<
+ typename use_format_write<format_base, destination_base>::gather_type,
+ writer::format_write<format_base,destination_base> > >
+{
+ typedef typename logger_base<
+ process_msg<
+ typename use_format_write<format_base, destination_base>::gather_type,
+ writer::format_write<format_base,destination_base> > > logger_base_type;
+
+ logger() {}
+ BOOST_LOGGING_FORWARD_CONSTRUCTOR(logger, logger_base_type)
+};
+
+}}
+
+#endif
+

Modified: sandbox/logging/boost/logging/detail/util.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/util.hpp (original)
+++ sandbox/logging/boost/logging/detail/util.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -21,6 +21,8 @@
 # pragma once
 #endif
 
+
+
 /*
     make sure we don't need any of our headers included from here!
     we're included from fwd.hpp!
@@ -44,6 +46,18 @@
         type val;
     };
 
+
+
+
+ struct ansi_unicode_char_holder {
+ const char * str;
+ const wchar_t * wstr;
+ ansi_unicode_char_holder(const char * str, const wchar_t * wstr) : str(str), wstr(wstr) {}
+
+ operator const char*() const { return str; }
+ operator const wchar_t*() const { return wstr; }
+ };
+
 }}
 
 #endif

Modified: sandbox/logging/boost/logging/filter.hpp
==============================================================================
--- sandbox/logging/boost/logging/filter.hpp (original)
+++ sandbox/logging/boost/logging/filter.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -180,35 +180,35 @@
 
 } // namespace filter
 
- namespace detail {
- template<class type> struct process_msg_holder {
- process_msg_holder() {}
-
- BOOST_LOGGING_FORWARD_CONSTRUCTOR(process_msg_holder, m_processor)
-
- type const & process_msg() const { return m_processor; }
- type & process_msg() { return m_processor; }
- private:
- type m_processor;
- };
- }
 
     /**
- @brief Helper, used to initialize both filter and process_msg_holder, from a logger.
+ @brief Base class for all loggers
+ */
+ template<class process_msg_type_ > struct logger_base {
+ typedef process_msg_type_ process_msg_type;
 
- Example:
+ logger_base() {}
 
- @code
- logger<...> l(init_both, param_to_initialize_process, param_to_initialize_filter);
- @endcode
- */
- struct init_both_t {};
- namespace { init_both_t init_both; }
+ BOOST_LOGGING_FORWARD_CONSTRUCTOR(logger_base, m_processor)
+
+ /**
+ The only way to get to the message processor. Allow writing <tt>logger->some_method(x);</tt>
+ */
+ const process_msg_type* operator->() const { return &m_processor; }
+ process_msg_type* operator->() { return &m_processor; }
+
+ // in the future, this little class counts, since it'll expose a small virtual interface
+ // to allow BOOST_DECLARE_LOG/BOOST_DEFINE_LOG
+ //
+ // it also counts since it's the same interface as log_keeper
+ private:
+ process_msg_type m_processor;
+ };
 
     /**
     @brief The logger class. Every log from your application is an instance of this.
 
- The logger has a filter, and a message processor, which will process the message if the log is enabled
+ The logger has a message processor, which will process the message if <i>you decide</i> the log is enabled
     (@ref workflow "see workflow")
 
     The logger derives from the filter, so you can manipulate it as a %filter (enable/disable it, if the %filter allows it)
@@ -249,37 +249,30 @@
     // usage
     L_ << "cool " << "message";
     @endcode
-
- \n\n
 
- @param process_msg_type The message processor. It can be any class that will process the message.
- How the class does the actual processing is up to you - also, based on that you'll @ref macros "define your macro(s)".
- For non-trivial cases, it should be the process_msg class.
 
- @param filter [optional] The filter that says if the log is enabled or not. If not specified, the @ref override_defaults "default is used".
- */
- template<class process_msg_type , class filter = filter_type> struct logger : filter, detail::process_msg_holder<process_msg_type> {
- typedef detail::process_msg_holder<process_msg_type> process_base;
 
- logger() {}
 
- /**
- */
- template<class p1, class p2> logger(const init_both_t&, p1 a1, p2 a2) : filter(a2), process_base(a1) {}
 
+ @note
+ You might think that the logical place for the filter would be in the logger (that is, the logger should own the filter). Well, this is how
+ the interface was at the beginning. However, in practice, it often happens that the same filter be shared be different loggers.
+ So it's best to just have the filter and logger concepts completely separated.
 
- BOOST_LOGGING_FORWARD_CONSTRUCTOR(logger, process_base)
+ FIXME explain how filters work!
 
- operator bool() const { return filter::is_enabled(); }
- bool operator!() const { return !filter::is_enabled(); }
 
- /**
- Syntactic sugar. Allow writing <tt>logger->some_method(x);</tt>, which is equivalent to
- <tt>logger.process_msg().some_method(x);</tt>
- */
- const process_msg_type* operator->() const { return &process_base::process_msg(); }
- process_msg_type* operator->() { return &process_base::process_msg(); }
+ \n\n
 
+ @param process_msg_type The message processor. It can be any class that will process the message.
+ How the class does the actual processing is up to you - also, based on that you'll @ref macros "define your macro(s)".
+ For non-trivial cases, it should be the process_msg class.
+
+ */
+ template<class process_msg_type_ > struct logger : logger_base<process_msg_type_> {
+ typedef logger_base<process_msg_type_> logger_base_type;
+ logger() {}
+ BOOST_LOGGING_FORWARD_CONSTRUCTOR(logger, logger_base_type)
     };
 
 

Modified: sandbox/logging/boost/logging/format.hpp
==============================================================================
--- sandbox/logging/boost/logging/format.hpp (original)
+++ sandbox/logging/boost/logging/format.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -536,9 +536,6 @@
     } // namespace msg_route
 
 
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // format_write class
- //
 
 
 
@@ -547,5 +544,12 @@
 #include <boost/logging/detail/manipulator.hpp>
 #include <boost/logging/writer/format_write.hpp>
 
+#include <boost/logging/format/formatter/defaults.hpp>
+#include <boost/logging/format/destination/defaults.hpp>
+#include <boost/logging/process_msg/ostream_like.hpp>
+
+
+
+
 #endif
 

Modified: sandbox/logging/boost/logging/format/destination/convert_destination.hpp
==============================================================================
--- sandbox/logging/boost/logging/format/destination/convert_destination.hpp (original)
+++ sandbox/logging/boost/logging/format/destination/convert_destination.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -1,4 +1,4 @@
-// Template.hpp
+// convert_destination.hpp
 
 // Boost Logging library
 //
@@ -14,8 +14,8 @@
 // See http://www.torjo.com/log2/ for more details
 
 
-#ifndef JT28092007_TEMPLATE_HPP_DEFINED
-#define JT28092007_TEMPLATE_HPP_DEFINED
+#ifndef JT28092007_convert_destination_HPP_DEFINED
+#define JT28092007_convert_destination_HPP_DEFINED
 
 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
 # pragma once
@@ -37,11 +37,11 @@
 FIXME
 */
 namespace convert {
- template<class obj, class char_traits, class char_type> void write(const obj & m, std::basic_iostream<char_type, char_traits> & out) {
+ template<class obj, class char_traits, class char_type> void write(const obj & m, std::basic_ostream<char_type, char_traits> & out) {
         out << m;
     }
 
- template<class char_traits, class char_type> void write(const char_type* m, std::basic_iostream<char_type, char_traits> & out) {
+ template<class char_traits, class char_type> void write(const char_type* m, std::basic_ostream<char_type, char_traits> & out) {
         out << m;
     }
 
@@ -54,12 +54,12 @@
 }
 
 struct do_convert_destination {
- template<class msg, class dest> void write(const msg & m, dest & d) {
- convert::write(msg, dest);
+ template<class msg, class dest> static void write(const msg & m, dest & d) {
+ convert::write(m, d);
     }
 
- template<class msg, class dest> dest do_convert(const msg & m, const into<dest> &) {
- convert::do_convert(msg, into<dest>() );
+ template<class msg, class dest> static dest do_convert(const msg & m, const into<dest> &) {
+ return convert::do_convert(m, into<dest>() );
     }
 
 };

Modified: sandbox/logging/boost/logging/format/destination/defaults.hpp
==============================================================================
--- sandbox/logging/boost/logging/format/destination/defaults.hpp (original)
+++ sandbox/logging/boost/logging/format/destination/defaults.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -33,7 +33,8 @@
 /**
     @brief Writes the string to console
 */
-template<class convert_dest = do_convert_destination > struct cout : is_generic, same_type {
+template<class convert_dest = do_convert_destination > struct cout_t : is_generic, boost::logging::op_equal::always_equal {
+
     template<class msg_type> void operator()(const msg_type & msg) const {
 #ifndef UNICODE
         convert_dest::write(msg, std::cout);
@@ -44,13 +45,17 @@
 };
 
 
-template<class convert_dest = do_convert_destination > struct dbg_window {
+/**
+ @brief Writes the string to console
+*/
+template<class convert_dest = do_convert_destination > struct dbg_window_t : is_generic, boost::logging::op_equal::always_equal {
+
     template<class msg_type> void operator()(const msg_type & msg) const {
 #ifdef BOOST_WINDOWS
 #ifndef UNICODE
- ::OutputDebugWindowA( convert_dest::do_convert(msg, into<const char*>() ) );
+ ::OutputDebugStringA( convert_dest::do_convert(msg, into<const char*>() ) );
 #else
- ::OutputDebugWindowW( convert_dest::do_convert(msg, into<const wchar_t*>() ) );
+ ::OutputDebugStringW( convert_dest::do_convert(msg, into<const wchar_t*>() ) );
 #endif
 #else
         // non windows
@@ -59,11 +64,17 @@
     }
 };
 
+/**
+ @brief cout_t with default values. See cout_t
+*/
+typedef cout_t<> cout;
 
+/**
+ @brief dbg_window_t with default values. See dbg_window_t
+*/
+typedef dbg_window_t<> dbg_window;
 
 
-sharing memory
-
 }}}
 
 #endif

Modified: sandbox/logging/boost/logging/format/destination/file.hpp
==============================================================================
--- sandbox/logging/boost/logging/format/destination/file.hpp (original)
+++ sandbox/logging/boost/logging/format/destination/file.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -21,6 +21,12 @@
 # pragma once
 #endif
 
+#if defined(_MSC_VER)
+#pragma warning ( disable : 4355)
+#endif
+
+
+
 #include <boost/logging/detail/fwd.hpp>
 #include <boost/logging/detail/manipulator.hpp>
 #include <boost/logging/format/destination/convert_destination.hpp>
@@ -32,60 +38,70 @@
     @brief settings for when constructing a file class
 */
 struct file_settings {
- file_settings() : m_flush_each_time(true), m_initial_overwrite(false), m_do_append(true) {}
+ typedef detail::flag<file_settings> flag;
 
- file_settings & flush_each_time(bool flush = true) { m_flush_each_time = flush; return *this; }
- file_settings & initial_overwrite(bool overwrite = true) { m_initial_overwrite = overwrite; return *this; }
- file_settings & do_append(bool append) { m_do_append = append; return *this; }
+ file_settings()
+ : flush_each_time(this, true)
+ , initial_overwrite(this, false)
+ , do_append(this, true)
+ , extra_flags(this, 0) {}
 
- file_settings & extra_open_flags(std::ios_base::open_mode extra_flags) { m_extra_flags = extra_flags; return *this; }
 
     /// if true (default), flushes after each write
- bool m_flush_each_time;
+ flag::t<bool> flush_each_time;
     // if true it initially overwrites the file; default = false
- bool m_initial_overwrite;
+ flag::t<bool> initial_overwrite;
     // if true (default), opens the file for appending
- bool m_do_append;
+ flag::t<bool> do_append;
 
     /// just in case you have some extra flags to pass, when opening the file
- std::ios_base::open_mode m_extra_flags;
+ flag::t<std::ios_base::open_mode> extra_flags;
 };
 
 namespace detail {
     std::ios_base::open_mode open_flags(file_settings fs) {
- std::ios_base::open_mode flags = std::ios_base::out | fs.m_extra_flags ;
- if ( m_do_append)
+ std::ios_base::open_mode flags = std::ios_base::out | fs.extra_flags() ;
+ if ( fs.do_append() )
             flags |= std::ios_base::app;
- if ( !m_initial_overwrite)
+ if ( !fs.initial_overwrite() )
             flags |= std::ios_base::in;
 
         return flags;
     }
 
     struct file_info {
- file_info(const char_type * name, file_settings settings) : out(name, open_flags(settings) ), settings(settings) {}
+ file_info(const std::string& name, file_settings settings) : name(name), out(name.c_str(), open_flags(settings) ), settings(settings) {}
+
+ std::string name;
         std::basic_ofstream<char_type> out;
         file_settings settings;
- }
+ };
 }
 
 /**
     @brief Writes the string to a file
 */
-template<class convert_dest = do_convert_destination > struct file : non_const_context<detail::file_info> {
+template<class convert_dest = do_convert_destination > struct file_t : is_generic, non_const_context<detail::file_info> {
     /**
         @brief constructs the file destination
 
         @param file_name name of the file
         @param set [optional] file settings - see file_settings class
     */
- file(const std::string & file_name, file_settings set = file_settings() ) : non_const_context_base(file_name) {}
+ file_t(const std::string & file_name, file_settings set = file_settings() ) : non_const_context_base(file_name,set) {}
     template<class msg_type> void operator()(const msg_type & msg) const {
- convert_dest::write(msg, non_const_context_base::context() );
+ convert_dest::write(msg, non_const_context_base::context().out );
     }
-};
 
+ bool operator==(const file_t & other) const {
+ return non_const_context_base::context().name == other.context().name;
+ }
+};
 
+/**
+@brief file_t with default values. See file_t
+*/
+typedef file_t<> file;
 
 
 

Modified: sandbox/logging/boost/logging/format/destination/rolling_file.hpp
==============================================================================
--- sandbox/logging/boost/logging/format/destination/rolling_file.hpp (original)
+++ sandbox/logging/boost/logging/format/destination/rolling_file.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -21,6 +21,10 @@
 # pragma once
 #endif
 
+#if defined(_MSC_VER)
+#pragma warning ( disable : 4355)
+#endif
+
 #include <boost/logging/detail/fwd.hpp>
 #include <boost/logging/detail/manipulator.hpp>
 #include <boost/logging/format/destination/convert_destination.hpp>
@@ -32,34 +36,12 @@
 
 namespace boost { namespace logging { namespace destination {
 
-namespace detail {
- template<class self_type, class type> struct flag_with_self_type {
- flag(self_type * self, const type& val = type() ) : m_val(val), m_self(self) {}
- flag(const flag & other) : m_val(other.m_val) {}
-
- const type & operator()() const { return m_val; }
- self_type & operator()(const type & val) {
- m_val = val; return *m_self;
- }
-
- // FIXME operator=
- private:
- type m_val;
- self_type * m_self;
- };
-
- template<class self_type> struct flag {
- template<class val_type> struct t : flag_with_type<self_type,val_type> {
- flag(self_type * self, const val_type& val = val_type() ) : flag_with_type(self,val) {}
- };
- };
-}
 
 /**
- Settings you can pass to the rolling file
+ @brief Settings you can pass to the rolling file
 */
 struct rolling_file_settings {
- typedef detail::flag<rolling_file_settings> flag;
+ typedef boost::logging::detail::flag<rolling_file_settings> flag;
 
     rolling_file_settings()
         : max_size_bytes(this, 1024 * 1024)
@@ -87,15 +69,15 @@
             
             if ( m_flags.initial_erase()) {
                 for ( int idx = 0; idx < m_flags.file_count(); ++idx)
- if ( fs::exists( file_name(idx) )
+ if ( fs::exists( file_name(idx) ))
                         fs::remove( file_name(idx) );
             }
 
             // see what file to start from
             if ( m_flags.start_where_size_not_exceeded() ) {
                 for ( m_cur_idx = 0; m_cur_idx < m_flags.file_count(); ++m_cur_idx )
- if ( fs::exists( file_name(m_cur_idx) ) {
- if ( fs::file_size( file_name(m_cur_idx) < m_flags.max_size_bytes() )
+ if ( fs::exists( file_name(m_cur_idx) )) {
+ if ( fs::file_size( file_name(m_cur_idx)) < m_flags.max_size_bytes() )
                             // file hasn't reached max size
                             break;
                     }
@@ -116,11 +98,11 @@
 
         void recreate_file() {
             m_out = boost::shared_ptr< std::basic_ofstream<char_type> >(new std::basic_ofstream<char_type>( file_name(m_cur_idx).c_str(),
- std::ios_base::out | std::ios_base::app);
+ std::ios_base::out | std::ios_base::app));
         }
 
         template<class msg_type> void write( const msg_type& msg) {
- (convert_dest(msg, (*m_out) );
+ convert_dest::write(msg, (*m_out) );
             if ( m_out->ftellg() > m_flags.max_size_bytes()) {
                 m_cur_idx = (m_cur_idx + 1) % m_flags.file_count();
                 recreate_file();
@@ -143,7 +125,7 @@
     The log has a max_size. When max_size is reached, we start writing to name_prefix.2. When max_size is reached, we start writing to name_prefix.3.
     And so on, until we reach name_prefix.N (N = file_count). When that gets fool, we start over, with name_prefix.1.
 */
-template<class convert_dest = do_convert_destination > struct rolling_file : non_const_context<detail::file_info<convert_dest> > {
+template<class convert_dest = do_convert_destination > struct rolling_file_t : is_generic, non_const_context<detail::rolling_file_info<convert_dest> > {
 
     /**
         Constructs a rolling file
@@ -152,13 +134,21 @@
         
         @param flags [optional] extra settings to pass to the rolling file. See rolling_file_settings.
     */
- rolling_file(const std::string & name_prefix, rolling_file_settings flags = rolling_file_settings() ) : non_const_context(name_prefix, flags) {}
+ rolling_file_t(const std::string & name_prefix, rolling_file_settings flags = rolling_file_settings() ) : non_const_context_base(name_prefix, flags) {}
 
- template<class msg_type> void operator()( const msg_type & msg) {
+ template<class msg_type> void operator()( const msg_type & msg) const {
         non_const_context::context().write(msg);
     }
+
+ bool operator==(const rolling_file_t & other) const {
+ return non_const_context_base::context().m_name_prefix == other.context().m_name_prefix;
+ }
 };
 
+/**
+@brief rolling_file_t with default values. See rolling_file_t
+*/
+typedef rolling_file_t<> rolling_file;
 
 
 

Modified: sandbox/logging/boost/logging/format/destination/shared_memory.hpp
==============================================================================
--- sandbox/logging/boost/logging/format/destination/shared_memory.hpp (original)
+++ sandbox/logging/boost/logging/format/destination/shared_memory.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -49,10 +49,10 @@
 /**
     @brief Logs the information in shared memory
 */
-template<class convert_dest = do_convert_destination > struct shared_memory : non_const_context<detail::shared_memory_context> {
+template<class convert_dest = do_convert_destination > struct shared_memory_t : non_const_context<detail::shared_memory_context> {
 
     enum { just_in_case = 8192 };
- basic_shared_memory_appender(const std::string & name, std::size_t mem_size = 2 * 1024 * 1024 * sizeof(char_type) ) {
+ shared_memory_t(const std::string & name, std::size_t mem_size = 2 * 1024 * 1024 * sizeof(char_type) ) : m_name(name), m_mem_size(mem_size) {
         non_const_context_base::context().mem_size = mem_size;
         
         // this segment might have been previously created...
@@ -83,7 +83,7 @@
         }
     }
     
- template<class msg_type> void operator () (const msg_type& msg_arg) {
+ template<class msg_type> void operator () (const msg_type& msg_arg) const {
         const string_type & msg = do_convert::do_convert(msg_arg, into<string_type>() );
 
         bool can_fit = *(non_const_context_base::context().occupied_size) + msg.size() < non_const_context_base::context().mem_size;
@@ -112,10 +112,20 @@
         }
     }
 
+ bool operator==(const shared_memory_t& other) const {
+ return m_name == other.m_name && m_mem_size == other.m_mem_size;
+ }
 
-};
+private:
+ std::string m_name;
+ std::size_t m_mem_size;
 
+};
 
+/**
+ @brief shared_memory_t with default values. See shared_memory_t.
+*/
+typedef shared_memory_t<> shared_memory;
 
 }}}
 

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-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -50,7 +50,12 @@
     Example : write_time
     */
     namespace prepend {
- void write(const string_type & src, string & dest) {
+ void write(const char_type * src, string_type & dest ) {
+ const char * end = src;
+ for ( ; *end; ++end);
+ dest.insert( dest.begin(), src, end);
+ }
+ void write(const string_type & src, string_type & dest) {
             dest.insert( dest.begin(), src.begin(), src.end() );
         }
         template<class string> void write(const string_type & src, boost::logging::optimize::cache_string_one_str<string> & dest) {
@@ -61,7 +66,10 @@
     /**
     */
     namespace append {
- void write(const string_type & src, string & dest) {
+ void write(const char_type * src, string_type & dest ) {
+ dest += src;
+ }
+ void write(const string_type & src, string_type & dest) {
             dest += src;
         }
         template<class string> void write(const string_type & src, boost::logging::optimize::cache_string_one_str<string> & dest) {
@@ -72,7 +80,10 @@
     /**
     */
     namespace modify {
- void write(const string_type & src, string & dest) {
+ void write(const char_type * src, string_type & dest ) {
+ dest = src;
+ }
+ void write(const string_type & src, string_type & dest) {
             dest = src;
         }
         template<class string> void write(const string_type & src, boost::logging::optimize::cache_string_one_str<string> & dest) {
@@ -84,20 +95,22 @@
 
 
 struct do_convert_format {
+ typedef std::basic_string<char_type> string_type;
+
     struct prepend {
- template<class string> void write(const string_type & src, string & dest) {
+ template<class string> static void write(const string_type & src, string & dest) {
             convert::prepend::write(src, dest);
         }
     };
 
     struct append {
- template<class string> void write(const string_type & src, string & dest) {
+ template<class string> static void write(const string_type & src, string & dest) {
             convert::append::write(src, dest);
         }
     };
 
     struct modify {
- template<class string> void write(const string_type & src, string & dest) {
+ template<class string> static void write(const string_type & src, string & dest) {
             convert::modify::write(src, 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-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -50,11 +50,11 @@
 @param convert [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format.
 For instance, you might use @ref boost::logging::optimize::cache_string_one_str "a cached_string class" (see @ref boost::logging::optimize "optimize namespace").
 */
-template<class convert = do_convert_format::prepend> struct idx : formatter::non_const_context<int> {
- idx() : non_const_context_base((int)0) {}
+template<class convert = do_convert_format::prepend> struct idx_t : is_generic, formatter::non_const_context<int>, boost::logging::op_equal::always_equal {
+ 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 << _T("[") << ++context() << _T("] ");
+ idx << BOOST_LOGGING_STR("[") << ++context() << BOOST_LOGGING_STR("] ");
 
         convert::write( idx.str(), str );
     }
@@ -67,9 +67,9 @@
 @param convert [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format.
 For instance, you might use @ref boost::logging::optimize::cache_string_one_str "a cached_string class" (see @ref boost::logging::optimize "optimize namespace").
 */
-template<class convert = do_convert_format::prepend> struct append_enter {
+template<class convert = do_convert_format::prepend> struct append_enter_t : is_generic, boost::logging::op_equal::always_equal {
     template<class msg_type> void operator()(msg_type & str) const {
- convert::write( _T("\n"), str );
+ convert::write( (const char_type*)BOOST_LOGGING_STR("\n"), str );
     }
 };
 
@@ -80,7 +80,7 @@
 @param convert [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format.
 For instance, you might use @ref boost::logging::optimize::cache_string_one_str "a cached_string class" (see @ref boost::logging::optimize "optimize namespace").
 */
-template<class convert = do_convert_format::append> struct append_enter_if_needed {
+template<class convert = do_convert_format::append> struct append_enter_if_needed_t : is_generic, boost::logging::op_equal::always_equal {
     template<class msg_type> void operator()(msg_type & str) const {
         bool is_needed = true;
         if ( !str.empty())
@@ -88,10 +88,13 @@
                 is_needed = false;
 
         if ( is_needed)
- convert::write( _T("\n"), str );
+ convert::write( BOOST_LOGGING_STR("\n"), str );
     }
 };
 
+typedef idx_t<> idx;
+typedef append_enter_t<> append_enter;
+typedef append_enter_if_needed_t<> append_enter_if_needed;
 
 }}}
 

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-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -31,10 +31,10 @@
 @param convert [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format.
 For instance, you might use @ref boost::logging::optimize::cache_string_one_str "a cached_string class" (see @ref boost::logging::optimize "optimize namespace").
 */
-template<class convert = do_convert_format::prepend> struct thread_id {
- template<class msg_type> void operator()(msg_type & msg) {
+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 << _T("[T")
+ out << BOOST_LOGGING_STR("[T")
     #if defined (BOOST_HAS_WINTHREADS)
             << ::GetCurrentThreadId()
     #elif defined (BOOST_HAS_PTHREADS)
@@ -42,10 +42,14 @@
     #elif defined (BOOST_HAS_MPTASKS)
             << MPCurrentTaskID()
     #endif
- << _T("] ");
+ << BOOST_LOGGING_STR("] ");
 
         convert::write( out.str(), msg );
     }
+};
+
+
+typedef thread_id_t<> thread_id;
 
 }}}
 

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-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -47,12 +47,11 @@
 @param convert [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format.
 For instance, you might use @ref boost::logging::optimize::cache_string_one_str "a cached_string class" (see @ref boost::logging::optimize "optimize namespace").
 */
-template<class convert = do_convert_format::prepend> struct time {
+template<class convert = do_convert_format::prepend> struct time_t : is_generic {
 private:
- typedef std::basic_string<c_type> string_type;
 
     struct index_info {
- typedef string_type::size_type uint;
+ typedef hold_string_type::size_type uint;
         
         index_info(uint src_idx, int *format_idx, int size = 2) : src_idx(src_idx), format_idx(format_idx), size(size) {}
         uint src_idx;
@@ -69,37 +68,37 @@
     /**
         constructs a time object
     */
- time(const string_type & format) : m_day(-1), m_month(-1), m_yy(-1), m_yyyy(-1), m_hour(-1), m_min(-1), m_sec(-1) {
+ time_t(const hold_string_type & format) : m_day(-1), m_month(-1), m_yy(-1), m_yyyy(-1), m_hour(-1), m_min(-1), m_sec(-1) {
         // format too big
         assert( format.size() < 64);
 
- typedef string_type::size_type uint;
- uint day_idx = format.find(_T("$dd"));
- uint month_idx = format.find(_T("$MM"));
- uint yy_idx = format.find(_T("$yy"));
- uint yyyy_idx = format.find(_T("$yyyy"));
- uint hour_idx = format.find(_T("$hh"));
- uint min_idx = format.find(_T("$mm"));
- uint sec_idx = format.find(_T("$ss"));
+ 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"));
 
         typedef std::vector<index_info> array;
         array indexes;
- if ( day_idx != logging_types::string::npos)
+ if ( day_idx != hold_string_type::npos)
             indexes.push_back( index_info(day_idx, &m_day) );
- if ( month_idx != logging_types::string::npos)
+ if ( month_idx != hold_string_type::npos)
             indexes.push_back( index_info(month_idx, &m_month) );
 
- if ( yy_idx != logging_types::string::npos || yyyy_idx != logging_types::string::npos)
- if ( yyyy_idx != logging_types::string::npos)
+ if ( yy_idx != hold_string_type::npos || yyyy_idx != hold_string_type::npos)
+ if ( yyyy_idx != hold_string_type::npos)
                 indexes.push_back( index_info(yyyy_idx, &m_yyyy, 4) );
             else
                 indexes.push_back( index_info(yy_idx, &m_yy) );
 
- if ( hour_idx != logging_types::string::npos)
+ if ( hour_idx != hold_string_type::npos)
             indexes.push_back( index_info(hour_idx, &m_hour ) );
- if ( min_idx != logging_types::string::npos)
+ if ( min_idx != hold_string_type::npos)
             indexes.push_back( index_info(min_idx, &m_min) );
- if ( sec_idx != logging_types::string::npos)
+ if ( sec_idx != hold_string_type::npos)
             indexes.push_back( index_info(sec_idx, &m_sec) );
         std::sort( indexes.begin(), indexes.end(), index_info::by_index);
         
@@ -109,7 +108,7 @@
         for ( 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) ? _T("%04d") : _T("%02d");
+ m_format += (begin->size == 4) ? BOOST_LOGGING_STR("%04d") : BOOST_LOGGING_STR("%02d");
             prev_idx = begin->src_idx + begin->size + 1;
             ++idx;
         }
@@ -120,10 +119,10 @@
 
 
 
- template<class msg_type> void operator()(msg_type & msg) {
+ template<class msg_type> void operator()(msg_type & msg) const {
         char_type buffer[64];
 
- time_t t = ::time(0);
+ ::time_t t = ::time(0);
         tm details = *localtime( &t);
 
         int vals[8];
@@ -145,6 +144,9 @@
         convert::write(buffer, msg);
     }
 
+ bool operator==(const time_t & other) const {
+ return m_format == other.m_format;
+ }
 
 private:
     // the indexes of each escape sequence within the format string
@@ -161,21 +163,21 @@
 @param convert [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format.
 For instance, you might use @ref boost::logging::optimize::cache_string_one_str "a cached_string class" (see @ref boost::logging::optimize "optimize namespace").
 */
-template<class convert = do_convert_format::prepend> struct write_time_strf {
+template<class convert = do_convert_format::prepend> struct time_strf_t : is_generic {
 
     /**
- constructs a write_time_strf object
+ constructs a time_strf object
 
         @param format the time format , strftime-like
         @param localtime if true, use localtime, otherwise global time
     */
- write_time_strf(const logging_types::string & format, bool localtime)
+ time_strf_t(const hold_string_type & format, bool localtime)
         : m_format (format), m_localtime (localtime)
     {}
 
- template<class msg_type> void operator()(msg_type & msg) {
+ template<class msg_type> void operator()(msg_type & msg) const {
         char_type buffer[64];
- time_t t = ::time (0);
+ ::time_t t = ::time (0);
         tm t_details = m_localtime ? *localtime( &m_t) : *gmtime( &m_t);
     #ifdef UNICODE
         if (0 != wcsftime (buffer, sizeof (buffer), m_format.c_str (), &t_details))
@@ -185,12 +187,20 @@
             convert::write(buffer, msg);
     }
 
- logging_types::string m_format;
+ bool operator==(const time_strf_t & other) const {
+ return m_format == other.m_format;
+ }
+
+private:
+ hold_string_type m_format;
     bool m_localtime;
 
 };
 
 
+typedef time_t<> time;
+typedef time_strf_t<> time_strf;
+
 }}}
 
 #endif

Modified: sandbox/logging/boost/logging/format/op_equal.hpp
==============================================================================
--- sandbox/logging/boost/logging/format/op_equal.hpp (original)
+++ sandbox/logging/boost/logging/format/op_equal.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -26,84 +26,14 @@
 namespace boost { namespace logging {
 
 /**
- @brief Different ways to implement operator==
+ @brief Implements operator== for manipulators
 
- You need this when:
- - your logger uses Formatters and Destinations, and
- - you've added formatters and/or destinations to your logger
- - at a later time, you want to erase a certain formatter and/or destination from your logger
-
- If so, we need a way to identify the formatter/destination to be erased.
 */
 namespace op_equal {
 
 
 
- /**
- @brief A unique ID is given to each default-constructed object. If object A is copy-constructed from B, or copy-assigned from B, it will "inherit" its ID.
-
- A lot of times this is usually enough. Since formatters/destinations either have const context data,
- or a shared context (@ref boost::logging::manipulator::non_const_context "non_const_context class"), this is enough.
- */
- struct unique_id {
- protected:
- unique_id() : m_id( next_id() ) {}
-
- public:
- bool are_unique_ids_equal(const unique_id & other) const { return m_id == other.m_id; }
- private:
- static int next_id() {
- static threading::mutex cs;
- static int id = 0;
- threading::scoped_lock lk(cs);
- return ++id;
- }
-
- int m_id;
- };
- inline bool operator==(const unique_id& a, const unique_id & b) { return a.are_unique_ids_equal(b); }
- namespace detail { namespace {
- struct make_sure_unique_id_next_id_is_initialized {
- struct use_unique_id : unique_id {};
-
- make_sure_unique_id_next_id_is_initialized() {
- // trick the compiler to make sure the statics in next_id() are initialized before main()!
- use_unique_id a, b;
- if ( a == b)
- std::vector<int> v;
- }
- };
- }}
-
-
-
- /**
- @brief Implements operator==, which compares two objects. If they have the same type, it will return true
-
- For trivial @ref manipulator "manipulators", that don't have any context, this is usually enough.
-
- If your @ref manipulator "manipulators" have context, you should either use non_const_context class, or same_type_op_equal class.
- */
- struct same_type {
- protected:
- same_type() {}
- same_type(const same_type&) {}
- virtual ~same_type() {}
- public:
- inline bool operator ==(const same_type& other) const {
- return typeid(*this) == typeid(other);
- }
- };
-
-
-
-
-
     struct same_type_op_equal_top {
- /*
- if you get a compile time error here, your formatter or destination needs to derive
- from same_type_op_equal<your_type>, and implement operator== as a member function , in your class
- */
         virtual bool equals(const same_type_op_equal_top &) const = 0;
     protected:
         same_type_op_equal_top() {}
@@ -118,6 +48,9 @@
     */
     struct same_type_op_equal_base : virtual same_type_op_equal_top {};
 
+ struct always_equal {
+ bool operator==(const always_equal& ) const { return true; }
+ };
 
     /**
         @brief Implements operator==, which compares two objects. If they have the same type, it will compare them using the type's member operator==.

Added: sandbox/logging/boost/logging/format_all.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/format_all.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -0,0 +1,36 @@
+// format_all.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_format_all_HPP_DEFINED
+#define JT28092007_format_all_HPP_DEFINED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/logging/detail/fwd.hpp>
+#include <boost/logging/format.hpp>
+#include <boost/logging/format/formatter/thread_id.hpp>
+#include <boost/logging/format/formatter/time.hpp>
+#include <boost/logging/format/destination/file.hpp>
+#include <boost/logging/format/destination/rolling_file.hpp>
+
+// not tested yet
+//#include <boost/logging/format/destination/shared_memory.hpp>
+
+
+#endif
+

Modified: sandbox/logging/boost/logging/level.hpp
==============================================================================
--- sandbox/logging/boost/logging/level.hpp (original)
+++ sandbox/logging/boost/logging/level.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -51,9 +51,9 @@
     enum {
         disable_all = (type)-1,
         enable_all = 0,
- info = 1000,
- warning = 2000,
- debug = 3000,
+ debug = 1000,
+ info = 2000,
+ warning = 3000,
         error = 4000,
         fatal = 5000
     };
@@ -137,6 +137,7 @@
         }
     };
 
+ typedef boost::logging::level_holder_type holder;
 } // namespace level
 
 /**

Modified: sandbox/logging/boost/logging/logging.hpp
==============================================================================
--- sandbox/logging/boost/logging/logging.hpp (original)
+++ sandbox/logging/boost/logging/logging.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -25,6 +25,8 @@
 #include <boost/logging/filter.hpp>
 #include <boost/logging/process_msg.hpp>
 #include <boost/logging/sink.hpp>
+#include <boost/logging/macros.hpp>
+#include <boost/logging/level.hpp>
 
 namespace boost { namespace logging {
 

Modified: sandbox/logging/boost/logging/macros.hpp
==============================================================================
--- sandbox/logging/boost/logging/macros.hpp (original)
+++ sandbox/logging/boost/logging/macros.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -22,6 +22,8 @@
 #endif
 
 #include <boost/logging/detail/fwd.hpp>
+#include <time.h>
+#include <stdlib.h>
 
 namespace boost { namespace logging {
 
@@ -42,8 +44,91 @@
     Explain why the if ; else strategy: so that if withing if (x) LOG_ ... ; else blabla - still ok
         #define L_ if ( g_single_log) ; else g_single_log->read_msg().gather().msg()
 
+
+
+ Macros
+ - BOOST_LOGGING_COMPILE_FAST_ON
+ - BOOST_LOGGING_COMPILE_FAST_OFF
+ - BOOST_LOGGING_COMPILE_FAST
 */
 
+#ifdef BOOST_LOGGING_COMPILE_FAST_ON
+#define BOOST_LOGGING_COMPILE_FAST
+#elif defined(BOOST_LOGGING_COMPILE_FAST_OFF)
+#undef BOOST_LOGGING_COMPILE_FAST
+#else
+// by default, turned on
+#define BOOST_LOGGING_COMPILE_FAST
+#endif
+
+namespace detail {
+ /*
+ Note that BOOST_DECLARE_LOG & BOOST_DEFINE_LOG define a function,
+ so that we don't run into the problem of using an object before it's initialized.
+
+ However, client code doesn't need to be aware of that.
+ So, for instance, clients will say:
+
+ typedef logger<...> app_log;
+ BOOST_DEFINE_LOG(g_l,app_log);
+
+ g_l->writer().add_formatter( formatter::idx() );
+ */
+ template<class type, type& (*func)() > struct log_keeper {
+ typedef typename type::process_msg_type process_msg_type ;
+
+ const process_msg_type* operator->() const { return func().operator->(); }
+ process_msg_type* operator->() { return func().operator->(); }
+ };
+
+ struct fake_using_log {
+ template<class type> fake_using_log( type & log) {
+ long long ignore = reinterpret_cast<long long>(&log);
+ // we need to force the compiler to force creation of the log
+ if ( time(0) < 0)
+ if ( time(0) < ignore)
+ exit(0);
+ }
+ };
+}
+
+#ifdef BOOST_LOGGING_COMPILE_FAST
+
+// FIXME need to reimplement them when using compile_fast
+#define BOOST_DECLARE_LOG(name,type) type& name ## _boost_log_impl_(); extern boost::logging::detail::log_keeper<type, name ## _boost_log_impl_ > g_l;
+#define BOOST_DEFINE_LOG(name,type) type& name ## _boost_log_impl_() \
+ { static type i; return i; } \
+ namespace { boost::logging::detail::fake_using_log ensure_log_is_created_before_main ## name ( name ## _boost_log_impl_() ); } \
+ boost::logging::detail::log_keeper<type, name ## _boost_log_impl_ > g_l;
+
+#else
+
+#define BOOST_DECLARE_LOG(name,type) type& name ## _boost_log_impl_(); extern boost::logging::detail::log_keeper<type, name ## _boost_log_impl_ > g_l;
+#define BOOST_DEFINE_LOG(name,type) type& name ## _boost_log_impl_() \
+ { static type i; return i; } \
+ namespace { boost::logging::detail::fake_using_log ensure_log_is_created_before_main ## name ( name ## _boost_log_impl_() ); } \
+ boost::logging::detail::log_keeper<type, name ## _boost_log_impl_ > g_l;
+
+#endif
+
+
+
+
+
+#define BOOST_LOG_USE_LOG(l, do_func, is_log_enabled) if ( !(is_log_enabled) ) ; else l -> do_func
+
+#define BOOST_LOG_USE_LOG_IF_LEVEL(l, holder, the_level) BOOST_LOG_USE_LOG(l, read_msg().gather().out(), holder.is_enabled(::boost::logging::level:: the_level) )
+
+
+
+
+
+
+
+
+
+
+
 
 }}
 

Modified: sandbox/logging/boost/logging/writer/format_write.hpp
==============================================================================
--- sandbox/logging/boost/logging/writer/format_write.hpp (original)
+++ sandbox/logging/boost/logging/writer/format_write.hpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -117,7 +117,7 @@
 template<
         class formatter_base,
         class destination_base,
- class apply_format_and_write = boost::logging::format_and_write::simple<typename destination_base::raw_param>,
+ class apply_format_and_write = boost::logging::format_and_write::simple<typename formatter_base::raw_param>,
         class router_type = msg_route::simple<formatter_base, destination_base> ,
         class formatter_array = array::shared_ptr_holder<formatter_base> ,
         class destination_array = array::shared_ptr_holder<destination_base> >
@@ -169,19 +169,19 @@
     // generic manipulator
     template<class formatter> void del_formatter_impl(formatter fmt, const boost::true_type& ) {
         typedef boost::logging::manipulator::detail::generic_holder<formatter,formatter_base> holder;
- del_formatter_impl( holder(fmt) boost::false_type() );
+ del_formatter_impl( holder(fmt), boost::false_type() );
     }
 
     // generic manipulator
     template<class destination> void add_destination_impl(destination dest, const boost::true_type& ) {
- typedef boost::logging::manipulator::detail::generic_holder<destination,destination_basee> holder;
- add_destination_impl( holder(dest) boost::false_type() );
+ typedef boost::logging::manipulator::detail::generic_holder<destination,destination_base> holder;
+ add_destination_impl( holder(dest), boost::false_type() );
     }
 
     // generic manipulator
     template<class destination> void del_destination_impl(destination dest, const boost::true_type& ) {
- typedef boost::logging::manipulator::detail::generic_holder<destination,destination_basee> holder;
- del_destination_impl( holder(dest) boost::false_type() );
+ typedef boost::logging::manipulator::detail::generic_holder<destination,destination_base> holder;
+ del_destination_impl( holder(dest), boost::false_type() );
     }
 
 
@@ -247,5 +247,7 @@
 
 }}
 
+#include <boost/logging/detail/use_format_write.hpp>
+
 #endif
 

Added: sandbox/logging/lib/logging/samples/scenarios/mul_levels_one_logger.cpp
==============================================================================
--- (empty file)
+++ sandbox/logging/lib/logging/samples/scenarios/mul_levels_one_logger.cpp 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -0,0 +1,102 @@
+// test_mul_levels_one_logger.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
+
+#define BOOST_LOGGING_COMPILE_FAST_OFF
+#include <boost/logging/logging.hpp>
+#include <boost/logging/format.hpp>
+
+using namespace boost::logging;
+
+/*
+ Common usage:
+ - You have multiple levels (in this example: debug < info < error)
+ - You want to format the message before it's written
+ (in this example: prefix it by index, by time, and append an enter to it)
+ - You have several log destinations
+ (in this example: the console, the output window, and a file
+
+*/
+
+// Step 1: define your formatter & destination base classes
+typedef formatter::base< std::string& > formatter_base;
+typedef destination::base< const std::string & > destination_base;
+
+// Step 2 : define your logging class(es)
+typedef logger< use_format_write<formatter_base,destination_base> > log_type;
+
+// Step 3 : if you use levels, have a log level holder
+level::holder g_log_level; // holds the application log level
+
+// Step 4A: declare which loggers you'll use
+BOOST_DECLARE_LOG(g_l, log_type) // normally this goes into a header file ;)
+
+// Step 4B: define which loggers you'll use
+BOOST_DEFINE_LOG(g_l, log_type)
+
+// Step 5: define the macros through which you'll log
+#define LDBG_ BOOST_LOG_USE_LOG_IF_LEVEL(g_l, g_log_level, debug )
+#define LERR_ BOOST_LOG_USE_LOG_IF_LEVEL(g_l, g_log_level, error )
+#define LAPP_ BOOST_LOG_USE_LOG_IF_LEVEL(g_l, g_log_level, info )
+
+void test_mul_levels_one_logger() {
+ // Step 6: 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::time("$hh:$mm.$ss ") );
+ g_l->writer().add_formatter( formatter::append_enter() );
+
+ // ... and where should it be written to
+ g_l->writer().add_destination( destination::cout() );
+ g_l->writer().add_destination( destination::dbg_window() );
+ g_l->writer().add_destination( destination::file("out.txt") );
+
+ // Step 7: use it...
+ int i = 1;
+ LDBG_ << "this is so cool " << i++;
+
+ std::string hello = "hello", world = "world";
+ LAPP_ << hello << ", " << world;
+
+ g_log_level.set_enabled(level::error);
+ LDBG_ << "this will not be written anywhere";
+ LAPP_ << "this won't be written anywhere either";
+
+ g_log_level.set_enabled(level::info);
+ LAPP_ << "good to be back ;) " << i++;
+
+ /*
+ Step 8 : Enjoy!
+
+ The output will be written to the console, debug window, and "out.txt" file.
+ It will look similar to this one:
+
+ 12:59.27 [1] this is so cool 1
+ 12:59.27 [2] hello, world
+ 12:59.27 [3] good to be back ;) 2
+ */
+}
+
+
+
+#ifdef SINGLE_TEST
+
+int main() {
+ test_mul_levels_one_logger();
+}
+
+#endif
+
+// End of file
+

Modified: sandbox/logging/lib/logging/samples/vc8/loggingvc8/loggingvc8.vcproj
==============================================================================
--- sandbox/logging/lib/logging/samples/vc8/loggingvc8/loggingvc8.vcproj (original)
+++ sandbox/logging/lib/logging/samples/vc8/loggingvc8/loggingvc8.vcproj 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -170,7 +170,7 @@
                         OutputDirectory="$(SolutionDir)$(ConfigurationName)"
                         IntermediateDirectory="$(ConfigurationName)"
                         ConfigurationType="1"
- CharacterSet="1"
+ CharacterSet="2"
>
                         <Tool
                                 Name="VCPreBuildEventTool"
@@ -425,12 +425,21 @@
>
                                 <FileConfiguration
                                         Name="Test|Win32"
+ ExcludedFromBuild="true"
>
                                         <Tool
                                                 Name="VCCLCompilerTool"
                                         />
                                 </FileConfiguration>
                         </File>
+ <Filter
+ Name="scenarios"
+ >
+ <File
+ RelativePath="..\..\scenarios\mul_levels_one_logger.cpp"
+ >
+ </File>
+ </Filter>
                 </Filter>
                 <Filter
                         Name="main"
@@ -619,6 +628,10 @@
>
                                 </File>
                                 <File
+ RelativePath="..\..\..\..\..\boost\logging\format_all.hpp"
+ >
+ </File>
+ <File
                                         RelativePath="..\..\..\..\..\boost\logging\detail\manipulator.hpp"
>
                                 </File>
@@ -630,6 +643,10 @@
                                         RelativePath="..\..\..\..\..\boost\logging\format\optimize.hpp"
>
                                 </File>
+ <File
+ RelativePath="..\..\..\..\..\boost\logging\detail\use_format_write.hpp"
+ >
+ </File>
                                 <Filter
                                         Name="formatter"
>
@@ -740,6 +757,10 @@
>
                         </File>
                         <File
+ RelativePath="..\..\..\..\..\boost\logging\detail\raw_doc\old_examples.hpp"
+ >
+ </File>
+ <File
                                 RelativePath="..\..\..\..\..\boost\logging\detail\raw_doc\table_of_contents.hpp"
>
                         </File>

Modified: sandbox/logging/lib/logging/src/changelog.txt
==============================================================================
--- sandbox/logging/lib/logging/src/changelog.txt (original)
+++ sandbox/logging/lib/logging/src/changelog.txt 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -1,3 +1,7 @@
+v0.8, 20 oct 2007
+- added use_format_write class
+- removed the filter from the logger class (need to update documentation)
+- added Common scenario
 
 
 v0.7.3, 19 oct 2007

Added: sandbox/logging/lib/logging/tests/obsolete.txt
==============================================================================
--- (empty file)
+++ sandbox/logging/lib/logging/tests/obsolete.txt 2007-10-20 06:36:59 EDT (Sat, 20 Oct 2007)
@@ -0,0 +1,2 @@
+Note: the tests here are obsolete.
+Please disregard them


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