Boost logo

Boost-Commit :

From: john.groups_at_[hidden]
Date: 2007-11-16 14:25:15


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

Log:
[logging]
v0.11.18, 16 nov 2007
- removed old_examples
- removed do_not_use tests

Added:
   sandbox/logging/boost/logging/gather/
      - copied from r41100, /sandbox/logging/boost/logging/process_msg/
   sandbox/logging/boost/logging/gather/ostream_like.hpp
      - copied unchanged from r41154, /sandbox/logging/boost/logging/process_msg/ostream_like.hpp
   sandbox/logging/lib/logging/internal/vc8/loggingvc8/test_now.cpp (contents, props changed)
Removed:
   sandbox/logging/boost/logging/detail/raw_doc/old_examples.hpp
   sandbox/logging/boost/logging/process_msg/
   sandbox/logging/lib/logging/tests/do_not_use/
Text files modified:
   sandbox/logging/boost/logging/detail/level.hpp | 41 --------
   sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp | 5
   sandbox/logging/boost/logging/detail/raw_doc/fixme.hpp | 7 -
   sandbox/logging/boost/logging/detail/raw_doc/thread_safety.hpp | 32 ++++++
   sandbox/logging/boost/logging/detail/use_format_write.hpp | 2
   sandbox/logging/boost/logging/format.hpp | 24 ++--
   sandbox/logging/boost/logging/format_fwd.hpp | 2
   sandbox/logging/lib/logging/internal/vc8/loggingvc8/loggingvc8.vcproj | 194 ---------------------------------------
   8 files changed, 51 insertions(+), 256 deletions(-)

Modified: sandbox/logging/boost/logging/detail/level.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/level.hpp (original)
+++ sandbox/logging/boost/logging/detail/level.hpp 2007-11-16 14:25:14 EST (Fri, 16 Nov 2007)
@@ -164,47 +164,6 @@
     typedef boost::logging::level_holder_type holder;
 } // namespace level
 
-/**
- @brief It's a filter that enables holding a level
-
- Allows managing whether a level is enabled or not (so that a logggers that wants to use levels,
- can determine if it's enabled or not)
-
- Example:
-
-_at_code
-typedef process_msg< gather::ostream_like::return_str<>, write_to_file> processor;
-level::holder_no_ts level_holder;
-
-typedef logger<processor, filter_level<level::holder_no_ts, level::debug> > debug_logger;
-typedef logger<processor, filter_level<level::holder_no_ts, level::error> > error_logger;
-typedef logger<processor, filter_level<level::holder_no_ts, level::info> > info_logger;
-
-debug_logger g_log_dbg( init_both, "dbg.txt", &level_holder );
-error_logger g_log_err( init_both, "err.txt", &level_holder );
-info_logger g_log_app( init_both, "out.txt", &level_holder );
-#define LAPP_ if ( !g_log_app) ; else g_log_app->read_msg().gather().out()
-#define LERR_ if ( !g_log_err) ; else g_log_err->read_msg().gather().out()
-#define LDBG_ if ( !g_log_dbg) ; else g_log_dbg->read_msg().gather().out()
-
-
-// usage
-LAPP_ << "info at : " << idx << " : reading word " << word;
-LDBG_ << "debug at: " << idx << ", reading " << word;
-LERR_ << "error at: " << idx << ", while reading " << word;
-
-_at_endcode
-
- @sa level::holder_no_ts, level::holder_ts, level::holder_tss_with_cache
-*/
-template<class holder_type, int level> struct filter_level {
- filter_level(holder_type * level_holder) : m_level_holder(*level_holder) {}
- bool is_enabled() const {
- return m_level_holder.is_enabled(level);
- }
-private:
- holder_type & m_level_holder;
-};
 
 }}
 

Modified: sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp 2007-11-16 14:25:14 EST (Fri, 16 Nov 2007)
@@ -1,7 +1,10 @@
 /**
 @page page_changelog Changelog
 
-_at_section changelog_cur_ver Current Version: v0.11.16, 16 nov 2007
+@section changelog_cur_ver Current Version: v0.11.18, 16 nov 2007
+- removed old_examples
+- removed do_not_use tests
+- more changes in the documentation ; also "refactored" table of contents
 - finalized documentation about macros
 - solved bugs in append_newline_if_needed() when using tags
 - updated docs - added page showing how to declare/define your logger/filter classes

Modified: sandbox/logging/boost/logging/detail/raw_doc/fixme.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/fixme.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/fixme.hpp 2007-11-16 14:25:14 EST (Fri, 16 Nov 2007)
@@ -2,7 +2,7 @@
 
 
 
-FIXME change the workflow & logger's definition - it doesn't need a filter
+FIXME
 all gather classes - they need to typedef the param they take, so that I can create a virtual function.
 no more process_msg class -> remove from docs!
 gathering the message - gather class must hold "param" type!
@@ -24,11 +24,6 @@
 about non_const_context
 
 about formatting
-about thread-safety
-
-
-writer namespace , etc.
-compilers
 
 
 convert- also explain that you can convert from str x to y; for instance write_time can actually append the time (instead of prepending it - default)!

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

Modified: sandbox/logging/boost/logging/detail/raw_doc/thread_safety.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/thread_safety.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/thread_safety.hpp 2007-11-16 14:25:14 EST (Fri, 16 Nov 2007)
@@ -3,8 +3,38 @@
 /**
 @page thread_safety Thread safety
 
-FIXME
+When talking about thread-safety, there are 2 types of things to consider:
+- the logger class(es)
+- the filter class(es)
 
+Based on your application, you can fine tune any of the above to suit your needs:
+- use it as single threaded
+- use @ref macros_tss "TSS" (Thread Specific Storage)
+ - use TSS - have some data you modify thread-safe(using mutexes), and have each thread cache the value, and refresh at a given period (very efficient)
+ - initialize your logger/filter only once, and once it's initialized, always use that value (very efficient)
+- thread-safe (use mutexes) - every access uses a mutex; very slow in comparison to the above methods
+
+In addition to the above, for loggers, you can have an even faster method of writing the messages to their destinations:
+@ref writer::on_dedicated_thread "on a dedicated thread".
+
+\n\n
+The easiest way to specify the logger and filter classes, is to @ref scenario::usage "customize the lib to suit your application's needs".
+
+Alternatively, you can @ref defining_your_logger_filter "define them manually":
+- filters:
+ - @c filter::no_ts - single threaded filter
+ - @c filter::ts - thread-safe filter
+ - @c filter::use_tss_with_cache - use TSS: have each thread cache the value, and refresh at a given period
+ - @c filter::use_tss_once_init - use TSS: once the value is set, it will be used by each thread
+- loggers:
+ - <tt>logger<default_, default_, writer::threading::no_ts> </tt> - single threaded logger
+ - <tt>logger<default_, default_, writer::threading::ts_write> </tt> - thread-safe logger
+ - <tt>logger<default_, default_, writer::threading::on_dedicated_thread> </tt> - thread-safe logger, writing on dedicated thread
+
+\n
+Note: I recommend defining loggers manually only if you know the lib very well. Otherwise, choose one of these:
+- @ref scenario::usage "customize the lib to suit your application's needs"
+- @ref defining_your_logger_filter
 */
 
 }}

Modified: sandbox/logging/boost/logging/detail/use_format_write.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/use_format_write.hpp (original)
+++ sandbox/logging/boost/logging/detail/use_format_write.hpp 2007-11-16 14:25:14 EST (Fri, 16 Nov 2007)
@@ -26,7 +26,7 @@
 
 #include <boost/logging/detail/fwd.hpp>
 #include <boost/logging/format/optimize.hpp>
-#include <boost/logging/process_msg/ostream_like.hpp>
+#include <boost/logging/gather/ostream_like.hpp>
 #include <boost/logging/detail/manipulator.hpp>
 #include <boost/logging/detail/find_gather.hpp>
 #include <boost/type_traits/remove_reference.hpp>

Modified: sandbox/logging/boost/logging/format.hpp
==============================================================================
--- sandbox/logging/boost/logging/format.hpp (original)
+++ sandbox/logging/boost/logging/format.hpp 2007-11-16 14:25:14 EST (Fri, 16 Nov 2007)
@@ -330,21 +330,21 @@
     Example:
 
     @code
- typedef process_msg< gather::ostream_like::return_str<> ,
+ typedef logger< default_,
         writer::format_write< format_base, destination_base, format_and_write::simple<cache_string>,
- msg_route::with_route<format_base,destination_base> > > process;
- logger<process, filter::no_ts> g_l;
+ msg_route::with_route<format_base,destination_base> > > log_type;
+ log_type g_l;
 
     g_l->writer().router().set_route()
- .fmt( write_time() )
- .fmt( append_newline() )
- .dest( write_to_dbg() )
- .fmt( write_idx() )
- .dest( write_to_cout() )
+ .fmt( formatter::time() )
+ .fmt( formatter::append_newline() )
+ .dest( destination::dbg_window() )
+ .fmt( formatter::write_idx() )
+ .dest( destination::cout() )
         .clear()
- .fmt( write_idx() )
- .fmt( append_newline() )
- .fmt( write_to_file())
+ .fmt( formatter::write_idx() )
+ .fmt( formatter::append_newline() )
+ .fmt( formatter::write_to_file())
         ;
     @endcode
 
@@ -593,7 +593,7 @@
 
 #include <boost/logging/format/formatter/defaults.hpp>
 #include <boost/logging/format/destination/defaults.hpp>
-#include <boost/logging/process_msg/ostream_like.hpp>
+#include <boost/logging/gather/ostream_like.hpp>
 
 
 

Modified: sandbox/logging/boost/logging/format_fwd.hpp
==============================================================================
--- sandbox/logging/boost/logging/format_fwd.hpp (original)
+++ sandbox/logging/boost/logging/format_fwd.hpp 2007-11-16 14:25:14 EST (Fri, 16 Nov 2007)
@@ -24,7 +24,7 @@
 
 #include <boost/logging/logging.hpp>
 #include <boost/logging/format/optimize.hpp>
-#include <boost/logging/process_msg/ostream_like.hpp>
+#include <boost/logging/gather/ostream_like.hpp>
 
 namespace boost { namespace logging {
 

Modified: sandbox/logging/lib/logging/internal/vc8/loggingvc8/loggingvc8.vcproj
==============================================================================
--- sandbox/logging/lib/logging/internal/vc8/loggingvc8/loggingvc8.vcproj (original)
+++ sandbox/logging/lib/logging/internal/vc8/loggingvc8/loggingvc8.vcproj 2007-11-16 14:25:14 EST (Fri, 16 Nov 2007)
@@ -326,196 +326,8 @@
                         Name="tests"
>
                         <File
- RelativePath="..\..\..\tests\do_not_use\format\test_format_write_ts.cpp"
+ RelativePath=".\test_now.cpp"
>
- <FileConfiguration
- Name="Test|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="TestAll|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\..\tests\do_not_use\format\test_manip_being_func.cpp"
- >
- <FileConfiguration
- Name="Test|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="TestAll|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\..\tests\do_not_use\format\test_manip_w_msgroute.cpp"
- >
- <FileConfiguration
- Name="Test|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="TestAll|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\..\tests\do_not_use\test_mul_lev_difflogs.cpp"
- >
- <FileConfiguration
- Name="Test|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="TestAll|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\..\tests\do_not_use\test_mul_lev_samelog.cpp"
- >
- <FileConfiguration
- Name="Test|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="TestAll|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\..\tests\do_not_use\test_multiple_simple_logs.cpp"
- >
- <FileConfiguration
- Name="Test|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="TestAll|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\..\tests\do_not_use\test_ostream_like.cpp"
- >
- <FileConfiguration
- Name="Test|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="TestAll|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\..\tests\do_not_use\test_simple_dump_to_cout.cpp"
- >
- <FileConfiguration
- Name="Test|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="TestAll|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\..\tests\do_not_use\format\test_simple_formatter.cpp"
- >
- <FileConfiguration
- Name="Test|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
- Name="TestAll|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\..\..\tests\do_not_use\testfast.cpp"
- >
- <FileConfiguration
- Name="TestAll|Win32"
- ExcludedFromBuild="true"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
                         </File>
                 </Filter>
                 <Filter
@@ -866,10 +678,6 @@
>
                         </File>
                         <File
- RelativePath="..\..\..\..\..\boost\logging\detail\raw_doc\old_examples.hpp"
- >
- </File>
- <File
                                 RelativePath="..\..\..\..\..\boost\logging\detail\raw_doc\requirements.hpp"
>
                         </File>

Added: sandbox/logging/lib/logging/internal/vc8/loggingvc8/test_now.cpp
==============================================================================
--- (empty file)
+++ sandbox/logging/lib/logging/internal/vc8/loggingvc8/test_now.cpp 2007-11-16 14:25:14 EST (Fri, 16 Nov 2007)
@@ -0,0 +1,100 @@
+
+#define BOOST_LOG_COMPILE_FAST_OFF
+#include <boost/logging/format_fwd.hpp>
+#include <boost/logging/tags.hpp>
+
+// Step 1: Optimize : use 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; //(1a)
+//typedef bl::tag::holder< bl::hold_string_type, bl::tag::file_line, bl::tag::thread_id, bl::tag::time> log_string; //(1b)
+BOOST_LOG_FORMAT_MSG( log_string )
+
+#include <boost/logging/format.hpp>
+#include <boost/logging/writer/ts_write.hpp>
+#include <boost/logging/format/formatter/tags.hpp>
+
+using namespace boost::logging;
+
+// Step 3 : Specify your logging class(es)
+using namespace boost::logging::scenario::usage;
+typedef use<default_,filter_::level::use_levels> 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)
+#define LDBG BOOST_LOG_USE_LOG_IF_LEVEL(g_l, g_log_filter, debug ) \
+ .set_tag( BOOST_LOG_TAG_FILELINE) << "[dbg] "
+#define LINF BOOST_LOG_USE_LOG_IF_LEVEL(g_l, g_log_filter, info ) \
+ .set_tag( BOOST_LOG_TAG_FILELINE) << "[inf] "
+#define LWRN BOOST_LOG_USE_LOG_IF_LEVEL(g_l, g_log_filter, warning ) \
+ .set_tag( BOOST_LOG_TAG_FILELINE) << "[wrn] "
+#define LERR BOOST_LOG_USE_LOG_IF_LEVEL(g_l, g_log_filter, error ) \
+ .set_tag( BOOST_LOG_TAG_FILELINE) << "[err] "
+#define LFAT BOOST_LOG_USE_LOG_IF_LEVEL(g_l, g_log_filter, fatal ) \
+ .set_tag( BOOST_LOG_TAG_FILELINE) << "[fat] "
+
+void init_logs();
+
+
+
+
+// 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 init_logs() {
+ using namespace boost::logging;
+ // Add formatters and destinations
+ // That is, how the message is to be formatted...
+ g_l->writer().add_formatter( formatter::tag::time("$hh:$mm.$ss ") );
+ g_l->writer().add_formatter( formatter::tag::file_line() );
+ g_l->writer().add_formatter( formatter::idx() );
+ g_l->writer().add_formatter( formatter::append_newline_if_needed() ); //(2a)
+ g_l->writer().add_formatter( formatter::append_newline() ); //(2b)
+
+ // ... and where should it be written to
+ g_l->writer().add_destination( destination::cout() );
+ //g_l->writer().add_destination( destination::dbg_window() );
+/* g_l->writer().add_destination
+ ( destination::rolling_file("atne_logging",
+ destination::rolling_file_settings().max_size_bytes(1024 * 10) )
+ );
+ */ g_l->writer().add_destination( destination::file("out.txt") );
+}
+void your_scenario_example() {
+
+ init_logs();
+
+ // Step 8: use it...
+ int i = 1;
+ LDBG << "this is so cool " << i++ << "\n";
+ LDBG << "this is so cool again " << i++;
+ LERR << "first error " << i++;
+
+ std::string hello = "hello", world = "world";
+ LWRN << hello << ", " << world;
+
+ LDBG << "this will not be written anywhere";
+ LWRN << "this won't be written anywhere either";
+ LERR << "this error is not logged " << i++;
+
+ LWRN << "good to be back ;) " << i++;
+ LERR << "second error " << i++;
+
+}
+
+
+
+#ifdef SINGLE_TEST
+
+int main() {
+ your_scenario_example();
+}
+
+#endif
+
+// End of file
+


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