Boost logo

Boost-Commit :

From: john.groups_at_[hidden]
Date: 2007-10-29 18:06:58


Author: jtorjo
Date: 2007-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
New Revision: 40572
URL: http://svn.boost.org/trac/boost/changeset/40572

Log:
[logging]
v0.9.1, 30 oct 2007
- implemented BOOST_DEFINE_LOG/BOOST_DECLARE_LOG for when not compiling fast
- BEFORE a breaking change that will happen :
  - logger as is now will dissapear
  - the new logger class will be the old process_msg class

Added:
   sandbox/logging/boost/logging/detail/find_gather.hpp (contents, props changed)
   sandbox/logging/boost/logging/detail/log_keeper.hpp (contents, props changed)
   sandbox/logging/boost/logging/detail/old/
   sandbox/logging/boost/logging/detail/old/macros_old.hpp (contents, props changed)
   sandbox/logging/lib/logging/tests/testfast.cpp (contents, props changed)
Properties modified:
   sandbox/logging/lib/logging/samples/basic_usage/ (props changed)
Text files modified:
   sandbox/logging/boost/logging/detail/format_msg_type.hpp | 28 +++++++++
   sandbox/logging/boost/logging/detail/raw_doc/fixme.hpp | 2
   sandbox/logging/boost/logging/detail/raw_doc/workflow.hpp | 3
   sandbox/logging/boost/logging/detail/use_format_write.hpp | 29 +++-------
   sandbox/logging/boost/logging/filter.hpp | 15 +++++
   sandbox/logging/boost/logging/format.hpp | 10 +++
   sandbox/logging/boost/logging/format_fwd.hpp | 8 ++
   sandbox/logging/boost/logging/macros.hpp | 114 +++++++++++----------------------------
   sandbox/logging/boost/logging/process_msg.hpp | 51 +++++++++++++----
   sandbox/logging/boost/logging/process_msg/ostream_like.hpp | 4 -
   sandbox/logging/lib/logging/samples/basic_usage/log.cpp | 4 +
   sandbox/logging/lib/logging/samples/basic_usage/log.h | 7 +-
   sandbox/logging/lib/logging/samples/scenarios/custom_fmt_dest.cpp | 2
   sandbox/logging/lib/logging/samples/scenarios/fastest_no_ostr_like.cpp | 2
   sandbox/logging/lib/logging/samples/scenarios/fastest_use_ostr_like.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/vc8/loggingvc8/loggingvc8.vcproj | 20 +++++++
   sandbox/logging/lib/logging/src/changelog.txt | 8 ++
   22 files changed, 186 insertions(+), 133 deletions(-)

Added: sandbox/logging/boost/logging/detail/find_gather.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/detail/find_gather.hpp 2007-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -0,0 +1,61 @@
+// find_gather.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_find_gather_HPP_DEFINED
+#define JT28092007_find_gather_HPP_DEFINED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/logging/detail/fwd.hpp>
+
+namespace boost { namespace logging {
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ // specialize logger for format_write class
+ //
+
+ namespace gather { namespace ostream_like {
+ template<class> struct return_str ;
+ template<class, class> struct return_cache_str ;
+ }}
+
+ namespace optimize {
+ template<class> struct cache_string_one_str ;
+ template<class, class> struct cache_string_several_str ;
+ }
+
+ namespace detail {
+ template<class param> struct find_gather {};
+ template<> struct find_gather< std::basic_string<char_type> > { typedef gather::ostream_like::return_str< std::basic_ostringstream<char_type> > type ; };
+
+ template< class string_type>
+ struct find_gather< boost::logging::optimize::cache_string_one_str<string_type> > {
+ typedef gather::ostream_like::return_cache_str< boost::logging::optimize::cache_string_one_str<string_type>, std::basic_ostringstream<char_type> > type;
+ };
+
+ template< class string_type>
+ struct find_gather< boost::logging::optimize::cache_string_several_str<string_type,void*> > {
+ typedef gather::ostream_like::return_cache_str< boost::logging::optimize::cache_string_several_str<string_type,void*>, std::basic_ostringstream<char_type> > type;
+ };
+
+ }
+
+}}
+
+#endif
+

Modified: sandbox/logging/boost/logging/detail/format_msg_type.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/format_msg_type.hpp (original)
+++ sandbox/logging/boost/logging/detail/format_msg_type.hpp 2007-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -22,6 +22,8 @@
 #endif
 
 #include <boost/logging/detail/fwd.hpp>
+#include <boost/logging/detail/find_gather.hpp>
+#include <boost/type_traits/remove_reference.hpp>
 
 
 namespace boost { namespace logging {
@@ -45,6 +47,32 @@
     };
 }
 
+
+/*
+ for when compiling fast, and:
+ - I know the gather type OR
+ - use a default gather
+*/
+namespace detail {
+ template<class gather_msg> struct call_write;
+
+ template<class gather_type> struct fast_compile_with_gather {
+ typedef gather_type gather_msg;
+ typedef typename process_msg_with_ptr_base< gather_msg > process_type;
+ typedef typename logger< process_type* > log_type;
+ };
+
+ template<class T = override> struct fast_compile_with_default_gather {
+ typedef typename boost::logging::formatter::msg_type<T>::type msg_type_ref;
+ typedef typename boost::remove_reference<msg_type_ref>::type msg_type;
+
+ typedef typename find_gather< msg_type >::type gather_msg;
+ typedef typename fast_compile_with_gather< gather_msg >::log_type log_type;
+ };
+
+}
+
+
 }}
 
 #endif

Added: sandbox/logging/boost/logging/detail/log_keeper.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/detail/log_keeper.hpp 2007-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -0,0 +1,86 @@
+// log_keeper.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_log_keeper_HPP_DEFINED
+#define JT28092007_log_keeper_HPP_DEFINED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/logging/detail/fwd.hpp>
+
+namespace boost { namespace logging {
+
+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) {
+ printf("LOGGING LIB internal error - should NEVER happen. Please report this to the author of the lib");
+ exit(0);
+ }
+ }
+ };
+
+
+ /*
+ Note that BOOST_DECLARE_LOG_FILTER & BOOST_DEFINE_LOG_FILTER 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:
+
+ BOOST_DEFINE_LOG_FILTER(g_level_holder, level::holder);
+
+ g_level_holder->set_enabled(level::debug);
+ */
+ template<class type, type& (*func)() > struct log_filter_keeper {
+
+ const type* operator->() const { return &(func()); }
+ type* operator->() { return &(func()); }
+ };
+
+} // namespace detail
+
+
+
+}}
+
+#endif
+

Added: sandbox/logging/boost/logging/detail/old/macros_old.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/detail/old/macros_old.hpp 2007-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -0,0 +1,215 @@
+// macros.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
+
+// IMPORTANT : the JT28092007_macros_HPP_DEFINED needs to remain constant - don't change the macro name!
+#ifndef JT28092007_macros_HPP_DEFINED
+#define JT28092007_macros_HPP_DEFINED
+
+/*
+ VERY IMPORTANT:
+ Not using #pragma once
+ We might need to re-include this file, when defining the logs
+*/
+
+#include <boost/logging/detail/fwd.hpp>
+#include <time.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <boost/logging/detail/log_keeper.hpp>
+
+namespace boost { namespace logging {
+
+#ifdef BOOST_LOG_COMPILE_FAST_ON
+#define BOOST_LOG_COMPILE_FAST
+#elif defined(BOOST_LOG_COMPILE_FAST_OFF)
+#undef BOOST_LOG_COMPILE_FAST
+#else
+// by default, turned on
+#define BOOST_LOG_COMPILE_FAST
+#endif
+
+
+
+
+
+
+
+
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Defining filter Macros
+
+/*
+ when compile fast is "off", we always need BOOST_LOG_MANIPULATE_LOGS, to get access to the logger class typedefs;
+*/
+#if !defined(BOOST_LOG_COMPILE_FAST)
+#if !defined(BOOST_LOG_MANIPULATE_LOGS)
+
+#define BOOST_LOG_MANIPULATE_LOGS
+
+#endif
+#endif
+
+
+
+
+
+
+
+#ifdef BOOST_LOG_COMPILE_FAST
+// ****** Fast compile ******
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// use log
+
+#define BOOST_USE_LOG_FIND_GATHER(name,log_type,base_type) \
+ namespace boost_log_define_ { \
+ extern ::boost::logging::detail::log_keeper< base_type, name ## _boost_log_impl_, ::boost::logging::detail::call_write_logger_finder< log_type, gather_msg > ::type > name ; \
+ } \
+ using boost_log_define_:: name ;
+
+
+#define BOOST_USE_LOG(name,type) BOOST_USE_LOG_FIND_GATHER(name, type, ::boost::logging::detail::fast_compile_with_default_gather<>::log_type )
+
+#define BOOST_DECLARE_LOG_KEEPER(name,log_type) \
+ namespace boost_log_declare_ { \
+ extern ::boost::logging::detail::log_keeper< log_type, name ## _boost_log_impl_ > name; \
+ } \
+ using boost_log_declare_ :: name ;
+
+
+
+
+#if !defined(BOOST_LOG_MANIPULATE_LOGS)
+// user is declaring logs
+#define BOOST_DECLARE_LOG_WITH_LOG_TYPE(name,log_type) \
+ log_type& name ## _boost_log_impl_(); \
+ BOOST_DECLARE_LOG_KEEPER(name,log_type)
+
+#else
+// user is defining logs
+#define BOOST_DECLARE_LOG_WITH_LOG_TYPE(name,log_type) \
+ log_type& name ## _boost_log_impl_(); \
+ BOOST_USE_LOG(name,log_type)
+
+#endif
+
+
+#define BOOST_DECLARE_LOG_FIND_GATHER(name) \
+ BOOST_DECLARE_LOG_WITH_LOG_TYPE(name, ::boost::logging::detail::fast_compile_with_default_gather<>::log_type )
+
+#define BOOST_DECLARE_LOG(name,type) BOOST_DECLARE_LOG_FIND_GATHER(name)
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// define log
+#define BOOST_DEFINE_LOG_FIND_GATHER(name, log_type, base_type, gather_msg) base_type & name ## _boost_log_impl_() \
+{ typedef ::boost::logging::detail::call_write_logger_finder< log_type, gather_msg > ::type logger_type; \
+ static logger_type i; return i; } \
+ namespace { boost::logging::detail::fake_using_log ensure_log_is_created_before_main ## name ( name ## _boost_log_impl_() ); } \
+ namespace boost_log_declare_ { \
+ ::boost::logging::detail::log_keeper< base_type, name ## _boost_log_impl_ > name ; \
+ } \
+ namespace boost_log_define_ { \
+ ::boost::logging::detail::log_keeper< base_type, name ## _boost_log_impl_, ::boost::logging::detail::call_write_logger_finder< log_type, gather_msg > ::type > name ; \
+ } \
+ using boost_log_define_ :: name ;
+
+#define BOOST_DEFINE_LOG(name,type) \
+ BOOST_DEFINE_LOG_FIND_GATHER(name, type, ::boost::logging::detail::fast_compile_with_default_gather<>::log_type, ::boost::logging::detail::fast_compile_with_default_gather<>::gather_msg )
+
+
+
+
+
+
+
+#else
+// don't compile fast
+
+#define BOOST_DECLARE_LOG(name,type) type& name ## _boost_log_impl_(); extern boost::logging::detail::log_keeper<type, name ## _boost_log_impl_ > name;
+#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_ > name;
+
+/**
+ Advanced
+*/
+#define BOOST_DECLARE_LOG_WITH_GATHER(name,type,gather_type) BOOST_DECLARE_LOG(name,type)
+
+#endif
+
+
+
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Filter Macros
+
+#define BOOST_DECLARE_LOG_FILTER_NO_NAMESPACE_PREFIX(name,type) type& name ## _boost_log_filter_impl_(); extern boost::logging::detail::log_filter_keeper<type, name ## _boost_log_filter_impl_ > name;
+#define BOOST_DEFINE_LOG_FILTER_NO_NAMESPACE_PREFIX(name,type) type& name ## _boost_log_filter_impl_() \
+ { static type i; return i; } \
+ namespace { boost::logging::detail::fake_using_log ensure_log_is_created_before_main ## name ( name ## _boost_log_filter_impl_() ); } \
+ boost::logging::detail::log_filter_keeper<type, name ## _boost_log_filter_impl_ > name;
+
+
+#define BOOST_DECLARE_LOG_FILTER(name,type) BOOST_DECLARE_LOG_FILTER_NO_NAMESPACE_PREFIX(name, ::boost::logging:: type)
+
+#define BOOST_DEFINE_LOG_FILTER(name,type) BOOST_DEFINE_LOG_FILTER_NO_NAMESPACE_PREFIX(name, ::boost::logging:: type)
+
+
+
+
+
+
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Log Macros
+
+
+
+#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) )
+
+#define BOOST_LOG_USE_LOG_IF_FILTER(l, the_filter) BOOST_LOG_USE_LOG(l, read_msg().gather().out(), the_filter)
+
+#define BOOST_LOG_USE_SIMPLE_LOG_IF_FILTER(l, is_log_enabled) if ( !(is_log_enabled) ) ; else l ->operator()
+
+
+
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Format and Destination Macros
+
+#define BOOST_LOG_FORMAT_MSG(msg_class) \
+ namespace boost { namespace logging { \
+ template<> struct formatter::msg_type<override> { typedef msg_class & type; }; \
+ }}
+
+#define BOOST_LOG_DESTINATION_MSG(msg_class) \
+ namespace boost { namespace logging { \
+ template<> struct destination::msg_type<override> { typedef const msg_class & type; }; \
+ }}
+
+
+
+}}
+
+#endif
+

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-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -3,7 +3,7 @@
 
 
 FIXME change the workflow & logger's definition - it doesn't need a filter
-
+all gather classes - they need to typedef the param they take, so that I can create a virtual function.
 
 
 

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-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -13,6 +13,7 @@
 
 @attention
 The filter is not kept in the logger anymore. They are different concepts. Need to update these pages
+Every time, the logger should contains a process_msg<> class. This is the core class.
 
 @section workflow_introduction Introduction
 
@@ -81,7 +82,7 @@
 };
 
 using namespace boost::logging;
-logger<write_to_cout, filter::no_ts> g_single_log;
+logger<write_to_cout> g_single_log;
 
 #define L_(x) if ( g_single_log) g_single_log.process_msg()(x)
 

Modified: sandbox/logging/boost/logging/detail/use_format_write.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/use_format_write.hpp (original)
+++ sandbox/logging/boost/logging/detail/use_format_write.hpp 2007-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -1,4 +1,4 @@
-// Template.hpp
+// use_format_write.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_use_format_write_HPP_DEFINED
+#define JT28092007_use_format_write_HPP_DEFINED
 
 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
 # pragma once
@@ -25,26 +25,15 @@
 #include <boost/logging/format/optimize.hpp>
 #include <boost/logging/process_msg/ostream_like.hpp>
 #include <boost/logging/detail/manipulator.hpp>
+#include <boost/logging/detail/find_gather.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;
- };
 
         template<class string, class formatter_base, class destination_base> struct find_format_write_params {
             typedef typename boost::logging::format_and_write::simple<string> apply_format_and_write ;
@@ -85,10 +74,10 @@
 @param gather
 */
 template<
- class format_base_type = default_,
- class destination_base_type = default_ ,
- class thread_safety = default_ ,
- class gather = default_
+ class format_base_type ,
+ class destination_base_type ,
+ class thread_safety ,
+ class gather
>
         struct use_format_write {
 

Modified: sandbox/logging/boost/logging/filter.hpp
==============================================================================
--- sandbox/logging/boost/logging/filter.hpp (original)
+++ sandbox/logging/boost/logging/filter.hpp 2007-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -201,6 +201,21 @@
         process_msg_type m_processor;
     };
 
+
+ // specialized for pointers
+ template<class process_msg_type_ > struct logger_base<process_msg_type_* > {
+ typedef process_msg_type_ process_msg_type;
+
+ logger_base(process_msg_type *p) : m_processor(p) {}
+
+ const process_msg_type* operator->() const { return m_processor; }
+ process_msg_type* operator->() { return m_processor; }
+
+ private:
+ process_msg_type *m_processor;
+ };
+
+
     /**
     @brief The logger class. Every log from your application is an instance of this.
 

Modified: sandbox/logging/boost/logging/format.hpp
==============================================================================
--- sandbox/logging/boost/logging/format.hpp (original)
+++ sandbox/logging/boost/logging/format.hpp 2007-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -34,6 +34,16 @@
 #include <boost/logging/detail/manipulator.hpp>
 #include <boost/logging/format_fwd.hpp>
 
+// redefine some of the macros
+#undef JT28092007_macros_HPP_DEFINED
+
+// when including this, we're using the logs
+#ifndef BOOST_LOG_USE_LOGS
+#define BOOST_LOG_USE_LOGS
+#endif
+
+#include <boost/logging/macros.hpp>
+
 namespace boost { namespace logging {
 
 /**

Modified: sandbox/logging/boost/logging/format_fwd.hpp
==============================================================================
--- sandbox/logging/boost/logging/format_fwd.hpp (original)
+++ sandbox/logging/boost/logging/format_fwd.hpp 2007-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -64,6 +64,14 @@
 @endcode
 */
 
+template<
+ class format_base_type = default_,
+ class destination_base_type = default_ ,
+ class thread_safety = default_ ,
+ class gather = default_
+ > struct use_format_write ;
+
+
 }}
 
 #endif

Modified: sandbox/logging/boost/logging/macros.hpp
==============================================================================
--- sandbox/logging/boost/logging/macros.hpp (original)
+++ sandbox/logging/boost/logging/macros.hpp 2007-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -13,18 +13,21 @@
 // See http://www.boost.org for updates, documentation, and revision history.
 // See http://www.torjo.com/log2/ for more details
 
-
+// IMPORTANT : the JT28092007_macros_HPP_DEFINED needs to remain constant - don't change the macro name!
 #ifndef JT28092007_macros_HPP_DEFINED
 #define JT28092007_macros_HPP_DEFINED
 
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
+/*
+ VERY IMPORTANT:
+ Not using #pragma once
+ We might need to re-include this file, when defining the logs
+*/
 
 #include <boost/logging/detail/fwd.hpp>
 #include <time.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <boost/logging/detail/log_keeper.hpp>
 
 namespace boost { namespace logging {
 
@@ -51,9 +54,7 @@
     - BOOST_LOG_COMPILE_FAST_ON
     - BOOST_LOG_COMPILE_FAST_OFF
     - BOOST_LOG_COMPILE_FAST
- - BOOST_LOG_DEFINE_LOGS
- - define it when you define/init your logs
- - if compile fast is "off", this is defined by default
+
 */
 
 #ifdef BOOST_LOG_COMPILE_FAST_ON
@@ -65,74 +66,37 @@
 #define BOOST_LOG_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) {
- printf("LOGGING LIB internal error - should NEVER happen. Please report this to the author of the lib");
- exit(0);
- }
- }
- };
-
-
- /*
- Note that BOOST_DECLARE_LOG_FILTER & BOOST_DEFINE_LOG_FILTER 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:
-
- BOOST_DEFINE_LOG_FILTER(g_level_holder, level::holder);
-
- g_level_holder->set_enabled(level::debug);
- */
- template<class type, type& (*func)() > struct log_filter_keeper {
-
- const type* operator->() const { return &(func()); }
- type* operator->() { return &(func()); }
- };
 
-}
 
-#ifdef BOOST_LOG_COMPILE_FAST
-// ****** Fast compile ******
 
-#define BOOST_DECLARE_LOG_WITH_STRING(name,type,str_type) \
- type& name ## _boost_log_impl_(); extern boost::logging::detail::log_keeper<type, name ## _boost_log_impl_ > name;
 
-// logger< process_msg<gather, do_writer<> > l;
 
-// FIXME need to reimplement them when using compile_fast
-#define BOOST_DECLARE_LOG(name,type) BOOST_DECLARE_LOG_WITH_STRING(name,type, ::boost::logging::msg_type<>::type )
+
+
+
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Defining filter Macros
+
+#ifdef BOOST_LOG_COMPILE_FAST
+// ****** Fast compile ******
+
+#define BOOST_DECLARE_LOG(name,type) \
+ type& name ## _boost_log_impl_(); \
+ ::boost::logging::detail::fast_compile_with_default_gather<>::log_type & name ## _boost_log_impl_light_(); \
+ extern boost::logging::detail::log_keeper<type, name ## _boost_log_impl_ > name;
 
 #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_ > name;
-
+ boost::logging::detail::log_keeper<type, name ## _boost_log_impl_ > name; \
+ ::boost::logging::detail::fast_compile_with_default_gather<>::log_type & name ## _boost_log_impl_light_() \
+ { typedef ::boost::logging::detail::fast_compile_with_default_gather<>::gather_msg gather_msg; \
+ typedef type::process_msg_type process_msg_type; \
+ typedef process_msg_type::write_type write_msg; \
+ static ::boost::logging::detail::process_msg_with_ptr< gather_msg, write_msg > p( name ## _boost_log_impl_() ); \
+ static ::boost::logging::detail::fast_compile_with_default_gather<>::log_type i ( &p ); \
+ return i; }
 
 
 #else
@@ -147,24 +111,11 @@
 /**
     Advanced
 */
-#define BOOST_DECLARE_LOG_WITH_STRING(name,type,str_type) BOOST_DECLARE_LOG(name,type)
+#define BOOST_DECLARE_LOG_WITH_GATHER(name,type,gather_type) BOOST_DECLARE_LOG(name,type)
 
 #endif
 
 
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Defining filter Macros
-
-/*
- when compile fast is "off", we always need BOOST_LOG_DEFINE_LOGS, to get access to the logger class typedefs;
-*/
-#if !defined(BOOST_LOG_COMPILE_FAST)
-#if !defined(BOOST_LOG_DEFINE_LOGS)
-
-#define BOOST_LOG_DEFINE_LOGS
-
-#endif
-#endif
 
 
 
@@ -204,7 +155,8 @@
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // Log Macros
 
-
+// FIXME always need to specify the function to call
+// when compiling fast, I'll use l ## _boost_log_impl() !!!
 
 #define BOOST_LOG_USE_LOG(l, do_func, is_log_enabled) if ( !(is_log_enabled) ) ; else l -> do_func
 

Modified: sandbox/logging/boost/logging/process_msg.hpp
==============================================================================
--- sandbox/logging/boost/logging/process_msg.hpp (original)
+++ sandbox/logging/boost/logging/process_msg.hpp 2007-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -50,6 +50,7 @@
     namespace detail {
         template<class type> type& as_non_const(const type & t) { return const_cast<type&>(t); }
     }
+
 
     /**
     @brief Processes a message (see @ref workflow_processing "workflow")
@@ -103,6 +104,7 @@
     */
     template<class gather_msg, class write_msg> struct process_msg {
         typedef process_msg<gather_msg, write_msg> self;
+ typedef write_msg write_type;
 
         process_msg() {}
         BOOST_LOGGING_FORWARD_CONSTRUCTOR(process_msg,m_writer)
@@ -126,30 +128,53 @@
         write_msg m_writer;
     };
 
+ // FIXME specialize for write_msg* pointer!
+
+
     namespace detail {
- template<class param> struct do_write_base {
- virtual void operator()(param arg) = 0;
- };
 
- template<class gather_msg, class write_msg> struct do_write : do_write_base<typename gather_msg::param> {
+ /**
+ @brief clone of process_msg, for holding the write_msg as pointer
+
+ Does offer same things as process_msg, but no access to the @c writer()
+ */
+ template<class gather_msg> struct process_msg_with_ptr_base {
+ typedef process_msg_with_ptr_base<gather_msg> self;
             typedef typename gather_msg::param param;
 
- BOOST_LOGGING_FORWARD_CONSTRUCTOR(do_write,m_writer)
-
- virtual void operator()(param arg) {
- m_writer(arg);
+ // FIXME watch for copy-construction!
+ /**
+ reads all data about a log message (gathers all the data about it)
+ FIXME
+ */
+ gather_holder<self, gather_msg> read_msg() const { return gather_holder<self, gather_msg>(*this) ; }
+
+ // called after all data has been gathered
+ void on_do_write(gather_msg & gather) const {
+ on_do_write_impl( as_non_const(gather.msg()) );
             }
- write_msg m_writer;
+
+ virtual void on_do_write_impl(param) const = 0;
         };
 
- template<class gather_msg> struct call_write {
+ template<class gather_msg, class write_msg> struct process_msg_with_ptr : process_msg_with_ptr_base<gather_msg> {
             typedef typename gather_msg::param param;
- typedef typename do_write_base<param> writer_type;
- writer_type * m_writer;
- call_write(writer_type * writer) : m_writer(writer) {}
+
+ template<class logger> process_msg_with_ptr(logger & l) {
+ m_writer = &l->writer();
+ }
+
+ void on_do_write_impl(param a) const {
+ (*m_writer)( a) ;
+ }
+
+ private:
+ write_msg *m_writer;
         };
     }
 
+
+
 }}
 
 #endif

Modified: sandbox/logging/boost/logging/process_msg/ostream_like.hpp
==============================================================================
--- sandbox/logging/boost/logging/process_msg/ostream_like.hpp (original)
+++ sandbox/logging/boost/logging/process_msg/ostream_like.hpp 2007-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -186,12 +186,10 @@
 
     returns a cache string
 
- @bug right now prepend_size and append_size are ignored; because we can also return a cache_string_several_str<>
+ @bug right now prepend_size and append_size are ignored; because we can also return a cache_string_several_str<>. When fixing, watch the find_gather class!
 */
 template<
         class cache_string = boost::logging::optimize::cache_string_one_str<hold_string_type> ,
- int prepend_size = 10,
- int append_size = 10,
         class stream_type = std::basic_ostringstream<char_type> > struct return_cache_str {
 
     // what does the gather_msg class return?

Modified: sandbox/logging/lib/logging/samples/basic_usage/log.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/basic_usage/log.cpp (original)
+++ sandbox/logging/lib/logging/samples/basic_usage/log.cpp 2007-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -1,6 +1,8 @@
-// so that we have access to the log_type typedef
+
+// to let the library know we're definining the logs
 #define BOOST_LOG_DEFINE_LOGS
 #include "log.h"
+#include <boost/logging/format.hpp>
 
 // Step 6: Define the filters and loggers you'll use
 BOOST_DEFINE_LOG(g_l, log_type)

Modified: sandbox/logging/lib/logging/samples/basic_usage/log.h
==============================================================================
--- sandbox/logging/lib/logging/samples/basic_usage/log.h (original)
+++ sandbox/logging/lib/logging/samples/basic_usage/log.h 2007-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -1,17 +1,16 @@
 #ifndef LOG_H_header
 #define LOG_H_header
 
+/* VERY IMPORTANT:
+ If using Visual Studio, don't use #pragma once! */
+
 #include <boost/logging/format_fwd.hpp>
 
 // Step 1: Optimize : use a cache string, to make formatting the message faster
 BOOST_LOG_FORMAT_MSG( optimize::cache_string_one_str<> )
 
-#if defined(BOOST_LOG_DEFINE_LOGS)
-#include <boost/logging/format.hpp>
-
 // Step 3 : Specify your logging class(es)
 typedef boost::logging::logger< boost::logging::use_format_write< > > log_type;
-#endif
 
 // Step 4: declare which filters and loggers you'll use
 BOOST_DECLARE_LOG_FILTER(g_l_filter, level::holder)

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-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -75,7 +75,7 @@
 
 
 
-#define BOOST_LOGGING_COMPILE_FAST_OFF
+#define BOOST_LOG_COMPILE_FAST_OFF
 #include <boost/logging/format_fwd.hpp>
 
 // Step 1: Optimize : use a cache string, to make formatting the message faster

Modified: sandbox/logging/lib/logging/samples/scenarios/fastest_no_ostr_like.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/fastest_no_ostr_like.cpp (original)
+++ sandbox/logging/lib/logging/samples/scenarios/fastest_no_ostr_like.cpp 2007-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -52,7 +52,7 @@
 
 
 
-#define BOOST_LOGGING_COMPILE_FAST_OFF
+#define BOOST_LOG_COMPILE_FAST_OFF
 #include <boost/logging/logging.hpp>
 #include <boost/logging/format.hpp>
 

Modified: sandbox/logging/lib/logging/samples/scenarios/fastest_use_ostr_like.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/fastest_use_ostr_like.cpp (original)
+++ sandbox/logging/lib/logging/samples/scenarios/fastest_use_ostr_like.cpp 2007-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -53,7 +53,7 @@
 
 
 
-#define BOOST_LOGGING_COMPILE_FAST_OFF
+#define BOOST_LOG_COMPILE_FAST_OFF
 #include <boost/logging/logging.hpp>
 #include <boost/logging/format.hpp>
 

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-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -77,7 +77,7 @@
 
 
 
-#define BOOST_LOGGING_COMPILE_FAST_OFF
+#define BOOST_LOG_COMPILE_FAST_OFF
 #include <boost/logging/format_fwd.hpp>
 
 // Step 1: Optimize : use a cache string, to make formatting the message faster

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-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -46,7 +46,7 @@
 
 
 
-#define BOOST_LOGGING_COMPILE_FAST_OFF
+#define BOOST_LOG_COMPILE_FAST_OFF
 #include <boost/logging/format.hpp>
 
 using namespace boost::logging;

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-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -76,7 +76,7 @@
 
 
 
-#define BOOST_LOGGING_COMPILE_FAST_OFF
+#define BOOST_LOG_COMPILE_FAST_OFF
 #include <boost/logging/format_fwd.hpp>
 
 // Step 1: Optimize : use a cache string, to make formatting the message faster

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-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -69,7 +69,7 @@
 
 
 
-#define BOOST_LOGGING_COMPILE_FAST_OFF
+#define BOOST_LOG_COMPILE_FAST_OFF
 #include <boost/logging/format_fwd.hpp>
 
 // Step 1: Optimize : use a cache string, to make formatting the message faster

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-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -49,7 +49,7 @@
 
 
 
-#define BOOST_LOGGING_COMPILE_FAST_OFF
+#define BOOST_LOG_COMPILE_FAST_OFF
 #include <boost/logging/format_fwd.hpp>
 
 // Step 1: Optimize : use a cache string, to make formatting the message faster

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-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -504,6 +504,10 @@
                                         />
                                 </FileConfiguration>
                         </File>
+ <File
+ RelativePath="..\..\..\tests\testfast.cpp"
+ >
+ </File>
                         <Filter
                                 Name="scenarios"
>
@@ -558,6 +562,14 @@
                                 <File
                                         RelativePath="..\..\scenarios\mul_levels_one_logger.cpp"
>
+ <FileConfiguration
+ Name="Test|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
                                 </File>
                                 <File
                                         RelativePath="..\..\scenarios\mul_loggers_one_filter.cpp"
@@ -721,6 +733,10 @@
>
                         </File>
                         <File
+ RelativePath="..\..\..\..\..\boost\logging\detail\log_keeper.hpp"
+ >
+ </File>
+ <File
                                 RelativePath="..\..\..\..\..\boost\logging\logging.hpp"
>
                         </File>
@@ -780,6 +796,10 @@
>
                                 </File>
                                 <File
+ RelativePath="..\..\..\..\..\boost\logging\detail\find_gather.hpp"
+ >
+ </File>
+ <File
                                         RelativePath="..\..\..\..\..\boost\logging\format.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-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -1,6 +1,12 @@
 
+v0.9.1, 30 oct 2007
+- implemented BOOST_DEFINE_LOG/BOOST_DECLARE_LOG for when not compiling fast
+- BEFORE a breaking change that will happen :
+ - logger as is now will dissapear
+ - the new logger class will be the old process_msg class
+
 
-v0.9, 28 oct 2007
+v0.9.0, 28 oct 2007
 - use_format_write has 4 params now, I've added 2 new params: thread_safety and gather
   - if you want to leave something unchanged, use "default_" as argument
 - added more complex example: Line Counter application

Added: sandbox/logging/lib/logging/tests/testfast.cpp
==============================================================================
--- (empty file)
+++ sandbox/logging/lib/logging/tests/testfast.cpp 2007-10-29 18:06:56 EDT (Mon, 29 Oct 2007)
@@ -0,0 +1,67 @@
+
+#define BOOST_LOG_COMPILE_FAST_ON
+#include <boost/logging/format_fwd.hpp>
+
+// Step 1: Optimize : use a cache string, to make formatting the message faster
+BOOST_LOG_FORMAT_MSG( optimize::cache_string_one_str<> )
+
+#include <boost/logging/format.hpp>
+
+using namespace boost::logging;
+
+// Step 3 : Specify your logging class(es)
+typedef logger< use_format_write< > > log_type;
+
+BOOST_DECLARE_LOG(g_l, log_type)
+
+
+// Step 4: declare which filters and loggers you'll use (usually in a header file)
+BOOST_DECLARE_LOG_FILTER(g_log_filter, filter::no_ts )
+BOOST_DECLARE_LOG(g_l, log_type)
+
+// Step 5: define the macros through which you'll log
+#define L_ BOOST_LOG_USE_LOG_IF_FILTER(g_l, g_log_filter->is_enabled() )
+
+
+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::append_enter() );
+ g_l->writer().add_destination( destination::file("out.txt") );
+ g_l->writer().add_destination( destination::cout() );
+ g_l->writer().add_destination( destination::dbg_window() );
+
+ // Step 8: use it...
+ int i = 1;
+ L_ << "this is so cool " << i++;
+ L_ << "this is so cool again " << i++;
+
+ std::string hello = "hello", world = "world";
+ L_ << hello << ", " << world;
+
+ g_log_filter->set_enabled(false);
+ L_ << "this will not be written to the log";
+ L_ << "this won't be written to the log";
+
+ g_log_filter->set_enabled(true);
+ L_ << "good to be back ;) " << i++;
+}
+
+
+
+#ifdef SINGLE_TEST
+
+int main() {
+ one_logger_one_filter_example();
+}
+
+#endif
+
+// End of file
+
+// Step 6: Define the filters and loggers you'll use (usually in a source file)
+BOOST_DEFINE_LOG_FILTER(g_log_filter, filter::no_ts )
+BOOST_DEFINE_LOG(g_l, log_type)
+


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