Boost logo

Boost-Commit :

From: john.groups_at_[hidden]
Date: 2007-11-15 01:54:23


Author: jtorjo
Date: 2007-11-15 01:54:23 EST (Thu, 15 Nov 2007)
New Revision: 41101
URL: http://svn.boost.org/trac/boost/changeset/41101

Log:
[logging]
v0.11.13, 15 nov 2007
- added @ref starter_project
Added:
   sandbox/logging/boost/logging/detail/raw_doc/starter_project.hpp (contents, props changed)
   sandbox/logging/lib/logging/samples/starter/
   sandbox/logging/lib/logging/samples/starter/log.cpp (contents, props changed)
   sandbox/logging/lib/logging/samples/starter/log.h (contents, props changed)
Properties modified:
   sandbox/logging/lib/logging/internal/ (props changed)
   sandbox/logging/lib/logging/internal/gcc/ (props changed)
   sandbox/logging/lib/logging/internal/vc8/loggingvc8/ (props changed)
Text files modified:
   sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp | 3 ++-
   sandbox/logging/boost/logging/detail/raw_doc/table_of_contents.hpp | 1 +
   sandbox/logging/lib/logging/internal/vc8/loggingvc8/loggingvc8.vcproj | 11 ++++-------
   sandbox/logging/lib/logging/samples/scenarios/using_tags.cpp | 10 +++++++++-
   4 files changed, 16 insertions(+), 9 deletions(-)

Modified: sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp 2007-11-15 01:54:23 EST (Thu, 15 Nov 2007)
@@ -1,7 +1,8 @@
 /**
 @page page_changelog Changelog
 
-_at_section changelog_cur_ver Current Version: v0.11.12, 14 nov 2007
+@section changelog_cur_ver Current Version: v0.11.13, 15 nov 2007
+- added @ref starter_project
 - solved bug when using append_newline_if_needed() - when not used with string
 - solved bug at opening file for initial overwrite
 - added destination::stream and test_log_output

Added: sandbox/logging/boost/logging/detail/raw_doc/starter_project.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/detail/raw_doc/starter_project.hpp 2007-11-15 01:54:23 EST (Thu, 15 Nov 2007)
@@ -0,0 +1,28 @@
+namespace boost { namespace logging {
+
+/**
+@page starter_project A starter project...
+
+You've probably looked at the @ref common_scenarios "scenarios", at @ref scenario_multiple_files "basic_usage example",
+and just in case, here's a something to get you started in your own project(s).
+
+You need 2 files:
+- @c log.h - where you declare your log(s)
+- @c log.cpp - where you define and initialize your log(s)
+
+Again, this is just a starter project, you can customize it as you wish. Enjoy!
+
+\n\n
+The log.h file
+
+@include starter/log.h
+
+\n\n
+The log.cpp file
+
+@include starter/log.cpp
+
+
+*/
+
+}}

Modified: sandbox/logging/boost/logging/detail/raw_doc/table_of_contents.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/table_of_contents.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/table_of_contents.hpp 2007-11-15 01:54:23 EST (Thu, 15 Nov 2007)
@@ -20,6 +20,7 @@
         - @ref scenario_multiple_files_log_h
         - @ref scenario_multiple_files_log_cpp
         - @ref scenario_multiple_files_main
+ - @ref starter_project
 
 - @ref headers_to_include "Headers to #include"
 - @ref scenario::usage "Choose the best filter/logger class, based on your application's needs"

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-15 01:54:23 EST (Thu, 15 Nov 2007)
@@ -509,13 +509,6 @@
                                 RelativePath="..\..\..\tests\do_not_use\testfast.cpp"
>
                                 <FileConfiguration
- Name="Test|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- />
- </FileConfiguration>
- <FileConfiguration
                                         Name="TestAll|Win32"
                                         ExcludedFromBuild="true"
>
@@ -877,6 +870,10 @@
>
                         </File>
                         <File
+ RelativePath="..\..\..\..\..\boost\logging\detail\raw_doc\starter_project.hpp"
+ >
+ </File>
+ <File
                                 RelativePath="..\..\..\..\..\boost\logging\detail\raw_doc\table_of_contents.hpp"
>
                         </File>

Modified: sandbox/logging/lib/logging/samples/scenarios/using_tags.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/using_tags.cpp (original)
+++ sandbox/logging/lib/logging/samples/scenarios/using_tags.cpp 2007-11-15 01:54:23 EST (Thu, 15 Nov 2007)
@@ -64,7 +64,15 @@
 
 // Step 3 : Specify your logging class(es)
 using namespace boost::logging::scenario::usage;
-typedef use<default_,filter_::level::no_levels> finder;
+typedef use<
+ // the filter is always accurate (but slow)
+ filter_::change::always_accurate,
+ // filter does not use levels
+ filter_::level::no_levels,
+ // the logger is initialized once, when only one thread is running
+ logger_::change::set_once_when_one_thread,
+ // 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 )

Added: sandbox/logging/lib/logging/samples/starter/log.cpp
==============================================================================
--- (empty file)
+++ sandbox/logging/lib/logging/samples/starter/log.cpp 2007-11-15 01:54:23 EST (Thu, 15 Nov 2007)
@@ -0,0 +1,29 @@
+// log.cpp
+#include "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>
+
+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)
+
+
+void init_logs() {
+ // Add formatters and destinations
+ // That is, how the message is to be formatted...
+ g_l->writer().add_formatter( formatter::tag::thread_id() );
+ g_l->writer().add_formatter( formatter::tag::time("$hh:$mm.$ss ") );
+ g_l->writer().add_formatter( formatter::idx() );
+ g_l->writer().add_formatter( formatter::append_newline() );
+
+ // ... and where should it be written to
+ g_l->writer().add_destination( destination::cout() );
+ g_l->writer().add_destination( destination::dbg_window() );
+ g_l->writer().add_destination( destination::file("out.txt") );
+}

Added: sandbox/logging/lib/logging/samples/starter/log.h
==============================================================================
--- (empty file)
+++ sandbox/logging/lib/logging/samples/starter/log.h 2007-11-15 01:54:23 EST (Thu, 15 Nov 2007)
@@ -0,0 +1,55 @@
+// log.h
+#ifndef LOG_H_header
+#define LOG_H_header
+
+#include <boost/logging/format_fwd.hpp>
+// If you want to use tags...
+#include <boost/logging/tags.hpp>
+
+// Step 1: Specify the class to hold the message
+namespace b_l = boost::logging;
+typedef b_l::tag::holder<
+ // string class
+ b_l::optimize::cache_string_one_str<>,
+ // tags
+ b_l::tag::thread_id, b_l::tag::time> log_string_type;
+// note: if you don't use tags, you can simply use a string class:
+// typedef b_l::optimize::cache_string_one_str<> log_string_type;
+BOOST_LOG_FORMAT_MSG( log_string_type )
+
+// if not compiling fast...
+#ifndef BOOST_LOG_COMPILE_FAST
+#include <boost/logging/format.hpp>
+#include <boost/logging/writer/ts_write.hpp>
+
+// If you use tags...
+#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>
+#endif
+
+
+// Step 3 : Specify your logging class(es)
+using namespace boost::logging::scenario::usage;
+typedef use<
+ // how often do you manipulate (change) the filter?
+ filter_::change::often<10>,
+ // does the filter use levels?
+ filter_::level::no_levels,
+ // how often do you manipulate (change) the logger?
+ logger_::change::often<10>,
+ // 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..
+void init_logs();
+
+#endif


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