|
Boost-Commit : |
From: john.groups_at_[hidden]
Date: 2008-01-27 21:44:09
Author: jtorjo
Date: 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
New Revision: 42995
URL: http://svn.boost.org/trac/boost/changeset/42995
Log:
[logging]
v0.21.6, 28 jan 2008
- made it much easier to include Boost Logging Lib headers: format_fwd.hpp, named_write_fwd.hpp, which internally accomodate for slow compilation
(that is, even if slow compile, you won't need to include more headers in your your_app_log.h file)
- updated docs + named_writer -> named_write
Added:
sandbox/logging/boost/logging/detail/format_fwd_detail.hpp (contents, props changed)
sandbox/logging/boost/logging/format/named_write.hpp
- copied, changed from r42940, /sandbox/logging/boost/logging/format/named_writer.hpp
sandbox/logging/boost/logging/format/named_write_fwd.hpp (contents, props changed)
sandbox/logging/boost/logging/writer/named_write.hpp
- copied, changed from r42949, /sandbox/logging/boost/logging/writer/named.hpp
Removed:
sandbox/logging/boost/logging/format/named_writer.hpp
sandbox/logging/boost/logging/writer/named.hpp
Text files modified:
sandbox/logging/boost/logging/defaults.hpp | 2
sandbox/logging/boost/logging/detail/find_format_writer.hpp | 4
sandbox/logging/boost/logging/detail/format_write_detail.hpp | 12 ++-
sandbox/logging/boost/logging/detail/logger_base.hpp | 18 ++++
sandbox/logging/boost/logging/detail/macros.hpp | 71 +++++++++++-------
sandbox/logging/boost/logging/detail/manipulator.hpp | 28 +++++--
sandbox/logging/boost/logging/detail/raw_doc/acknowledgments.hpp | 2
sandbox/logging/boost/logging/detail/raw_doc/caching.hpp | 2
sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp | 7 +
sandbox/logging/boost/logging/detail/raw_doc/common_usage_steps_fd.hpp | 44 +++++++++-
sandbox/logging/boost/logging/detail/raw_doc/defining_logger_macros.hpp | 59 +++++++++++++--
sandbox/logging/boost/logging/detail/raw_doc/headers_to_include.hpp | 17 +++-
sandbox/logging/boost/logging/detail/raw_doc/miscelaneous.hpp | 2
sandbox/logging/boost/logging/detail/raw_doc/scenarios_code.hpp | 6 +
sandbox/logging/boost/logging/detail/raw_doc/todo.hpp | 8 +
sandbox/logging/boost/logging/detail/raw_doc/workflow.hpp | 6
sandbox/logging/boost/logging/format.hpp | 18 +++-
sandbox/logging/boost/logging/format/destination/defaults.hpp | 22 +++++
sandbox/logging/boost/logging/format/destination/file.hpp | 2
sandbox/logging/boost/logging/format/destination/rolling_file.hpp | 2
sandbox/logging/boost/logging/format/named_write.hpp | 4
sandbox/logging/boost/logging/format_fwd.hpp | 150 ---------------------------------------
sandbox/logging/boost/logging/writer/named_write.hpp | 46 ++++++-----
sandbox/logging/boost/logging/writer/on_dedicated_thread.hpp | 1
sandbox/logging/lib/logging/internal/vc8/loggingvc8/loggingvc8.vcproj | 21 ++--
sandbox/logging/lib/logging/internal/vc8/loggingvc8/test_now.cpp | 74 ++++++++++++++++---
sandbox/logging/lib/logging/samples/basic_usage/main.cpp | 2
sandbox/logging/lib/logging/samples/scenarios/custom_fmt_dest.cpp | 11 --
sandbox/logging/lib/logging/samples/scenarios/ded_loger_one_filter.cpp | 13 ---
sandbox/logging/lib/logging/samples/scenarios/fastest_no_ostr_like.cpp | 10 --
sandbox/logging/lib/logging/samples/scenarios/fastest_use_ostr_like.cpp | 8 --
sandbox/logging/lib/logging/samples/scenarios/mul_levels_mul_logers.cpp | 4
sandbox/logging/lib/logging/samples/scenarios/mul_levels_one_logger.cpp | 2
sandbox/logging/lib/logging/samples/scenarios/mul_loggers_one_filter.cpp | 11 --
sandbox/logging/lib/logging/samples/scenarios/no_levels_with_route.cpp | 10 --
sandbox/logging/lib/logging/samples/scenarios/one_loger_one_filter.cpp | 2
sandbox/logging/lib/logging/samples/scenarios/ts_loger_one_filter.cpp | 15 ---
sandbox/logging/lib/logging/samples/scenarios/use_tss_ostringstream.cpp | 11 --
sandbox/logging/lib/logging/samples/scenarios/using_tags.cpp | 9 --
sandbox/logging/lib/logging/samples/scenarios/your_scenario.cpp | 10 --
sandbox/logging/lib/logging/samples/starter/my_app_log.cpp | 7 +
sandbox/logging/lib/logging/samples/starter/my_app_log.h | 12 +--
42 files changed, 372 insertions(+), 393 deletions(-)
Modified: sandbox/logging/boost/logging/defaults.hpp
==============================================================================
--- sandbox/logging/boost/logging/defaults.hpp (original)
+++ sandbox/logging/boost/logging/defaults.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -50,7 +50,7 @@
#include <boost/logging/defaults.hpp>
namespace boost { namespace logging {
- struct types<override> {
+ struct types<override> : default_types {
// define your types
typedef wchar_t char_type;
// etc.
Modified: sandbox/logging/boost/logging/detail/find_format_writer.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/find_format_writer.hpp (original)
+++ sandbox/logging/boost/logging/detail/find_format_writer.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -123,8 +123,8 @@
typedef typename ::boost::logging::destination::msg_type<override_>::type destination_msg_type;
typedef typename ::boost::logging::types<override_>::lock_resource default_lock_resource;
- typedef ::boost::logging::formatter::base< format_msg_type, default_ > default_format_base;
- typedef ::boost::logging::destination::base< destination_msg_type, default_ > default_destination_base;
+ typedef ::boost::logging::formatter::base< default_, default_ > default_format_base;
+ typedef ::boost::logging::destination::base< default_, default_ > default_destination_base;
typedef typename use_default<format_base_type, default_format_base > ::type format_base;
typedef typename use_default<destination_base_type, default_destination_base > ::type destination_base;
Added: sandbox/logging/boost/logging/detail/format_fwd_detail.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/detail/format_fwd_detail.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -0,0 +1,177 @@
+// format_fwd_detail.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_fwd_detail_HPP_DEFINED
+#define JT28092007_format_fwd_detail_HPP_DEFINED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/logging/logging.hpp>
+#include <boost/logging/format/optimize.hpp>
+#include <boost/logging/gather/ostream_like.hpp>
+
+namespace boost { namespace logging {
+
+namespace writer {
+ template<class msg_type, class base_type> struct on_dedicated_thread ;
+ template<class base_type> struct ts_write ;
+
+ /**
+ @brief specify thread-safety of your logger_format_write class
+ */
+ namespace threading {
+ /** @brief not thread-safe */
+ struct no_ts {};
+ /** @brief thread-safe write. All writes are protected by a lock */
+ struct ts_write {};
+ /** @brief thread-safe write on a dedicated thread. Very efficient. Formatting & writing to destinations happens on the dedicated thread */
+ struct on_dedicated_thread {};
+ }
+}
+
+/**
+@file boost/logging/format_fwd.hpp
+
+Include this file when you're using @ref manipulator "formatters and destinations",
+and you want to declare the logger classes, in a header file
+(using BOOST_DECLARE_LOG)
+
+Example:
+
+@code
+#ifndef LOG_H_header
+#define LOG_H_header
+
+#include <boost/logging/logging.hpp>
+#include <boost/logging/format/optimize.hpp>
+
+BOOST_LOG_FORMAT_MSG( boost::logging::optimize::cache_string_one_str<> )
+
+#if defined(BOOST_LOG_DEFINE_LOGS)
+#include <boost/logging/format.hpp>
+
+typedef logger_format_write< > logger_type;
+#endif
+
+BOOST_DECLARE_LOG(g_l, logger_type)
+BOOST_DECLARE_LOG_FILTER(g_l_filter, level::holder)
+
+#define LDBG_ BOOST_LOG_USE_LOG_IF_LEVEL(g_l(), g_log_level(), debug ) << "[dbg] "
+#define LERR_ BOOST_LOG_USE_LOG_IF_LEVEL(g_l(), g_log_level(), error ) << "[ERR] "
+#define LAPP_ BOOST_LOG_USE_LOG_IF_LEVEL(g_l(), g_log_level(), info ) << "[app] "
+
+void init_logs();
+
+#endif
+@endcode
+*/
+template<
+ class format_base_type = default_,
+ class destination_base_type = default_ ,
+ class thread_safety = default_ ,
+ class gather = default_,
+ class lock_resource = default_
+ > struct logger_format_write;
+
+
+/**
+ dumps the default levels
+
+ Has a static function : dump, which dumps the level as string (works only for the default levels; for any other level, returns "")
+*/
+struct dump_default_levels {
+ static const char_type * dump(::boost::logging::level::type lvl) {
+ using namespace ::boost::logging::level;
+ switch ( lvl) {
+ case debug: return BOOST_LOG_STR("[debug] ");
+ case info: return BOOST_LOG_STR("[info] ");
+ case warning: return BOOST_LOG_STR("[warn] ");
+ case error: return BOOST_LOG_STR("[ERROR] ");
+ case fatal: return BOOST_LOG_STR("[FATAL] ");
+ default: return BOOST_LOG_STR("");
+ }
+ }
+};
+
+/**
+ Specifies the class that will dump the levels. Used by formatter::tag::level class.
+*/
+template<class T = override> struct dump_level {
+ typedef dump_default_levels type;
+};
+
+
+namespace detail {
+ // finds the gather type, when using formatting (for logger_format_write)
+ template<class gather> struct format_find_gather {
+ typedef typename detail::to_override<gather>::type override_;
+
+ // FIXME in the future, I might provide gather as a specific class!
+ typedef typename formatter::msg_type<override_>::type msg_type;
+ typedef typename ::boost::logging::gather::find<override_>::template from_msg_type<msg_type>::type type;
+ };
+}
+
+
+// specialize for logger_format_write
+template<class format_base, class destination_base, class thread_safety, class gather, class lock_resource>
+ struct logger_to_gather< logger_format_write<format_base, destination_base, thread_safety, gather, lock_resource> > {
+
+ typedef typename detail::format_find_gather<gather>::type gather_type;
+};
+
+namespace writer {
+ template<class format_write_ = default_ > struct named_write ;
+}
+
+/** @brief named_logger<...>::type finds a logger that uses @ref writer::named_write<> "Named Formatters and Destinations"
+
+@code
+#include <boost/logging/format/named_write.hpp>
+@endcode
+
+Example:
+@code
+typedef boost::logging::named_logger<>::type logger_type;
+@endcode
+
+Setting the formatters and destinations to write to is extremely simple:
+
+@code
+// first param - the formatter(s) , second param : the destination(s)
+g_l()->writer().write("%time%($hh:$mm.$ss.$mili) [%idx%] |\n", "cout file(out.txt) debug");
+@endcode
+
+To see the syntax, see writer::named_write
+
+*/
+template<class gather = default_> struct named_logger {
+ typedef typename detail::format_find_gather<gather>::type gather_type;
+
+ /** @copydoc named_logger */
+ typedef logger< gather_type, writer::named_write<> > type;
+};
+
+}}
+
+
+#include <boost/logging/detail/scenario.hpp>
+#include <boost/logging/detail/tags.hpp>
+
+#endif
+
Modified: sandbox/logging/boost/logging/detail/format_write_detail.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/format_write_detail.hpp (original)
+++ sandbox/logging/boost/logging/detail/format_write_detail.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -133,8 +133,8 @@
template<
class formatter_base,
class destination_base,
- class lock_resource = typename boost::logging::types<override>::lock_resource ,
- class apply_format_and_write = ::boost::logging::format_and_write::simple<typename formatter_base::raw_param>,
+ class lock_resource = default_ ,
+ class apply_format_and_write = default_ ,
class router_type = msg_route::simple<formatter_base, destination_base, lock_resource> ,
class formatter_array = array::shared_ptr_holder<formatter_base> ,
class destination_array = array::shared_ptr_holder<destination_base> >
@@ -142,9 +142,13 @@
typedef typename formatter_base::ptr_type formatter_ptr;
typedef typename destination_base::ptr_type destination_ptr;
+ typedef typename use_default<apply_format_and_write, ::boost::logging::format_and_write::simple<typename formatter_base::raw_param> > ::type apply_format_and_write_type;
+
+ typedef typename boost::logging::detail::to_override<formatter_base>::type override_;
+ typedef typename use_default<lock_resource, typename boost::logging::types<override_>::lock_resource > ::type lock_resource_type;
+
typedef formatter_base formatter_base_type;
typedef destination_base destination_base_type;
- typedef lock_resource lock_resource_type;
format_write() : m_router(m_formatters, m_destinations) {}
@@ -269,7 +273,7 @@
does the actual write
*/
template<class msg_type> void operator()(msg_type & msg) const {
- router().template write<apply_format_and_write>(msg);
+ router().template write<apply_format_and_write_type>(msg);
}
private:
Modified: sandbox/logging/boost/logging/detail/logger_base.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/logger_base.hpp (original)
+++ sandbox/logging/boost/logging/detail/logger_base.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -114,6 +114,10 @@
}
+ /** @brief logger base class.
+
+ @class logger_base
+ */
template<class gather_msg , class write_msg, class dummy = override > struct logger_base
: detail::default_cache_keeper< detail::cache_before_init<typename detail::find_gather_if_default<gather_msg>::msg_type > >,
detail::common_base_holder<gather_msg, write_msg>,
@@ -150,8 +154,18 @@
/** @brief Marks this logger as initialized
- You might log messages before the logger is initialized. In this case, they are cached, and written to the logger,
- when you mark it as "initialized"
+ You might log messages before the logger is initialized. In this case, they are cached, and will be written to the logger
+ only when you mark it as "initialized"
+
+ Example:
+
+ @code
+ // the logger
+ BOOST_DEFINE_LOG(g_l, logger_type)
+
+ // marking the logger as initialized
+ g_l()->mark_as_initialized();
+ @endcode
*/
void mark_as_initialized() {
self().turn_cache_off();
Modified: sandbox/logging/boost/logging/detail/macros.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/macros.hpp (original)
+++ sandbox/logging/boost/logging/detail/macros.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -45,7 +45,7 @@
- @ref BOOST_DEFINE_LOG_FILTER
- @ref BOOST_DEFINE_LOG_FILTER_WITH_ARGS
- @ref macros_use
- - @ref BOOST_LOG_USE_LOG
+ - @ref BOOST_LOG_USE_LOG
- @ref BOOST_LOG_USE_LOG_IF_LEVEL
- @ref BOOST_LOG_USE_LOG_IF_FILTER
- @ref BOOST_LOG_USE_SIMPLE_LOG_IF_FILTER
@@ -58,9 +58,8 @@
- @ref BOOST_LOG_TAG_FILELINE
- @ref BOOST_LOG_TAG_FUNCTION
- @ref macros_compile_time
- - @ref BOOST_LOG_COMPILE_FAST_ON
- - @ref BOOST_LOG_COMPILE_FAST_OFF
- - @ref BOOST_LOG_COMPILE_FAST
+ - @ref macros_compile_time_fast
+ - @ref macros_compile_time_slow
- @ref boost_log_compile_results
- @ref macros_tss
- @ref BOOST_LOG_TSS_USE_INTERNAL
@@ -216,7 +215,7 @@
-_at_subsection macros_use Defining your own macros for logging
+@subsection macros_use Macros that help you define your own macros for logging
@subsubsection BOOST_LOG_USE_LOG_IF_LEVEL BOOST_LOG_USE_LOG_IF_LEVEL
@@ -234,6 +233,8 @@
#define LERR_ BOOST_LOG_USE_LOG_IF_LEVEL(g_log_err(), g_log_level(), error )
@endcode
+See @ref defining_logger_macros for more details
+
@subsubsection BOOST_LOG_USE_LOG_IF_FILTER BOOST_LOG_USE_LOG_IF_FILTER
Uses a logger if a filter is enabled:
@@ -247,6 +248,7 @@
#define LERR_ BOOST_LOG_USE_LOG_IF_FILTER(g_log_err(), g_log_filter()->is_enabled() )
@endcode
+See @ref defining_logger_macros for more details
@subsubsection BOOST_LOG_USE_LOG BOOST_LOG_USE_LOG
@@ -258,6 +260,7 @@
Normally you don't use this directly. You use @ref BOOST_LOG_USE_LOG_IF_FILTER or @ref BOOST_LOG_USE_LOG_IF_LEVEL instead.
+See @ref defining_logger_macros for more details
@subsubsection BOOST_LOG_USE_SIMPLE_LOG_IF_FILTER BOOST_LOG_USE_SIMPLE_LOG_IF_FILTER
@@ -283,6 +286,7 @@
#define LAPP_ BOOST_LOG_USE_SIMPLE_LOG_IF_FILTER(g_log_app(), g_log_filter()->is_enabled() )
@endcode
+See @ref defining_logger_macros for more details
@@ -398,37 +402,41 @@
@subsection macros_compile_time Macros that treat compilation time
Assume you're using formatters and destinations, and you
-<tt>#include <boost/logging/format.hpp> </tt> or
-<tt>#include <boost/logging/format_ts.hpp> </tt>. If you include this in every file (indirectly, you'll
-be including some @c log.h file, which will then include the above), this will increase compilation time quite a bit.
-
-So, you can choose to:
-- have fast compilation time, and a virtual function call per each logged message (default)
-- have everything inline (no virtual function calls), very fast, and slow compilation
-
-Most of the time you won't notice the extra virtual function call, and the compilation time will be faster.
-However, just in case you'll sometime want the very fast configuration, just turn the fast compilation off, by using the
-_at_ref BOOST_LOG_COMPILE_FAST_OFF directive.
+<tt>#include <boost/logging/format.hpp> </tt> in every source file when you want to do logging.
+This will increase compilation time quite a bit (30 to 50%, in my tests; depending on your application' complexity, this could go higher).
-You might want this turned off, for the release configuration - either way, it's your call.
-In case you want to have both possibilities available to you (fast compilation and speedy), you'll want to take a look at
-the @ref starter_project "the starter project".
+Thus, you can choose to:
+-# have fast compilation time, and a virtual function call per each logged message (default on debug mode)
+-# have everything inline (no virtual function calls), very fast, and slower compilation (default on release mode)
+In the former case, most of the time you won't notice the extra virtual function call, and the compilation time will be faster.
-_at_subsubsection BOOST_LOG_COMPILE_FAST_ON BOOST_LOG_COMPILE_FAST_ON
+\n\n
+@subsubsection macros_compile_time_fast Fast Compilation time
+
+- this is turned on by default on debug mode
+- this is turned off by default on release mode
+- to force it, define BOOST_LOG_COMPILE_FAST_ON directive
+
+FIXME explain about what to include
+
+\n\n
+@subsubsection macros_compile_time_slow Slow Compilation time
+
+- this is turned off by default on debug mode
+- this is turned on by default on release mode
+- to force it, define BOOST_LOG_COMPILE_FAST_OFF directive
+
+FIXME explain about what to include
+
+In case you want to have both possibilities available to you (fast compilation and slow compilation), you'll want to take a look at
+the @ref starter_project "the starter project".
-If you define this, it turns fast compilation on (this is the default anyway).
-_at_subsubsection BOOST_LOG_COMPILE_FAST_OFF BOOST_LOG_COMPILE_FAST_OFF
-If you define this, it turns fast compilation off.
-_at_subsubsection BOOST_LOG_COMPILE_FAST BOOST_LOG_COMPILE_FAST
-If defined, it means we're doing fast-compile. Otherwise, we're not doing fast compile.
-_at_note
-Don't define this! It's defined automatically.
@subsubsection boost_log_compile_results Compile time sample (and results)
@@ -514,8 +522,13 @@
#elif defined(BOOST_LOG_COMPILE_FAST_OFF)
#undef BOOST_LOG_COMPILE_FAST
#else
-// by default, turned on
-#define BOOST_LOG_COMPILE_FAST
+ // by default...
+ #if defined(NDEBUG)
+ // ... turned off in release
+ #else
+ // ... turned on in debug
+ #define BOOST_LOG_COMPILE_FAST
+ #endif
#endif
Modified: sandbox/logging/boost/logging/detail/manipulator.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/manipulator.hpp (original)
+++ sandbox/logging/boost/logging/detail/manipulator.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -525,13 +525,15 @@
/**
@brief Formatter is a manipulator. It allows you to format the message before writing it to the destination(s)
-talk about format_base
-
-FIXME
-
-_at_sa manipulator::base, manipulator::base_no_opearator_call, manipulator::non_const_context
+@sa manipulator, manipulator::non_const_context
*/
namespace formatter {
+ namespace detail {
+ template<class arg, class ptr, class dummy = override > struct format_base_finder {
+ typedef typename use_default<arg, typename boost::logging::formatter::msg_type<dummy>::type > ::type arg_type;
+ typedef boost::logging::manipulator::base< arg_type, arg_type &, ptr> type;
+ };
+ }
/**
@brief What to use as base class, for your formatter classes
@@ -541,9 +543,9 @@
*/
template<
// note: I'm counting on these defaults, in format_find_writer class
- class arg_type = typename msg_type<override>::type,
+ class arg_type = default_ ,
class ptr_type_ = default_ >
- struct base : boost::logging::manipulator::base< arg_type, arg_type& , ptr_type_> {
+ struct base : detail::format_base_finder<arg_type,ptr_type_>::type {
};
/**
@@ -577,9 +579,17 @@
Some viable destinations are : the console, a file, a socket, etc.
+@sa manipulator, manipulator::non_const_context
*/
namespace destination {
+ namespace detail {
+ template<class arg, class ptr, class dummy = override > struct destination_base_finder {
+ typedef typename use_default<arg, typename boost::logging::destination::msg_type<dummy>::type > ::type arg_type;
+ typedef boost::logging::manipulator::base< arg_type, const arg_type &, ptr> type;
+ };
+ }
+
/**
@brief What to use as base class, for your destination classes
@@ -588,9 +598,9 @@
*/
template<
// note: I'm counting on these defaults, in format_find_writer class
- class arg_type = typename msg_type<override>::type,
+ class arg_type = default_ ,
class ptr_type_ = default_ >
- struct base : boost::logging::manipulator::base< arg_type, const arg_type& , ptr_type_> {
+ struct base : detail::destination_base_finder<arg_type,ptr_type_>::type {
};
using boost::logging::manipulator::non_const_context;
Modified: sandbox/logging/boost/logging/detail/raw_doc/acknowledgments.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/acknowledgments.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/acknowledgments.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -17,6 +17,8 @@
- Thomas Kreisel - for testing my lib in Linux, providing patches, finding possible problems in my lib
- Lucian Ciufudean - for giving me thorough feedback on the documentation, even though he's a Java freak...
- Andrei Alexandrescu - for reminding me that the default syntax should be soooo easy... Thus, named_logger was born!
+- Amit Jain - for giving me quite a lot of criticism, but who made me make the docs a lot easier (or at least I hope so :))
+
*/
Modified: sandbox/logging/boost/logging/detail/raw_doc/caching.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/caching.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/caching.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -130,7 +130,7 @@
There are several such policies, find them in the lock_resource_finder namespace.
If you want to override the above, make sure you define the @c BOOST_LOG_BEFORE_INIT_LOCK_RESOURCE_CLASS macro before including
-any Boost Log headers. Example:
+any Boost Logging Lib headers. Example:
@code
#define BOOST_LOG_BEFORE_INIT_LOCK_RESOURCE_CLASS ::boost::logging::lock_resource_finder::tss_once_init<>
Modified: sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -1,7 +1,12 @@
/**
@page page_changelog Changelog
-_at_section changelog_cur_ver Current Version: v0.21.4, 26 jan 2008
+@section changelog_cur_ver Current Version: v0.21.6, 28 jan 2008
+- made it much easier to include Boost Logging Lib headers: format_fwd.hpp, named_write_fwd.hpp, which internally accomodate for slow compilation
+ (that is, even if slow compile, you won't need to include more headers in your your_app_log.h file)
+- updated docs + named_writer -> named_write
+- now can include <boost/logging/format.hpp> without including format_fwd.hpp before, and use BOOST_LOG* macros, and code still compiles and works as expected
+- moved tags.hpp - not to be included directly by mistake
- added BOOST_LOG_DONOT_USE_WCHAR_T for Windows users
- added more docs to named_logger
- added named_logger - much easier to use the logging lib - doesn't require any advanced knowledge at all
Modified: sandbox/logging/boost/logging/detail/raw_doc/common_usage_steps_fd.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/common_usage_steps_fd.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/common_usage_steps_fd.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -3,16 +3,46 @@
/**
@page common_usage_steps_fd Common steps when using Formatters and destinations
-The usual steps when using the Boost Logging Lib are:
+\n
+<b>The easy way, use Named Formatters and Destinations</b>
+
+You use a string to specify Formatters, and a string to specify Destinations. Thus, you use the @ref boost::logging::writer::named_write "writer::named_write".
+
+First, the examples: @ref scenarios_code_mom "example 1", @ref scenarios_code_noo "example 2"
+
+
+
- Step 1: (optional) Specify your @ref BOOST_LOG_FORMAT_MSG "format message class" and/or @ref BOOST_LOG_DESTINATION_MSG "destination message class". By default, it's <tt>std::(w)string</tt>.
- You'll use this when you want a @ref optimize "optimize string class".
+ You'll use this when you want a @ref optimize "optimize string class". Or, when @ref boost::logging::tag "using tags"
+- Step 2: Specify your logging and filter classes
+ - Step 2A: Typedef your logger as <tt>typedef boost::logging::named_logger<>::type logger_type;</tt> and @ref typedefing_your_filter "typedef your filter class"
+ - Step 2B: Declare the @ref declare_define "filters and loggers" you'll use (in a header file)
+ - Step 2C: Define the @ref declare_define "filters and loggers" you'll use (in a source file). We need this separation
+ (into declaring and defining the logs/filters), in order to @ref macros_compile_time "make compilation times fast".
+- Step 3: Define the @ref defining_logger_macros "macros through which you'll do logging"
+- Step 4: Initialize the logger.
+ - Step 4A: Set the @ref boost::logging::writer::named_write "formatters and destinations", as strings.
+ - Step 4B: @ref boost::logging::logger_base::mark_as_initialized "Mark the logger as initialized"
+
+
+\n
+<b>The manual way</b>
+
+First, the examples: @ref common_your_scenario_code "example 1", @ref common_your_mul_logger_one_filter "example 2"
+
+- Step 1: (optional) Specify your @ref BOOST_LOG_FORMAT_MSG "format message class" and/or @ref BOOST_LOG_DESTINATION_MSG "destination message class". By default, it's <tt>std::(w)string</tt>.
+ You'll use this when you want a @ref optimize "optimize string class". Or, when @ref boost::logging::tag "using tags"
- Step 2: (optional) Specify your @ref boost::logging::manipulator "formatter & destination base classes"
-- Step 3: @ref defining_your_logger "Specify your logger class(es)"
-- Step 4: Declare the @ref defining_your_filter "filters" and @ref defining_your_logger "loggers" you'll use (in a header file)
-- Step 5: Define the @ref macros_use "macros through which you'll do logging"
-- Step 6: Define the @ref defining_your_logger "loggers" and the @ref defining_your_filter "filters" you'll use (in a source file). We need this separation
+- Step 3: Specify your logging and filter classes
+ - Step 3A: @ref typedefing_your_filter "Typedef your filter class(es)" and @ref typedefing_your_logger "Typedef your logger class(es)"
+ - Step 3B: Declare the @ref declare_define "filters and loggers" you'll use (in a header file)
+ - Step 3C: Define the @ref declare_define "filters and loggers" you'll use (in a source file). We need this separation
(into declaring and defining the logs/filters), in order to @ref macros_compile_time "make compilation times fast".
-- Step 7: Add @ref boost::logging::manipulator "formatters and destinations". That is, how the message is to be formatted...
+- Step 4: Define the @ref defining_logger_macros "macros through which you'll do logging"
+- Step 5: Initialize the logger
+ - Step 5A: Add @ref boost::logging::manipulator "formatters and destinations". That is, how the message is to be formatted...
+ - Step 5B: @ref boost::logging::logger_base::mark_as_initialized "Mark the logger as initialized"
+
*/
Modified: sandbox/logging/boost/logging/detail/raw_doc/defining_logger_macros.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/defining_logger_macros.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/defining_logger_macros.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -3,6 +3,16 @@
/**
@page defining_logger_macros Defining macros to do logging
+- @ref defining_logger_macros_prerequisites
+- @ref defining_logger_macros_easiest
+- @ref defining_logger_macros_levels
+- @ref defining_logger_macros_file_name
+- @ref defining_logger_macros_module_name
+
+
+\n\n
+@section defining_logger_macros_prerequisites Defining macros to do logging - prerequisites
+
Now that you've @ref defining_your_logger_filter "declared and defined your loggers/filters", it's time to log messages in code.
You'll have to define macros to log messages in code. Such a macro needs to do the following:
@@ -12,21 +22,50 @@
To see if the logger is enabled, you'll use a filter. Note that you can reuse the same filter for multiple loggers, in case you want to.
-To define a macro to logmessages in code, I've provided these few macros to help you:
--# BOOST_LOG_USE_LOG_IF_FILTER(logger, filter_is_enabled)
--# BOOST_LOG_USE_LOG_IF_LEVEL(logger, filter, level)
--# BOOST_LOG_USE_SIMPLE_LOG_IF_FILTER(logger, filter_is_enabled)
+To define a macro to log messages in code, I've provided these few macros to help you:
+-# <tt>BOOST_LOG_USE_LOG_IF_FILTER(logger, filter_is_enabled)</tt>
+-# <tt>BOOST_LOG_USE_LOG_IF_LEVEL(logger, filter, level)</tt>
+-# <tt>BOOST_LOG_USE_SIMPLE_LOG_IF_FILTER(logger, filter_is_enabled)</tt>
The parameters are:
-- logger - a pointer to a logger you've declared
-- filter_is_enabled - how to determine if the filter is enabled.
+- @c %logger - a pointer to a logger you've declared
+- @c filter_is_enabled - how to determine if the filter is enabled.
- For simple filters this can be a simple <tt>filter()->is_enabled()</tt>
- More complex filters can be passed additional information (as you'll see below)
- As an example of filter that needs an extra argument, we have: \n
<tt>BOOST_LOG_USE_LOG_IF_LEVEL(l, holder, the_level) = BOOST_LOG_USE_LOG_IF_FILTER(l, holder->is_enabled(the_level)) </tt>
-- level - in case you have a filter based on level
+- @c %level - in case you have a filter based on level
+
+How you define your macros is up to you.
+
+\n\n
+@section defining_logger_macros_easiest The easiest: Example of Logging, with a filter that can be turned on/off
+
+Assume you have a filter that can only be turned on or off.
+
+@code
+typedef logger_format_write< > logger_type;
+typedef level::no_ts filter_type;
+
+BOOST_DECLARE_LOG_FILTER(g_log_filter, filter_type )
+BOOST_DECLARE_LOG(g_l, logger_type)
-How you define your macros is up to you. Assuming you have a filter based on levels, you can:
+#define L_ BOOST_LOG_USE_LOG_IF_FILTER(g_l(), g_log_filter()->is_enabled() )
+@endcode
+
+\n
+Using it in code:
+
+@code
+L_ << "this is a cool message " << i++;
+L_ << "this is another cool message " << i++;
+@endcode
+
+
+\n\n
+@section defining_logger_macros_levels Example of Logging, filtered by levels
+
+Assuming you have a filter based on levels, you can:
- either define an <tt>L_(level)</tt> macro, which will care about the level or,
- define an <tt>L..._</tt> macro for each level you want (for instance, LDBG_, LAPP_, LERR_).
@@ -68,6 +107,8 @@
@endcode
\n\n
+@section defining_logger_macros_file_name Logging with a filter based on file name
+
Another example. Assume you have a @c file_filter class, which filters based on file name (a file can be turned on or off):
@code
@@ -99,6 +140,8 @@
\n\n
+@section defining_logger_macros_module_name Logging with a filter based on module name
+
Another example. Assume you have a @c module_filter class, which filters based on module name (logging for a module can be turne on or off) :
@code
Modified: sandbox/logging/boost/logging/detail/raw_doc/headers_to_include.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/headers_to_include.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/headers_to_include.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -14,19 +14,28 @@
If you want to log a message using a certain logger, that logger needs to be declared.
-- when using Formatters and Destinations, or the Named Writer (an easy interface to Formatters and Destinations)
+- when using the @ref boost::logging::writer::named_write "Named Writer" (an easy interface to Formatters and Destinations)
+
+@code
+#include <boost/logging/format/named_write_fwd.hpp>
+@endcode
+
+
+- when using Formatters and Destinations
@code
#include <boost/logging/format_fwd.hpp>
@endcode
+
+
- when using Logging, without Formatters/Destinations
@code
#include <boost/logging/logging.hpp>
@endcode
-Note that these need to be included first, before any other Boost Log headers.
+Note that these need to be included first, before any other Boost Logging Lib headers.
\n\n
@@ -37,10 +46,10 @@
In other words, the corresponding logger class needs to be defined.
-- when using the Named Writer (an easy interface to Formatters and Destinations)
+- when using the @ref boost::logging::writer::named_write "Named Writer" (an easy interface to Formatters and Destinations)
@code
-#include <boost/logging/format/named_writer.hpp>
+#include <boost/logging/format/named_write.hpp>
@endcode
Modified: sandbox/logging/boost/logging/detail/raw_doc/miscelaneous.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/miscelaneous.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/miscelaneous.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -20,7 +20,7 @@
- just <tt>\#define BOOST_LOG_USE_WCHAR_T</tt> before including any Boost.Logging files
- For Windows, in case the @c UNICODE or @c _UNICODE is defined, the @c BOOST_LOG_USE_WCHAR_T is defined automatically for you
- - If you don't wish that, please <tt>#define BOOST_LOG_DONOT_USE_WCHAR_T</tt> globally, before including any Boost Log files.
+ - If you don't wish that, please <tt>#define BOOST_LOG_DONOT_USE_WCHAR_T</tt> globally, before including any Boost Logging Lib files.
*/
Modified: sandbox/logging/boost/logging/detail/raw_doc/scenarios_code.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/scenarios_code.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/scenarios_code.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -38,6 +38,12 @@
+@section common_your_mul_logger_one_filter Multiple loggers, one filter
+
+@include mul_loggers_one_filter.cpp
+\n\n\n
+
+
*/
}}
Modified: sandbox/logging/boost/logging/detail/raw_doc/todo.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/todo.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/todo.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -30,10 +30,14 @@
- @c normal have a logger_with_filter class, to make using the lib easier (this would hold the logger and the filter).
-- @c normal writer::named<> need to allow tags by default, here!
+- @c high writer::named_write<> need to allow tags by default, here!
- @c high scenario::use class - have ::gather and ::write typedefs !!!
this way we can have: named_logger< finder::gather , writer::named<finder::writer> >
+ same goes for logger_format_write class.
+
+- @c normal make it so that I use BOOST_LOG_USE_WCHAR_T as little as possible
+ for instance, it's not needed in cout_t, cerr_t.
- @c high should see that if I have a tss* object, if used AFTER destruction, will not crash the application.
in other words, if I have tss_with_cache<int>, after this is destroyed, I should always reference the original int or so.
@@ -137,6 +141,8 @@
- @c low have a document with differences from v1 and v2
- Votes: 1
+- @c normal explain BOOST_LOG_USE_SIMPLE_LOG_IF_FILTER (defining_logger_macros)
+
- @c normal explain about cachestring clases
- @c normal about is_generic formatters/destinations (note that I might have already written about this)
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 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -65,10 +65,10 @@
#define LAPP_ BOOST_LOG_USE_LOG_IF_LEVEL(g_log_app(), g_log_level(), info )
@endcode
-Every time, before anything gets written to the log, the filter is asked if "it's enabled". If so, the processing of the message takes place
+Every time, before anything gets written to the log, the filter is asked if <em>it's enabled</em>. If so, the processing of the message takes place
(gathering the message and then writing it). Otherwise, the log message is completely ignored.
-What "it's enabled" is depends on the filter class you use:
+What <em>it's enabled</em> is depends on the filter class you use:
- if it's a simple class (filter::no_ts, filter::ts, filter::use_tss_with_cache), it's simply the @c is_enabled function (Example 1, above)
- if it's a more complex class, it's up to you
- for instance, the level::holder_no_ts exposes an <tt>is_enabled(level)</tt>, so you can ask if a certain level is enabled (Example 2, above)
@@ -131,7 +131,7 @@
}
};
-typedef logger< gather::ostream_like::return_str<>, write_to_cout> logger_type;
+typedef logger< gather::ostream_like::return_str<std::string>, write_to_cout> logger_type;
BOOST_DECLARE_LOG(g_single_log, logger_type)
BOOST_DECLARE_LOG_FILTER(g_filter, filter::no_ts)
Modified: sandbox/logging/boost/logging/format.hpp
==============================================================================
--- sandbox/logging/boost/logging/format.hpp (original)
+++ sandbox/logging/boost/logging/format.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -260,17 +260,20 @@
@param destination_base The base class for all destination classes from your application. See manipulator.
-_at_param lock_resource What class you use to do allow thread-safe access to an instance of this clas (used internally).
+@param lock_resource_type What class you use to do allow thread-safe access to an instance of this clas (used internally).
*/
template<
class formatter_base,
class destination_base,
- class lock_resource = typename boost::logging::types<override>::lock_resource >
+ class lock_resource = default_ >
struct simple {
typedef typename formatter_base::ptr_type formatter_ptr;
typedef typename destination_base::ptr_type destination_ptr;
+ typedef typename detail::to_override<formatter_base>::type override_;
+ typedef typename use_default<lock_resource, typename boost::logging::types<override_>::lock_resource > ::type lock_resource_type;
+
typedef std::vector<formatter_ptr> f_array;
typedef std::vector<destination_ptr> d_array;
struct write_info {
@@ -278,7 +281,7 @@
d_array destinations;
};
- typedef typename lock_resource::template finder<write_info>::type data;
+ typedef typename lock_resource_type::template finder<write_info>::type data;
template<class formatter_array, class destination_array> simple(const formatter_array&, const destination_array&) {}
@@ -355,8 +358,8 @@
template<
class formatter_base,
class destination_base,
+ class lock_resource = default_ ,
// note: we're counting on these defaults in format_find_writer
- class lock_resource = typename boost::logging::types<override>::lock_resource ,
class formatter_array = boost::logging::array::shared_ptr_holder<formatter_base>,
class destination_array = boost::logging::array::shared_ptr_holder<destination_base>
>
@@ -364,9 +367,12 @@
typedef typename formatter_base::ptr_type formatter_ptr;
typedef typename destination_base::ptr_type destination_ptr;
+ typedef typename detail::to_override<formatter_base>::type override_;
+ typedef typename use_default<lock_resource, typename boost::logging::types<override_>::lock_resource > ::type lock_resource_type;
+
typedef formatter_and_destination_array_holder<formatter_array, destination_array> holder_base_type;
- typedef with_route<formatter_base, destination_base, lock_resource, formatter_array, destination_array> self_type;
+ typedef with_route<formatter_base, destination_base, lock_resource_type, formatter_array, destination_array> self_type;
typedef std::vector<formatter_ptr> f_array;
typedef std::vector<destination_ptr> d_array;
@@ -379,7 +385,7 @@
bool do_clear_afterwards;
};
typedef std::vector<write_once> write_array;
- typedef typename lock_resource::template finder<write_array>::type data;
+ typedef typename lock_resource_type::template finder<write_array>::type data;
public:
with_route(const formatter_array& formatters, const destination_array & destinations) : holder_base_type(formatters, destinations) {}
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 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -46,6 +46,22 @@
/**
+ @brief Writes the string to cerr
+*/
+template<class convert_dest = do_convert_destination > struct cerr_t : is_generic, boost::logging::op_equal::always_equal {
+
+ template<class msg_type> void operator()(const msg_type & msg) const {
+#ifndef BOOST_LOG_USE_WCHAR_T
+ convert_dest::write(msg, std::cerr);
+#else
+ convert_dest::write(msg, std::wcerr);
+#endif
+ }
+};
+
+
+
+/**
@brief writes to stream.
The stream must outlive this object! Or, clear() the stream, before the stream is deleted.
@@ -110,6 +126,12 @@
*/
typedef cout_t<> cout;
+/** @brief cerr_t with default values. See cerr_t
+
+@copydoc cerr_t
+*/
+typedef cerr_t<> cerr;
+
/** @brief stream_t with default values. See stream_t
@copydoc stream_t
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 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -40,7 +40,7 @@
@brief settings for when constructing a file class. To see how it's used, see @ref dealing_with_flags.
*/
struct file_settings {
- typedef detail::flag<file_settings> flag;
+ typedef ::boost::logging::detail::flag<file_settings> flag;
file_settings()
: flush_each_time(this, true)
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 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -41,7 +41,7 @@
@brief Settings you can pass to the rolling file. To see how it's used, see @ref dealing_with_flags.
*/
struct rolling_file_settings {
- typedef boost::logging::detail::flag<rolling_file_settings> flag;
+ typedef ::boost::logging::detail::flag<rolling_file_settings> flag;
rolling_file_settings()
: max_size_bytes(this, 1024 * 1024)
Copied: sandbox/logging/boost/logging/format/named_write.hpp (from r42940, /sandbox/logging/boost/logging/format/named_writer.hpp)
==============================================================================
--- /sandbox/logging/boost/logging/format/named_writer.hpp (original)
+++ sandbox/logging/boost/logging/format/named_write.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -1,4 +1,4 @@
-// named_writer.hpp
+// named_write.hpp
// Boost Logging library
//
@@ -21,7 +21,7 @@
# pragma once
#endif
-#include <boost/logging/writer/named.hpp>
+#include <boost/logging/writer/named_write.hpp>
#endif
Added: sandbox/logging/boost/logging/format/named_write_fwd.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/format/named_write_fwd.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -0,0 +1,35 @@
+// named_write_fwd.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_named_writer_fwd_HPP_DEFINED
+#define JT28092007_format_named_writer_fwd_HPP_DEFINED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/logging/format_fwd.hpp>
+
+#if !defined( BOOST_LOG_COMPILE_FAST)
+// slow compile
+#include <boost/logging/writer/named_write.hpp>
+#endif
+
+
+
+#endif
+
+
Deleted: sandbox/logging/boost/logging/format/named_writer.hpp
==============================================================================
--- sandbox/logging/boost/logging/format/named_writer.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
+++ (empty file)
@@ -1,29 +0,0 @@
-// named_writer.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_named_writer_HPP_DEFINED
-#define JT28092007_format_named_writer_HPP_DEFINED
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-#include <boost/logging/writer/named.hpp>
-
-
-#endif
-
-
Modified: sandbox/logging/boost/logging/format_fwd.hpp
==============================================================================
--- sandbox/logging/boost/logging/format_fwd.hpp (original)
+++ sandbox/logging/boost/logging/format_fwd.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -22,157 +22,13 @@
# pragma once
#endif
-#include <boost/logging/logging.hpp>
-#include <boost/logging/format/optimize.hpp>
-#include <boost/logging/gather/ostream_like.hpp>
+#include <boost/logging/detail/format_fwd_detail.hpp>
-namespace boost { namespace logging {
-
-namespace writer {
- template<class msg_type, class base_type> struct on_dedicated_thread ;
- template<class base_type> struct ts_write ;
-
- /**
- @brief specify thread-safety of your logger_format_write class
- */
- namespace threading {
- /** @brief not thread-safe */
- struct no_ts {};
- /** @brief thread-safe write. All writes are protected by a lock */
- struct ts_write {};
- /** @brief thread-safe write on a dedicated thread. Very efficient. Formatting & writing to destinations happens on the dedicated thread */
- struct on_dedicated_thread {};
- }
-}
-
-/**
-_at_file boost/logging/format_fwd.hpp
-
-Include this file when you're using @ref manipulator "formatters and destinations",
-and you want to declare the logger classes, in a header file
-(using BOOST_DECLARE_LOG)
-
-Example:
-
-_at_code
-#ifndef LOG_H_header
-#define LOG_H_header
-
-#include <boost/logging/logging.hpp>
-#include <boost/logging/format/optimize.hpp>
-
-BOOST_LOG_FORMAT_MSG( boost::logging::optimize::cache_string_one_str<> )
-
-#if defined(BOOST_LOG_DEFINE_LOGS)
+#if !defined( BOOST_LOG_COMPILE_FAST)
+// slow compile
#include <boost/logging/format.hpp>
-
-typedef logger_format_write< > logger_type;
#endif
-BOOST_DECLARE_LOG(g_l, logger_type)
-BOOST_DECLARE_LOG_FILTER(g_l_filter, level::holder)
-
-#define LDBG_ BOOST_LOG_USE_LOG_IF_LEVEL(g_l(), g_log_level(), debug ) << "[dbg] "
-#define LERR_ BOOST_LOG_USE_LOG_IF_LEVEL(g_l(), g_log_level(), error ) << "[ERR] "
-#define LAPP_ BOOST_LOG_USE_LOG_IF_LEVEL(g_l(), g_log_level(), info ) << "[app] "
-
-void init_logs();
-
-#endif
-_at_endcode
-*/
-template<
- class format_base_type = default_,
- class destination_base_type = default_ ,
- class thread_safety = default_ ,
- class gather = default_,
- class lock_resource = default_
- > struct logger_format_write;
-
-
-/**
- dumps the default levels
-
- Has a static function : dump, which dumps the level as string (works only for the default levels; for any other level, returns "")
-*/
-struct dump_default_levels {
- static const char_type * dump(::boost::logging::level::type lvl) {
- using namespace ::boost::logging::level;
- switch ( lvl) {
- case debug: return BOOST_LOG_STR("[debug] ");
- case info: return BOOST_LOG_STR("[info] ");
- case warning: return BOOST_LOG_STR("[warn] ");
- case error: return BOOST_LOG_STR("[ERROR] ");
- case fatal: return BOOST_LOG_STR("[FATAL] ");
- default: return BOOST_LOG_STR("");
- }
- }
-};
-
-/**
- Specifies the class that will dump the levels. Used by formatter::tag::level class.
-*/
-template<class T = override> struct dump_level {
- typedef dump_default_levels type;
-};
-
-
-namespace detail {
- // finds the gather type, when using formatting (for logger_format_write)
- template<class gather> struct format_find_gather {
- typedef typename detail::to_override<gather>::type override_;
-
- // FIXME in the future, I might provide gather as a specific class!
- typedef typename formatter::msg_type<override_>::type msg_type;
- typedef typename ::boost::logging::gather::find<override_>::template from_msg_type<msg_type>::type type;
- };
-}
-
-
-// specialize for logger_format_write
-template<class format_base, class destination_base, class thread_safety, class gather, class lock_resource>
- struct logger_to_gather< logger_format_write<format_base, destination_base, thread_safety, gather, lock_resource> > {
-
- typedef typename detail::format_find_gather<gather>::type gather_type;
-};
-
-namespace writer {
- template<class format_write_ = default_ > struct named ;
-}
-
-/** @brief named_logger<...>::type finds a logger that uses @ref writer::named<> "Named Formatters and Destinations"
-
-_at_code
-#include <boost/logging/format/named_writer.hpp>
-_at_endcode
-
-Example:
-_at_code
-typedef boost::logging::named_logger<>::type logger_type;
-_at_endcode
-
-Setting the formatters and destinations to write to is extremely simple:
-
-_at_code
-// first param - the formatter(s) , second param : the destination(s)
-g_l()->writer().write("%time%($hh:$mm.$ss.$mili) [%idx%] |\n", "cout file(out.txt) debug");
-_at_endcode
-
-To see the syntax, see writer::named
-
-*/
-template<class gather = default_> struct named_logger {
- typedef typename detail::format_find_gather<gather>::type gather_type;
-
- /** @copydoc named_logger */
- typedef logger< gather_type, writer::named<> > type;
-};
-
-}}
-
-
-#include <boost/logging/detail/scenario.hpp>
-#include <boost/logging/detail/tags.hpp>
#endif
Deleted: sandbox/logging/boost/logging/writer/named.hpp
==============================================================================
--- sandbox/logging/boost/logging/writer/named.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
+++ (empty file)
@@ -1,366 +0,0 @@
-// named_writer.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_named_writer_HPP_DEFINED
-#define JT28092007_named_writer_HPP_DEFINED
-
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-#include <boost/logging/format_ts.hpp>
-
-// all destinations
-#include <boost/logging/format/destination/file.hpp>
-#include <boost/logging/format/destination/named.hpp>
-#include <boost/logging/format/destination/rolling_file.hpp>
-
-// all formats
-#include <boost/logging/format/formatter/named_spacer.hpp>
-#include <boost/logging/format/formatter/thread_id.hpp>
-
-#ifndef __GNUC__
-// Boost 1.33.1 - GCC has error compiling microsec_clock
-#include <boost/logging/format/formatter/high_precision_time.hpp>
-namespace boost { namespace logging { namespace detail {
- typedef formatter::high_precision_time formatter_time_type ;
- typedef formatter::high_precision_time_t<formatter::do_convert_format::append> formatter_time_type_append ;
-}}}
-#else
-#include <boost/logging/format/formatter/time.hpp>
-namespace boost { namespace logging { namespace detail {
- typedef formatter::time formatter_time_type ;
- typedef formatter::time_t<formatter::do_convert_format::append> formatter_time_type_append ;
-}}}
-#endif
-
-
-namespace boost { namespace logging { namespace writer {
-
-/**
-_at_brief Composed of a named formatter and a named destinations. Thus, you can specify the formatting and destinations as strings
-
-_at_code
-#include <boost/logging/format/named_writer.hpp>
-_at_endcode
-
-
-Contains a very easy interface for using formatters and destinations:
-- at construction, specify 2 params: the formatter string and the destinations string
-
-Setting the formatters and destinations to write to is extremely simple:
-
-_at_code
-// first param - the formatter(s) , second param : the destination(s)
-g_l()->writer().write("%time%($hh:$mm.$ss.$mili) [%idx%] |\n", "cout file(out.txt) debug");
-
-// set the formatter(s)
-g_l()->writer().format("%time%($hh:$mm.$ss.$mili) [%idx%] |\n");
-
-g_l()->writer().destination("cout file(out.txt) debug");
-_at_endcode
-
-
-_at_section format_string_syntax The syntax of the format string
-
-- The format string specifies how the message is to be logged
-- Every formatter is escaped using %<em>fmt</em>%
- - Available formatters:
- - <tt>"%idx%"</tt> - writes the index of the message (formatter::idx)
- - <tt>"%time%"</tt> - writes the time (formatter::high_precision_time)
- - <tt>"%thread_id%"</tt> - writes the thread id (formatter::thread_id)
- - if you want to write "%", double it, like this: "%%"
-- "|" is used to specify the original message. What is before it, is prepended to the message, what is after, is appended to the message
-- If a formatter is configurable, append "(params)" to it
- - For now, only "%time%" is configurable. For instance, "%time%($hh:$mm.$ss.$mili)" writes time like "21:14.24.674"
-
-Example:
-_at_code
-"%time%($hh:$mm.$ss.$mili) [%idx%] |\n"
-_at_endcode
-
-The output can look like:
-
-_at_code
-21:03.17.243 [1] this is so cool
-21:03.17.243 [2] first error
-21:03.17.243 [3] hello, world
-_at_endcode
-
-
-_at_section dest_string_syntax The syntax of the destinations string
-
-- The syntax of the destination string specifies where the message is to be logged
- - Every destination is specified by name
- - Separate destinations by space (' ')
-- Available destinations
- - <tt>"cout"</tt> - writes to std::cout (destination::cout)
- - <tt>"debug"</tt> - writes to the debug window: OutputDebugString in Windows, console on Linux (destination::dbg_window)
- - <tt>"file"</tt> - writes to a file (destination::file)
- - <tt>"file2"</tt> - writes to a second file (destination::file)
- - <tt>"rol_file"</tt> - writes to a rolling file (destination::rolling_file)
- - <tt>"rol_file2"</tt> - writes to a second rolling file (destination::rolling_file)
-- If a destination is configurable, append "(params)" to it
- - Right now, "file", "file2", "rol_file" and "rol_file2" are configurable
- - Append "(filename)" to them to specify the file name. Example: "file(out.txt)" will write to the out.txt file
-
-Examples:
-- "file(out.txt) cout" - will write to a file called out.txt and to cout
-- "cout debug" - will write to cout and debug window (see above)
-- "cout file(out.txt) file2(dbg.txt)" - will write to cout, and to 2 files - out.txt and dbg.txt
-- "cout rol_file(r.txt)" - will write to cout and to a @ref destination::rolling_file "rolling_file" called r.txt
-
-_at_note
-If you want to output to 2 files, don't use "file(one.txt) file(two.txt)". This will just configure "file" twice, ending up with writing only to "two.txt" file.
-Use "file(one.txt) file2(two.txt)" instead!
-
-
-
-_at_param format_write_ the underlying format writer
-
-
-*/
-template<class format_write_ /* = default_ */ > struct named {
- typedef typename use_default< format_write_, format_write< formatter::base<> , destination::base<> > >::type format_write_type;
-
- typedef typename format_write_type::formatter_base_type formatter_base_type;
- typedef typename format_write_type::destination_base_type destination_base_type;
- typedef typename format_write_type::lock_resource_type lock_resource_type;
-
- typedef hold_string_type string_type;
-
- named() {
- m_writer.add_formatter( m_format_before);
- m_writer.add_formatter( m_format_after);
- m_writer.add_destination( m_destination);
-
- init();
- }
-
- /** @brief sets the format string: what should be before, and what after the original message, separated by "|"
-
- Example: \n
- "[%idx%] |\n" - this writes "[%idx%] " before the message, and "\n" after the message
-
- If "|" is not present, the whole message is prepended to the message
- */
- void format(const string_type & format_str) {
- m_format_str = format_str;
-
- typename string_type::size_type idx = format_str.find('|');
- string_type before, after;
- if ( idx != string_type::npos) {
- before = format_str.substr(0, idx);
- after = format_str.substr(idx + 1);
- }
- else
- before = format_str;
-
- format( before, after);
- };
-
- /** @brief sets the format strings (what should be before, and what after the original message)
- */
- void format(const string_type & format_before_str, const string_type & format_after_str) {
- m_format_before_str = format_before_str;
- m_format_after_str = format_after_str;
-
- set_and_configure( m_format_before, format_before_str, parse_formatter() );
- set_and_configure( m_format_after, format_after_str, parse_formatter() );
- };
-
- /** @brief sets the destinations string - where should logged messages be outputted
- */
- void destination(const string_type & destination_str) {
- m_destination_str = destination_str;
- set_and_configure( m_destination, destination_str, parse_destination() );
- }
-
- /** @brief Specifies the formats and destinations in one step
- */
- void write(const string_type & format_str, const string_type & destination_str) {
- format( format_str);
- destination( destination_str);
- }
-
- const string_type & format() const { return m_format_str; }
- const string_type & destination() const { return m_destination_str; }
-
- template<class msg_type> void operator()(msg_type & msg) const {
- m_writer(msg);
- }
-
- /** @brief Replaces a destination from the named destination.
-
- You can use this, for instance, when you want to share a destination between multiple named writers.
- */
- template<class destination> void replace_destination(const string_type & name, destination d) {
- m_destination.del(name);
- m_destination.add(name, d);
- }
-
- /** @brief Replaces a formatter from the named formatter.
-
- You can use this, for instance, when you want to share a formatter between multiple named writers.
- */
- template<class formatter> void replace_formatter(const string_type & name, formatter d) {
- if ( m_format_before_str.find(name) != string_type::npos) {
- m_format_before.del(name);
- m_format_before.add(name, d);
- }
-
- if ( m_format_after_str.find(name) != string_type::npos) {
- m_format_after.del(name);
- m_format_after.add(name, d);
- }
- }
-
-private:
- struct parse_destination {
- bool has_manipulator_name() const { return !m_manipulator.empty(); }
- string_type get_manipulator_name() const {
- BOOST_ASSERT( has_manipulator_name() );
- if ( m_manipulator[0] == '-' || m_manipulator[0] == '+')
- // + or - -> turning on or off a destination
- return m_manipulator.substr(1);
- else
- return m_manipulator;
- }
- void clear() { m_manipulator.clear(); }
-
- void add(char_type c) {
- // destination always follows ' '
- if ( c == ' ')
- clear();
- else
- m_manipulator += c;
- }
- private:
- string_type m_manipulator;
- };
-
- struct parse_formatter {
- // formatter starts and ends with %
- bool has_manipulator_name() const {
- if ( m_manipulator.empty() )
- return false;
- if ( m_manipulator.size() > 1)
- if ( m_manipulator[0] == '%' && (*m_manipulator.rbegin() == '%') )
- return true;
-
- return false;
- }
-
- string_type get_manipulator_name() const {
- BOOST_ASSERT( has_manipulator_name() );
- // ignore starting and ending %
- return m_manipulator.substr( 1, m_manipulator.size() - 2);
- }
- void clear() { m_manipulator.clear(); }
-
- void add(char_type c) {
- if ( has_manipulator_name() )
- // was a manipulator until now
- clear();
-
- if ( c == '%') {
- m_manipulator += c;
- if ( !has_manipulator_name() )
- // it could be the start of a formatter
- m_manipulator = '%';
- }
- else if ( m_manipulator.empty())
- ; // ignore this char - not from a manipulator
- else if ( m_manipulator[0] == '%')
- m_manipulator += c;
- else
- // manipulator should always start with %
- BOOST_ASSERT(false);
- }
- private:
- string_type m_manipulator;
- };
-
-
- template<class manipulator, class parser_type> void set_and_configure(manipulator & manip, const string_type & name, parser_type parser) {
- // need to parse string
- string_type prev ;
- bool parsing_params = false;
- string_type params;
- string_type stripped_str;
- for ( typename string_type::const_iterator b = name.begin(), e = name.end(); b != e; ++b) {
- if ( (*b == '(') && !parsing_params) {
- if ( parser.has_manipulator_name() ) {
- parsing_params = true;
- params.clear();
- }
- }
- else if ( (*b == ')') && parsing_params) {
- BOOST_ASSERT ( parser.has_manipulator_name() );
- manip.configure_inner( parser.get_manipulator_name(), params);
- parser.clear();
- parsing_params = false;
- }
- else {
- if ( parsing_params)
- params += *b;
- else {
- stripped_str += *b;
- parser.add( *b);
- }
- }
- }
- manip.string( stripped_str);
- }
-
-private:
- void init() {
- m_format_before
- .add( BOOST_LOG_STR("idx"), formatter::idx() )
- .add( BOOST_LOG_STR("time"), ::boost::logging::detail::formatter_time_type( BOOST_LOG_STR("$hh:$mm:$ss") ) )
- .add( BOOST_LOG_STR("thread_id"), formatter::thread_id() );
-
- m_format_after
- .add( BOOST_LOG_STR("idx"), formatter::idx_t<formatter::do_convert_format::append>() )
- .add( BOOST_LOG_STR("time"), ::boost::logging::detail::formatter_time_type_append( BOOST_LOG_STR("$hh:$mm:$ss") ) )
- .add( BOOST_LOG_STR("thread_id"), formatter::thread_id_t<formatter::do_convert_format::append>() );
-
- m_destination
- .add( BOOST_LOG_STR("file"), destination::file("out.txt") )
- .add( BOOST_LOG_STR("file2"), destination::file("out.txt") )
- .add( BOOST_LOG_STR("rol_file"), destination::rolling_file("out.txt") )
- .add( BOOST_LOG_STR("rol_file2"), destination::rolling_file("out.txt") )
- .add( BOOST_LOG_STR("cout"), destination::cout() )
- .add( BOOST_LOG_STR("debug"), destination::dbg_window() );
- }
-
-private:
- formatter::named_spacer_t< formatter::do_convert_format::prepend, formatter_base_type, lock_resource_type > m_format_before;
- formatter::named_spacer_t< formatter::do_convert_format::append, formatter_base_type, lock_resource_type > m_format_after;
- destination::named_t< destination_base_type, lock_resource_type > m_destination;
- format_write_type m_writer;
-
- string_type m_format_str;
- string_type m_format_before_str, m_format_after_str;
- string_type m_destination_str;
-};
-
-}}}
-
-
-#endif
-
-
Copied: sandbox/logging/boost/logging/writer/named_write.hpp (from r42949, /sandbox/logging/boost/logging/writer/named.hpp)
==============================================================================
--- /sandbox/logging/boost/logging/writer/named.hpp (original)
+++ sandbox/logging/boost/logging/writer/named_write.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -1,4 +1,4 @@
-// named_writer.hpp
+// named_write.hpp
// Boost Logging library
//
@@ -54,22 +54,23 @@
@brief Composed of a named formatter and a named destinations. Thus, you can specify the formatting and destinations as strings
@code
-#include <boost/logging/format/named_writer.hpp>
+#include <boost/logging/format/named_write.hpp>
@endcode
-Contains a very easy interface for using formatters and destinations:
-- at construction, specify 2 params: the formatter string and the destinations string
+Contains a very easy interface for using @ref manipulator "formatters and destinations":
+- at construction, specify 2 params: the %formatter string and the destinations string
-Setting the formatters and destinations to write to is extremely simple:
+Setting the @ref manipulator "formatters and destinations" to write to is extremely simple:
@code
-// first param - the formatter(s) , second param : the destination(s)
+// Set the formatters (first param) and destinatins (second step) in one step
g_l()->writer().write("%time%($hh:$mm.$ss.$mili) [%idx%] |\n", "cout file(out.txt) debug");
// set the formatter(s)
g_l()->writer().format("%time%($hh:$mm.$ss.$mili) [%idx%] |\n");
+// set the destination(s)
g_l()->writer().destination("cout file(out.txt) debug");
@endcode
@@ -77,15 +78,15 @@
@section format_string_syntax The syntax of the format string
- The format string specifies how the message is to be logged
-- Every formatter is escaped using %<em>fmt</em>%
+- Every formatter is escaped using <tt>%</tt><em>fmt</em><tt>%</tt>
- Available formatters:
- <tt>"%idx%"</tt> - writes the index of the message (formatter::idx)
- <tt>"%time%"</tt> - writes the time (formatter::high_precision_time)
- <tt>"%thread_id%"</tt> - writes the thread id (formatter::thread_id)
- - if you want to write "%", double it, like this: "%%"
-- "|" is used to specify the original message. What is before it, is prepended to the message, what is after, is appended to the message
-- If a formatter is configurable, append "(params)" to it
- - For now, only "%time%" is configurable. For instance, "%time%($hh:$mm.$ss.$mili)" writes time like "21:14.24.674"
+ - if you want to write @c "%", double it, like this: @c "%%"
+- @c "|" is used to specify the original message. What is before it, is prepended to the message, what is after, is appended to the message
+- If a formatter is configurable, append @em (params) to it
+ - For now, only @c "%time%" is configurable. For instance, @c "%time%($hh:$mm.$ss.$mili)" writes time like @c "21:14.24.674"
Example:
@code
@@ -108,32 +109,34 @@
- Separate destinations by space (' ')
- Available destinations
- <tt>"cout"</tt> - writes to std::cout (destination::cout)
+ - <tt>"cerr"</tt> - writes to std::cerr (destination::cerr)
- <tt>"debug"</tt> - writes to the debug window: OutputDebugString in Windows, console on Linux (destination::dbg_window)
- <tt>"file"</tt> - writes to a file (destination::file)
- <tt>"file2"</tt> - writes to a second file (destination::file)
- <tt>"rol_file"</tt> - writes to a rolling file (destination::rolling_file)
- <tt>"rol_file2"</tt> - writes to a second rolling file (destination::rolling_file)
-- If a destination is configurable, append "(params)" to it
- - Right now, "file", "file2", "rol_file" and "rol_file2" are configurable
- - Append "(filename)" to them to specify the file name. Example: "file(out.txt)" will write to the out.txt file
+- If a destination is configurable, append @em (params) to it
+ - Right now, @c "file", @c "file2", @c "rol_file" and @c "rol_file2" are configurable
+ - Append <tt>(</tt><em>filename</em><tt>)</tt> to them to specify the file name. Example: @c "file(out.txt)" will write to the out.txt file
Examples:
-- "file(out.txt) cout" - will write to a file called out.txt and to cout
-- "cout debug" - will write to cout and debug window (see above)
-- "cout file(out.txt) file2(dbg.txt)" - will write to cout, and to 2 files - out.txt and dbg.txt
-- "cout rol_file(r.txt)" - will write to cout and to a @ref destination::rolling_file "rolling_file" called r.txt
+- <tt>"file(out.txt) cout"</tt> - will write to a file called out.txt and to cout
+- <tt>"cout debug"</tt> - will write to cout and debug window (see above)
+- <tt>"cout file(out.txt) file2(dbg.txt)"</tt> - will write to cout, and to 2 files - out.txt and dbg.txt
+- <tt>"cout rol_file(r.txt)"</tt> - will write to cout and to a @ref destination::rolling_file "rolling_file" called r.txt
@note
If you want to output to 2 files, don't use "file(one.txt) file(two.txt)". This will just configure "file" twice, ending up with writing only to "two.txt" file.
Use "file(one.txt) file2(two.txt)" instead!
-
+@note
+At this time, named_write does not support tags. However, it's a high priority on my TODO list, so it'll be here soon!
@param format_write_ the underlying format writer
*/
-template<class format_write_ /* = default_ */ > struct named {
+template<class format_write_ /* = default_ */ > struct named_write {
typedef typename use_default< format_write_, format_write< formatter::base<> , destination::base<> > >::type format_write_type;
typedef typename format_write_type::formatter_base_type formatter_base_type;
@@ -142,7 +145,7 @@
typedef hold_string_type string_type;
- named() {
+ named_write() {
m_writer.add_formatter( m_format_before);
m_writer.add_formatter( m_format_after);
m_writer.add_destination( m_destination);
@@ -344,6 +347,7 @@
.add( BOOST_LOG_STR("rol_file"), destination::rolling_file("out.txt") )
.add( BOOST_LOG_STR("rol_file2"), destination::rolling_file("out.txt") )
.add( BOOST_LOG_STR("cout"), destination::cout() )
+ .add( BOOST_LOG_STR("cerr"), destination::cerr() )
.add( BOOST_LOG_STR("debug"), destination::dbg_window() );
}
Modified: sandbox/logging/boost/logging/writer/on_dedicated_thread.hpp
==============================================================================
--- sandbox/logging/boost/logging/writer/on_dedicated_thread.hpp (original)
+++ sandbox/logging/boost/logging/writer/on_dedicated_thread.hpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -137,7 +137,6 @@
write_array();
}
-// void operator()(const msg_type & msg) const {
void operator()(msg_type & msg) const {
typedef typename context_type::ptr ptr;
typedef typename context_type::thread_ptr thread_ptr;
Modified: sandbox/logging/lib/logging/internal/vc8/loggingvc8/loggingvc8.vcproj
==============================================================================
--- sandbox/logging/lib/logging/internal/vc8/loggingvc8/loggingvc8.vcproj (original)
+++ sandbox/logging/lib/logging/internal/vc8/loggingvc8/loggingvc8.vcproj 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -170,7 +170,7 @@
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
- CharacterSet="1"
+ CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
@@ -328,13 +328,6 @@
<File
RelativePath=".\test_now.cpp"
>
- <FileConfiguration
- Name="Test|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
</File>
</Filter>
<Filter
@@ -540,6 +533,10 @@
>
</File>
<File
+ RelativePath="..\..\..\..\..\boost\logging\detail\format_fwd_detail.hpp"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\..\boost\logging\detail\format_msg_type.hpp"
>
</File>
@@ -556,7 +553,11 @@
>
</File>
<File
- RelativePath="..\..\..\..\..\boost\logging\format\named_writer.hpp"
+ RelativePath="..\..\..\..\..\boost\logging\format\named_write.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\boost\logging\format\named_write_fwd.hpp"
>
</File>
<File
@@ -648,7 +649,7 @@
>
</File>
<File
- RelativePath="..\..\..\..\..\boost\logging\writer\named.hpp"
+ RelativePath="..\..\..\..\..\boost\logging\writer\named_write.hpp"
>
</File>
<File
Modified: sandbox/logging/lib/logging/internal/vc8/loggingvc8/test_now.cpp
==============================================================================
--- sandbox/logging/lib/logging/internal/vc8/loggingvc8/test_now.cpp (original)
+++ sandbox/logging/lib/logging/internal/vc8/loggingvc8/test_now.cpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -1,21 +1,71 @@
+#define BOOST_LOG_COMPILE_FAST_OFF
+#include <boost/logging/format/named_write_fwd.hpp>
-#include <boost/logging/format_fwd.hpp>
-#include <boost/logging/format/named_writer.hpp>
-typedef boost::logging::named_logger<>::type logger_type;
+BOOST_LOG_FORMAT_MSG( optimize::cache_string_one_str<> )
+using namespace boost::logging;
+
+typedef logger_format_write< default_, default_, writer::threading::no_ts > logger_type;
+
+
+BOOST_DECLARE_LOG_FILTER(g_log_filter, filter::no_ts )
+BOOST_DECLARE_LOG(g_l, logger_type)
#define L_ BOOST_LOG_USE_LOG_IF_FILTER(g_l(), g_log_filter()->is_enabled() )
-// Define the filters and loggers you'll use (usually in a source file)
-BOOST_DEFINE_LOG_FILTER(g_log_filter, boost::logging::filter::no_ts )
BOOST_DEFINE_LOG(g_l, logger_type)
+BOOST_DEFINE_LOG_FILTER(g_log_filter, filter::no_ts )
+
+
+
+// Example of custom formatter:
+// dump the no. of seconds since start of program
+struct secs_since_start : formatter::class_<secs_since_start, formatter::implement_op_equal::no_context > {
+ ::time_t m_start;
+ secs_since_start() : m_start( ::time(0) ) {}
+ void operator()(param str) const {
+ ::time_t now = ::time(0);
+ std::stringstream out;
+ out << "+" << (int)(now-m_start) << "s ";
+ str.prepend_string( out.str() );
+ }
+};
+
+// Example of custom destination:
+// Dump each message as XML
+struct as_xml :
+ destination::class_<as_xml, destination::implement_op_equal::has_context>,
+ destination::non_const_context<std::ofstream> {
+
+ std::string m_name;
+ as_xml(const char* name) : non_const_context_base(name), m_name(name) {}
+ void operator()(param str) const {
+ context() << "<msg>" << str << "</msg>" << std::endl;
+ }
+ bool operator==(const as_xml& other) const { return m_name == other.m_name; }
+};
-void one_logger_one_filter_example() {
- // formatting : [idx] message \n
- // destinations : console, file "out.txt" and debug window
- g_l()->writer().write("[%idx%] |\n", "cout file(out.txt) debug");
+#if 0
+int main() {
+ secs_since_start s;
+ secs_since_start::raw_param a;
+ std::cout << a;
+}
+#endif
+
+#if 1
+void custom_fmt_dest_example() {
+ // 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_newline() );
+ g_l()->writer().add_formatter( secs_since_start() );
+
+ g_l()->writer().add_destination( destination::cout() );
+ g_l()->writer().add_destination( destination::dbg_window() );
+ g_l()->writer().add_destination( as_xml("out.txt") );
g_l()->mark_as_initialized();
int i = 1;
@@ -35,11 +85,9 @@
-
int main() {
- one_logger_one_filter_example();
+ custom_fmt_dest_example();
}
-
+#endif
// End of file
-
Modified: sandbox/logging/lib/logging/samples/basic_usage/main.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/basic_usage/main.cpp (original)
+++ sandbox/logging/lib/logging/samples/basic_usage/main.cpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -13,7 +13,7 @@
@section scenario_multiple_files_program What the program does
This represents a small program to count lines of code from a directory and its subdirs.
-It's a simple application, just to show you how to use the Boost Log library v2 in your own projects.
+It's a simple application, just to show you how to use the Boost Logging Lib v2 in your own projects.
It counts code lines, empty lines, and comment lines.
Again, it's a very simple program, thus:
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 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -59,24 +59,19 @@
#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_format_write< default_, default_, writer::threading::no_ts > logger_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, logger_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() )
-// Step 6: Define the filters and loggers you'll use (usually in a source file)
BOOST_DEFINE_LOG(g_l, logger_type)
BOOST_DEFINE_LOG_FILTER(g_log_filter, filter::no_ts )
@@ -112,9 +107,8 @@
void custom_fmt_dest_example() {
- // Step 7: add formatters and destinations
+ // 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_newline() );
g_l()->writer().add_formatter( secs_since_start() );
@@ -124,7 +118,6 @@
g_l()->writer().add_destination( as_xml("out.txt") );
g_l()->mark_as_initialized();
- // Step 8: use it...
int i = 1;
L_ << "this is so cool " << i++;
L_ << "this is so cool again " << i++;
@@ -138,8 +131,6 @@
g_log_filter()->set_enabled(true);
L_ << "good to be back ;) " << i++;
-
- // Step 9 : Enjoy!
}
Modified: sandbox/logging/lib/logging/samples/scenarios/ded_loger_one_filter.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/ded_loger_one_filter.cpp (original)
+++ sandbox/logging/lib/logging/samples/scenarios/ded_loger_one_filter.cpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -55,7 +55,6 @@
#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_ts.hpp>
@@ -65,19 +64,13 @@
using namespace boost::logging;
-// Step 3 : Specify your logging class(es)
-// In our case, we're also writing on a dedidcated thread
typedef logger_format_write< default_, default_, writer::threading::on_dedicated_thread > logger_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, logger_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() )
-// 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, logger_type)
@@ -95,19 +88,13 @@
}
void use_log_thread() {
- // Step 8: use it...
for ( int i = 0; i < 20; ++i) {
L_ << "message " << i ;
do_sleep(1);
}
-
- // Step 9 : Enjoy!
}
void ts_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::time("$mm:$ss ") );
g_l()->writer().add_formatter( formatter::append_newline() );
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 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -49,20 +49,15 @@
void *out(const std::string& msg) { m_msg = msg.c_str(); return this; }
};
-// Step 1 : Specify your logging class(es)
+
typedef logger< no_gather, destination::cout > app_log_type;
typedef logger< no_gather, destination::file > err_log_type;
-// Step 2 : Set up a filter
BOOST_DEFINE_LOG_FILTER(g_log_filter, filter::no_ts )
-// Step 3: declare which loggers you'll use
BOOST_DEFINE_LOG(g_log_app, app_log_type)
BOOST_DEFINE_LOG_WITH_ARGS( g_log_err, err_log_type, ("err.txt") )
-// FIXME most likely I can use BOOST_LOG_USE_IF_FILTER
-
-// Step 4: define the macros through which you'll log
#define LAPP_ BOOST_LOG_USE_SIMPLE_LOG_IF_FILTER(g_log_app(), g_log_filter()->is_enabled() )
#define LERR_ BOOST_LOG_USE_SIMPLE_LOG_IF_FILTER(g_log_err(), g_log_filter()->is_enabled() )
@@ -70,7 +65,6 @@
g_log_app()->mark_as_initialized();
g_log_err()->mark_as_initialized();
- // Step 5: use it...
LAPP_("this is so cool\n");
LERR_("first error \n");
@@ -85,8 +79,6 @@
g_log_filter()->set_enabled(true);
LAPP_("good to be back ;) \n" );
LERR_("second error \n" );
-
- // Step 6 : Enjoy!
}
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 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -41,19 +41,14 @@
using namespace boost::logging;
-
-// Step 1 : Specify your logging class(es)
typedef logger< default_, destination::cout> app_log_type;
typedef logger< default_, destination::file> err_log_type;
-// Step 2 : Set up a filter
BOOST_DEFINE_LOG_FILTER(g_log_filter, filter::no_ts )
-// Step 3: declare which loggers you'll use
BOOST_DEFINE_LOG(g_log_app, app_log_type )
BOOST_DEFINE_LOG_WITH_ARGS( g_log_err, err_log_type, ("err.txt") )
-// Step 4: define the macros through which you'll log
#define LAPP_ BOOST_LOG_USE_LOG_IF_FILTER(g_log_app(), g_log_filter()->is_enabled() )
#define LERR_ BOOST_LOG_USE_LOG_IF_FILTER(g_log_err(), g_log_filter()->is_enabled() )
@@ -61,7 +56,6 @@
g_log_app()->mark_as_initialized();
g_log_err()->mark_as_initialized();
- // Step 5: use it...
int i = 1;
LAPP_ << "this is so cool " << i++ << "\n";
LAPP_ << "this is so cool again " << i++ << "\n";
@@ -78,8 +72,6 @@
g_log_filter()->set_enabled(true);
LAPP_ << "good to be back ;) " << i++ << "\n";
LERR_ << "second error " << i++ << "\n";
-
- // Step 6 : Enjoy!
}
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 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -59,15 +59,13 @@
-#include <boost/logging/format/named_writer.hpp>
+#include <boost/logging/format/named_write.hpp>
typedef boost::logging::named_logger<>::type logger_type;
-// Step 5: define the macros through which you'll log
#define LDBG_ BOOST_LOG_USE_LOG_IF_LEVEL(g_log_dbg(), g_log_level(), debug ) << "[dbg] "
#define LERR_ BOOST_LOG_USE_LOG_IF_LEVEL(g_log_err(), g_log_level(), error )
#define LAPP_ BOOST_LOG_USE_LOG_IF_LEVEL(g_log_app(), g_log_level(), info ) << "[app] "
-// Step 6: Define the filters and loggers you'll use (usually in a source file)
BOOST_DEFINE_LOG_FILTER(g_log_level, boost::logging::level::holder )
BOOST_DEFINE_LOG(g_log_err, logger_type)
BOOST_DEFINE_LOG(g_log_app, logger_type)
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 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -27,7 +27,7 @@
*/
-#include <boost/logging/format/named_writer.hpp>
+#include <boost/logging/format/named_write.hpp>
typedef boost::logging::named_logger<>::type logger_type;
#define L_(lvl) BOOST_LOG_USE_LOG_IF_LEVEL(g_l(), g_log_level(), lvl )
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 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -60,36 +60,28 @@
#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_format_write< > logger_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_log_err, logger_type)
BOOST_DECLARE_LOG(g_log_app, logger_type)
BOOST_DECLARE_LOG(g_log_dbg, logger_type)
-// Step 5: define the macros through which you'll log
#define LDBG_ BOOST_LOG_USE_LOG_IF_FILTER(g_log_dbg(), g_log_filter()->is_enabled() ) << "[dbg] "
#define LERR_ BOOST_LOG_USE_LOG_IF_FILTER(g_log_err(), g_log_filter()->is_enabled() )
#define LAPP_ BOOST_LOG_USE_LOG_IF_FILTER(g_log_app(), g_log_filter()->is_enabled() ) << "[app] "
-// 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_log_err, logger_type)
BOOST_DEFINE_LOG(g_log_app, logger_type)
BOOST_DEFINE_LOG(g_log_dbg, logger_type)
void mul_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
-
// Err log
g_log_err()->writer().add_formatter( formatter::idx(), "[%] " );
g_log_err()->writer().add_formatter( formatter::time("$hh:$mm.$ss ") );
@@ -112,7 +104,6 @@
g_log_err()->mark_as_initialized();
g_log_dbg()->mark_as_initialized();
- // Step 8: use it...
int i = 1;
LDBG_ << "this is so cool " << i++;
LDBG_ << "this is so cool again " << i++;
@@ -129,8 +120,6 @@
g_log_filter()->set_enabled(true);
LAPP_ << "good to be back ;) " << i++;
LERR_ << "second error " << i++;
-
- // Step 9 : Enjoy!
}
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 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -53,7 +53,6 @@
#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_several_str<> )
#include <boost/logging/format.hpp>
@@ -61,22 +60,18 @@
using namespace boost::logging;
-// Step 3 : Specify your logging class(es)
typedef logger_format_write< > logger_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, logger_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() )
-// 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, logger_type)
void no_levels_with_route_example() {
- // Step 7: add formatters and destinations
+ // 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 ") );
@@ -108,7 +103,6 @@
g_l()->mark_as_initialized();
- // Step 8: use it...
int i = 1;
L_ << "this is so cool " << i++;
@@ -121,8 +115,6 @@
g_log_filter()->set_enabled(true);
L_ << "good to be back ;) " << i++;
-
- // Step 9 : Enjoy!
}
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 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -33,7 +33,7 @@
#include <boost/logging/format_fwd.hpp>
-#include <boost/logging/format/named_writer.hpp>
+#include <boost/logging/format/named_write.hpp>
typedef boost::logging::named_logger<>::type logger_type;
#define L_ BOOST_LOG_USE_LOG_IF_FILTER(g_l(), g_log_filter()->is_enabled() )
Modified: sandbox/logging/lib/logging/samples/scenarios/ts_loger_one_filter.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/ts_loger_one_filter.cpp (original)
+++ sandbox/logging/lib/logging/samples/scenarios/ts_loger_one_filter.cpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -48,7 +48,6 @@
#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_ts.hpp>
@@ -58,18 +57,10 @@
using namespace boost::logging;
-// Step 3 : Specify your logging class(es)
typedef logger_format_write< default_, default_, writer::threading::ts_write > logger_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, logger_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() )
-// 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, logger_type)
@@ -87,19 +78,15 @@
}
void use_log_thread() {
- // Step 8: use it...
for ( int i = 0; i < 50; ++i) {
L_ << "message " << i ;
do_sleep(1);
}
-
- // Step 9 : Enjoy!
}
void ts_logger_one_filter_example() {
- // Step 7: add formatters and destinations
+ // add formatters and destinations
// That is, how the message is to be formatted and where should it be written to
-
g_l()->writer().add_formatter( formatter::idx(), "[%] " );
g_l()->writer().add_formatter( formatter::thread_id(), "[T%] " );
g_l()->writer().add_formatter( formatter::append_newline() );
Modified: sandbox/logging/lib/logging/samples/scenarios/use_tss_ostringstream.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/use_tss_ostringstream.cpp (original)
+++ sandbox/logging/lib/logging/samples/scenarios/use_tss_ostringstream.cpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -35,7 +35,6 @@
#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<> )
// FIXME need to set the gather class
@@ -44,24 +43,19 @@
using namespace boost::logging;
-// Step 3 : Specify your logging class(es)
typedef logger_format_write< > logger_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, logger_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() )
-// 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, logger_type)
void use_tss_ostringstream_example() {
- // Step 7: add formatters and destinations
+ // 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(), "[%] " );
@@ -70,13 +64,10 @@
g_l()->writer().add_destination( destination::dbg_window() );
g_l()->mark_as_initialized();
- // Step 8: use it...
int i = 1;
L_ << "this is so cool " << i++;
L_ << "this is so cool again " << i++;
L_ << "this is so too cool " << i++;
-
- // Step 9 : Enjoy!
}
Modified: sandbox/logging/lib/logging/samples/scenarios/using_tags.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/using_tags.cpp (original)
+++ sandbox/logging/lib/logging/samples/scenarios/using_tags.cpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -30,7 +30,6 @@
#include <boost/logging/format_fwd.hpp>
-// Step 1: Optimize : use tags (on top of a cache string, to make formatting the message faster)
namespace bl = boost::logging;
typedef bl::tag::holder< bl::optimize::cache_string_one_str<>, bl::tag::file_line, bl::tag::thread_id, bl::tag::time> log_string;
BOOST_LOG_FORMAT_MSG( log_string )
@@ -42,7 +41,6 @@
using namespace boost::logging;
-// Step 3 : Specify your logging class(es)
using namespace boost::logging::scenario::usage;
typedef use<
// the filter is always accurate (but slow)
@@ -54,20 +52,17 @@
// the logger favors speed (on a dedicated thread)
logger_::favor::speed> finder;
-// Step 4: declare which filters and loggers you'll use (usually in a header file)
BOOST_DECLARE_LOG_FILTER(g_log_filter, finder::filter )
BOOST_DECLARE_LOG(g_l, finder::logger)
-// 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() ) .set_tag( BOOST_LOG_TAG_FILELINE)
-// Step 6: Define the filters and loggers you'll use (usually in a source file)
BOOST_DEFINE_LOG_FILTER(g_log_filter, finder::filter )
BOOST_DEFINE_LOG(g_l, finder::logger)
void using_tags_example() {
- // Step 7: add formatters and destinations
+ // 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::named_spacer( "%fileline% [T%thread_id%] [%idx%] %time%" )
@@ -81,11 +76,9 @@
g_l()->writer().add_destination( destination::file("out.txt") );
g_l()->mark_as_initialized();
- // Step 8: use it...
int i = 1;
L_ << "this is so cool " << i++;
L_ << "this is so cool again " << i++;
- // Step 9 : Enjoy!
}
Modified: sandbox/logging/lib/logging/samples/scenarios/your_scenario.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/your_scenario.cpp (original)
+++ sandbox/logging/lib/logging/samples/scenarios/your_scenario.cpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -65,14 +65,12 @@
#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_ts.hpp>
#include <boost/thread/xtime.hpp>
using namespace boost::logging;
-// Step 3 : Specify your logging class(es)
using namespace boost::logging::scenario::usage;
typedef use<
// the filter is always accurate (but slow)
@@ -84,18 +82,15 @@
// the logger favors speed (on a dedicated thread)
logger_::favor::speed> finder;
-// Step 4: declare which filters and loggers you'll use (usually in a header file)
BOOST_DECLARE_LOG_FILTER(g_log_filter, finder::filter )
BOOST_DECLARE_LOG(g_log_err, finder::logger )
BOOST_DECLARE_LOG(g_log_app, finder::logger )
BOOST_DECLARE_LOG(g_log_dbg, finder::logger )
-// Step 5: define the macros through which you'll log
#define LDBG_ BOOST_LOG_USE_LOG_IF_FILTER(g_log_dbg(), g_log_filter()->is_enabled() )
#define LERR_ BOOST_LOG_USE_LOG_IF_FILTER(g_log_err(), g_log_filter()->is_enabled() )
#define LAPP_ BOOST_LOG_USE_LOG_IF_FILTER(g_log_app(), g_log_filter()->is_enabled() )
-// Step 6: Define the filters and loggers you'll use (usually in a source file)
BOOST_DEFINE_LOG_FILTER(g_log_filter, finder::filter )
BOOST_DEFINE_LOG(g_log_err, finder::logger )
BOOST_DEFINE_LOG(g_log_app, finder::logger )
@@ -115,7 +110,7 @@
}
void your_scenario_example() {
- // Step 7: add formatters and destinations
+ // add formatters and destinations
// That is, how the message is to be formatted and where should it be written to
// Err log
@@ -139,7 +134,6 @@
g_log_err()->mark_as_initialized();
g_log_dbg()->mark_as_initialized();
- // Step 8: use it...
int i = 1;
LDBG_ << "this is so cool " << i++;
LDBG_ << "this is so cool again " << i++;
@@ -157,8 +151,6 @@
LAPP_ << "good to be back ;) " << i++;
LERR_ << "second error " << i++;
- // Step 9 : Enjoy!
-
// just so that we can see the output to the console as well (the messages are written no a different thread)...
do_sleep(1000);
}
Modified: sandbox/logging/lib/logging/samples/starter/my_app_log.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/starter/my_app_log.cpp (original)
+++ sandbox/logging/lib/logging/samples/starter/my_app_log.cpp 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -1,15 +1,16 @@
// my_app_log.cpp
-#include "log.h"
+#include "my_app_log.h"
#include <boost/logging/format.hpp>
-#include <boost/logging/writer/ts_write.hpp>
#include <boost/logging/format/formatter/tags.hpp>
// uncomment if you want to use do logging on a dedicated thread
// #include <boost/logging/writer/on_dedicated_thread.hpp>
+// uncomment if you're using Named Formatters and Destinations
+// #include <boost/logging/format/named_write.hpp>
+
using namespace boost::logging;
-// Step 6: Define the filters and loggers you'll use
BOOST_DEFINE_LOG_FILTER(g_log_filter, finder::filter )
BOOST_DEFINE_LOG(g_l, finder::logger)
Modified: sandbox/logging/lib/logging/samples/starter/my_app_log.h
==============================================================================
--- sandbox/logging/lib/logging/samples/starter/my_app_log.h (original)
+++ sandbox/logging/lib/logging/samples/starter/my_app_log.h 2008-01-27 21:44:05 EST (Sun, 27 Jan 2008)
@@ -4,7 +4,9 @@
#include <boost/logging/format_fwd.hpp>
-// Step 1: Specify the class to hold the message
+// uncomment if you're using Named Formatters and Destinations
+//#include <boost/logging/format/named_write_fwd.hpp>
+
namespace bl = boost::logging;
typedef bl::tag::holder<
// string class
@@ -17,15 +19,11 @@
// if not compiling fast...
#ifndef BOOST_LOG_COMPILE_FAST
-#include <boost/logging/format.hpp>
-// If you use tags...
-#include <boost/logging/format/formatter/tags.hpp>
-// uncomment if you want to use do logging on a dedicated thread
+// uncomment if you want to do logging on a dedicated thread
// #include <boost/logging/writer/on_dedicated_thread.hpp>
#endif
-// Step 3 : Specify your logging class(es)
using namespace boost::logging::scenario::usage;
typedef use<
// how often do you manipulate (change) the filter?
@@ -37,11 +35,9 @@
// for the logger: do you favor speed or correctness?
logger_::favor::correctness> finder;
-// Step 4: declare which filters and loggers you'll use
BOOST_DECLARE_LOG_FILTER(g_l_filter, finder::filter)
BOOST_DECLARE_LOG(g_l, finder::logger)
-// 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() )
// initialize thy logs..
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