Boost logo

Boost-Commit :

From: john.groups_at_[hidden]
Date: 2008-02-08 09:46:52


Author: jtorjo
Date: 2008-02-08 09:46:50 EST (Fri, 08 Feb 2008)
New Revision: 43173
URL: http://svn.boost.org/trac/boost/changeset/43173

Log:
[logging]
v0.22.9, 8 feb 2008
- added few fixes, due to feedback review
  - out_of_the_box usage
  - logger_base - virtual destructor
  - custom_tag example
  - header_only_lib example

Added:
   sandbox/logging/boost/logging/format/destination/syslog.hpp (contents, props changed)
   sandbox/logging/boost/logging/out_of_the_box/
   sandbox/logging/boost/logging/out_of_the_box/no_levels.hpp (contents, props changed)
   sandbox/logging/boost/logging/out_of_the_box/use_levels.hpp (contents, props changed)
   sandbox/logging/libs/logging/samples/header_only_lib/
   sandbox/logging/libs/logging/samples/header_only_lib/header_only_lib.sln (contents, props changed)
   sandbox/logging/libs/logging/samples/header_only_lib/header_only_lib.vcproj (contents, props changed)
   sandbox/logging/libs/logging/samples/header_only_lib/main.cpp (contents, props changed)
   sandbox/logging/libs/logging/samples/header_only_lib/settings_lib/
   sandbox/logging/libs/logging/samples/header_only_lib/settings_lib/settings.hpp (contents, props changed)
   sandbox/logging/libs/logging/samples/header_only_lib/settings_lib/settings_log.hpp (contents, props changed)
   sandbox/logging/libs/logging/samples/scenarios/custom_tag.cpp (contents, props changed)
Properties modified:
   sandbox/logging/libs/logging/internal/vc8/loggingvc8/ (props changed)
   sandbox/logging/libs/logging/samples/dll_and_exe/the_dll/ (props changed)
   sandbox/logging/libs/logging/samples/dll_and_exe/the_exe/ (props changed)
Text files modified:
   sandbox/logging/boost/logging/detail/logger_base.hpp | 2
   sandbox/logging/boost/logging/detail/manipulator.hpp | 1
   sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp | 8 ++++
   sandbox/logging/boost/logging/detail/raw_doc/main.hpp | 2
   sandbox/logging/boost/logging/detail/raw_doc/todo.hpp | 5 +++
   sandbox/logging/boost/logging/format/destination/convert_destination.hpp | 23 +++++++++++++
   sandbox/logging/boost/logging/writer/named_write.hpp | 12 +++++++
   sandbox/logging/libs/logging/internal/vc8/loggingvc8/loggingvc8.vcproj | 12 +++++++
   sandbox/logging/libs/logging/internal/vc8/loggingvc8/test_now.cpp | 64 +++++++++++----------------------------
   9 files changed, 79 insertions(+), 50 deletions(-)

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-02-08 09:46:50 EST (Fri, 08 Feb 2008)
@@ -52,7 +52,7 @@
         */
         template<class cache_type> struct default_cache_keeper {
             default_cache_keeper() : m_is_cache_turned_off(false) {}
- ~default_cache_keeper() {
+ virtual ~default_cache_keeper() {
                 // after we're destroyed, always consider the cache turned off
                 // (just in case someone is using the logger after it's been destroyed
                 m_is_cache_turned_off = true;

Modified: sandbox/logging/boost/logging/detail/manipulator.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/manipulator.hpp (original)
+++ sandbox/logging/boost/logging/detail/manipulator.hpp 2008-02-08 09:46:50 EST (Fri, 08 Feb 2008)
@@ -541,6 +541,7 @@
 @sa boost::logging::destination::convert, boost::logging::formatter::convert
 */
 struct is_generic {
+ virtual ~is_generic() {}
 
     /** @brief Override this if you want to allow configuration through scripting
 

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-02-08 09:46:50 EST (Fri, 08 Feb 2008)
@@ -1,7 +1,13 @@
 /**
 @page page_changelog Changelog
 
-_at_section changelog_cur_ver Current Version: v0.22.8, 4 feb 2008
+@section changelog_cur_ver Current Version: v0.22.9, 8 feb 2008
+- added few fixes, due to feedback review
+ - out_of_the_box usage
+ - logger_base - virtual destructor
+ - custom_tag example
+ - header_only_lib example
+- added index.html
 - added license to all .h .cpp files (in scenarios/tests - they were missing)
 - removed loggingvc8.cpp file (useless)
 - lib -> libs

Modified: sandbox/logging/boost/logging/detail/raw_doc/main.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/main.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/main.hpp 2008-02-08 09:46:50 EST (Fri, 08 Feb 2008)
@@ -59,7 +59,7 @@
 
 @copydoc mul_levels_one_logger
 
-_at_ref scenarios_code_1 "Click to see the code"
+@ref scenarios_code_mom "Click to see the code"
 \n\n\n
 
 To see more examples, check out @ref common_scenarios.

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-02-08 09:46:50 EST (Fri, 08 Feb 2008)
@@ -23,6 +23,9 @@
 @section todo_implementation Implementation
 
 
+- @c normal make it possible to enumerate formatters/destinations, and to reuse a certain formatter/destination
+ in 2 loggers in an easy way - that is, request it from one logger, and add it to another.
+
 - @c normal destination::stream_ptr - just like stream, but hold the stream as a shared pointer. Thus , we won't have to worry
                     about outliving the stream.
 
@@ -178,6 +181,8 @@
 
 - @c normal scoped logs - scoped_write_msg - explain that you need to implement this in case you have your own gather.read_msg().out() class
 
+- @c high explain more about filters
+
 */
 
 }}

Modified: sandbox/logging/boost/logging/format/destination/convert_destination.hpp
==============================================================================
--- sandbox/logging/boost/logging/format/destination/convert_destination.hpp (original)
+++ sandbox/logging/boost/logging/format/destination/convert_destination.hpp 2008-02-08 09:46:50 EST (Fri, 08 Feb 2008)
@@ -27,6 +27,22 @@
 
 template<class t> struct into {};
 
+namespace tag {
+ template<
+ class string_ ,
+ class param1 ,
+ class param2 ,
+ class param3 ,
+ class param4 ,
+ class param5 ,
+ class param6 ,
+ class param7 ,
+ class param8 ,
+ class param9 ,
+ class param10> struct holder ;
+}
+
+
 /**
 @brief Allows writing messages to destinations
 
@@ -37,10 +53,15 @@
 FIXME
 */
 namespace convert {
- template<class obj, class char_traits, class char_type> void write(const obj & m, std::basic_ostream<char_type, char_traits> & out) {
+ template<class obj, class char_type, class char_traits> void write(const obj & m, std::basic_ostream<char_type, char_traits> & out) {
         out << m;
     }
 
+ template<class string_, class p1, class p2, class p3, class p4, class p5, class p6, class p7, class p8, class p9, class p10, class char_type, class char_traits> void write(const ::boost::logging::tag::holder<string_,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10> & src, std::basic_ostream<char_type, char_traits> & out ) {
+ typedef typename ::boost::logging::tag::holder<string_,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10>::string_type string_type;
+ out << (const string_type&)src;
+ }
+
     template<class char_traits, class char_type> void write(const char_type* m, std::basic_ostream<char_type, char_traits> & out) {
         out << m;
     }

Added: sandbox/logging/boost/logging/format/destination/syslog.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/format/destination/syslog.hpp 2008-02-08 09:46:50 EST (Fri, 08 Feb 2008)
@@ -0,0 +1,99 @@
+// destination/syslog.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_destination_syslog_HPP_DEFINED
+#define JT28092007_destination_syslog_HPP_DEFINED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/logging/detail/fwd.hpp>
+#include <boost/logging/detail/manipulator.hpp>
+#include <boost/logging/format/destination/convert_destination.hpp>
+#include <boost/logging/format/destination/file.hpp>
+#include <boost/logging/detail/level.hpp>
+#include <syslog.h>
+
+namespace boost { namespace logging { namespace destination {
+
+
+/**
+ @brief Writes the string to syslog. Note: does not care about levels - always logs as LOG_INFO
+*/
+template<class convert_dest = do_convert_destination > struct syslog_no_levels_t : is_generic, boost::logging::op_equal::always_equal {
+
+ template<class msg_type> void operator()(const msg_type & msg) const {
+ syslog( LOG_INFO, msg.c_str() );
+ }
+};
+
+
+/** @brief syslog_no_levels_t with default values. See syslog_no_levels_t
+
+@copydoc syslog_no_levels_t
+*/
+typedef syslog_no_levels_t<> syslog_no_levels;
+
+
+
+
+
+
+/** @brief Writes the string to syslog. It cares about levels
+
+See @ref boost::logging::tag "how to use tags".
+*/
+template<class convert = do_convert_format::prepend> struct syslog_t : is_generic, uses_tag< level_t<convert>, ::boost::logging::tag::level >, boost::logging::op_equal::always_equal {
+ typedef convert convert_type;
+ template<class msg_type, class tag_type> void write_tag(msg_type & str, const tag_type & tag) const {
+ syslog( level_to_syslog_level(tag.val) , as_string(str).c_str() );
+ }
+
+private:
+ const hold_string_type& as_string(const hold_string_type & str) { return str; }
+
+ int level_to_syslog_level( level::type level) {
+ if ( level <= level::debug)
+ return LOG_DEBUG;
+ if ( level <= level::info)
+ return LOG_INFO;
+ if ( level <= level::warning)
+ return LOG_WARN;
+ if ( level <= level::error)
+ return LOG_ERR;
+ if ( level <= level::fatal)
+ return LOG_CRIT;
+
+ return LOG_EMERG;
+ }
+};
+
+
+
+
+
+/** @brief syslog_t with default values. See syslog_t
+
+@copydoc syslog_t
+*/
+typedef syslog_t<> syslog;
+
+
+}}}
+
+#endif
+

Added: sandbox/logging/boost/logging/out_of_the_box/no_levels.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/out_of_the_box/no_levels.hpp 2008-02-08 09:46:50 EST (Fri, 08 Feb 2008)
@@ -0,0 +1,46 @@
+// out_of_the_box_no_levels.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_out_of_the_box_no_levels_HPP_DEFINED
+#define JT28092007_out_of_the_box_no_levels_HPP_DEFINED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/logging/format/named_write.hpp>
+typedef boost::logging::named_logger<>::type logger_type;
+typedef boost::logging::filter::no_ts filter_type;
+
+namespace boost { namespace logging {
+ struct out_of_the_box_logger : logger_type {
+ out_of_the_box_logger() {
+ writer().write( BOOST_LOG_STR("%time%($hh:$mm.$ss.$mili) [%idx%] |\n"), BOOST_LOG_STR("cout file(log.txt) debug"));
+ mark_as_initialized();
+ }
+ };
+
+ struct do_log {
+ static out_of_the_box_logger* l_() { static out_of_the_box_logger i; return &i; }
+ static filter_type* l_filter_() { static filter_type f; return &f; }
+ };
+
+}}
+
+#define L_ BOOST_LOG_USE_LOG_IF_FILTER( ::boost::logging::do_log::l_(), ::boost::logging::do_log::l_filter_()->is_enabled() )
+
+#endif
+

Added: sandbox/logging/boost/logging/out_of_the_box/use_levels.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/out_of_the_box/use_levels.hpp 2008-02-08 09:46:50 EST (Fri, 08 Feb 2008)
@@ -0,0 +1,50 @@
+// out_of_the_box_use_levels.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_out_of_the_box_use_levels_HPP_DEFINED
+#define JT28092007_out_of_the_box_use_levels_HPP_DEFINED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/logging/format/named_write.hpp>
+typedef boost::logging::named_logger<>::type logger_type;
+typedef boost::logging::level::holder filter_type;
+
+namespace boost { namespace logging {
+ struct out_of_the_box_logger : logger_type {
+ out_of_the_box_logger() {
+ writer().write( BOOST_LOG_STR("%time%($hh:$mm.$ss.$mili) [%idx%] |\n"), BOOST_LOG_STR("cout file(log.txt) debug"));
+ mark_as_initialized();
+ }
+ };
+
+ struct do_log {
+ static out_of_the_box_logger* l_() { static out_of_the_box_logger i; return &i; }
+ static filter_type* l_filter_() { static filter_type f; return &f; }
+ };
+
+}}
+
+#define L_(lvl) BOOST_LOG_USE_LOG_IF_FILTER( ::boost::logging::do_log::l_(), ::boost::logging::do_log::l_filter_(), lvl )
+
+#endif
+

Modified: sandbox/logging/boost/logging/writer/named_write.hpp
==============================================================================
--- sandbox/logging/boost/logging/writer/named_write.hpp (original)
+++ sandbox/logging/boost/logging/writer/named_write.hpp 2008-02-08 09:46:50 EST (Fri, 08 Feb 2008)
@@ -153,6 +153,18 @@
         init();
     }
 
+ /** @brief Constructs the named_write, and specifies the formats and destinations
+ */
+ named_write(const string_type & format_str, const string_type & destination_str) {
+ m_writer.add_formatter( m_format_before);
+ m_writer.add_formatter( m_format_after);
+ m_writer.add_destination( m_destination);
+
+ init();
+ write(format_str, destination_str);
+ }
+
+
     /** @brief sets the format string: what should be before, and what after the original message, separated by "|"
 
     Example: \n

Modified: sandbox/logging/libs/logging/internal/vc8/loggingvc8/loggingvc8.vcproj
==============================================================================
--- sandbox/logging/libs/logging/internal/vc8/loggingvc8/loggingvc8.vcproj (original)
+++ sandbox/logging/libs/logging/internal/vc8/loggingvc8/loggingvc8.vcproj 2008-02-08 09:46:50 EST (Fri, 08 Feb 2008)
@@ -697,6 +697,18 @@
>
                                 </File>
                         </Filter>
+ <Filter
+ Name="out_of_the_box"
+ >
+ <File
+ RelativePath="..\..\..\..\..\boost\logging\out_of_the_box\no_levels.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\boost\logging\out_of_the_box\use_levels.hpp"
+ >
+ </File>
+ </Filter>
                 </Filter>
                 <Filter
                         Name="internal docs"

Modified: sandbox/logging/libs/logging/internal/vc8/loggingvc8/test_now.cpp
==============================================================================
--- sandbox/logging/libs/logging/internal/vc8/loggingvc8/test_now.cpp (original)
+++ sandbox/logging/libs/logging/internal/vc8/loggingvc8/test_now.cpp 2008-02-08 09:46:50 EST (Fri, 08 Feb 2008)
@@ -1,59 +1,31 @@
-// 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
+#include <boost/logging/format.hpp>
+#include <boost/logging/format/formatter/tags.hpp>
+#include <boost/logging/format/formatter/syslog.hpp>
 
+namespace bl = boost::logging;
+typedef bl::tag::holder<bl::default_, bl::tag::level> tag_holder;
+BOOST_LOG_FORMAT_MSG(tag_holder)
+BOOST_LOG_DESTINATION_MSG(tag_holder)
 
+typedef bl::logger_format_write< > logger_type;
 
+#define L_(lvl) BOOST_LOG_USE_LOG_IF_LEVEL(g_l(), g_log_filter(), lvl ) .set_tag( BOOST_LOG_TAG_LEVEL(lvl) )
 
-#include <boost/logging/format_fwd.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() )
-
-// 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_FILTER(g_log_filter, bl::level::holder )
 BOOST_DEFINE_LOG(g_l, logger_type)
 
-
-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");
+int main() {
+ g_l()->writer().add_formatter( bl::formatter::idx(), "[%] " );
+ g_l()->writer().add_formatter( bl::formatter::append_newline() );
+ // write to cout and syslog
+ g_l()->writer().add_destination( bl::destination::cout() );
+ g_l()->writer().add_destination( bl::destination::syslog() );
     g_l()->mark_as_initialized();
 
     int i = 1;
- L_ << "this is so cool " << i++;
- L_ << "this is so cool again " << i++;
-
- std::string hello = "hello", world = "world";
- L_ << hello << ", " << world;
-
- g_log_filter()->set_enabled(false);
- L_ << "this will not be written to the log";
- L_ << "this won't be written to the log";
-
- g_log_filter()->set_enabled(true);
- L_ << "good to be back ;) " << i++;
-}
-
-
-
-
-int main() {
- one_logger_one_filter_example();
+ L_(debug) << "this is so cool " << i++;
+ L_(error) << "first error " << i++;
 }
 
 
-// End of file
 

Added: sandbox/logging/libs/logging/samples/header_only_lib/header_only_lib.sln
==============================================================================
--- (empty file)
+++ sandbox/logging/libs/logging/samples/header_only_lib/header_only_lib.sln 2008-02-08 09:46:50 EST (Fri, 08 Feb 2008)
@@ -0,0 +1,23 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "header_only_lib", "header_only_lib.vcproj", "{9A44F3D6-2252-48FF-9468-21A587471A4B}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ DebugLibDisableLog|Win32 = DebugLibDisableLog|Win32
+ DebugLibEnableLog|Win32 = DebugLibEnableLog|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {9A44F3D6-2252-48FF-9468-21A587471A4B}.DebugLibDisableLog|Win32.ActiveCfg = Debug|Win32
+ {9A44F3D6-2252-48FF-9468-21A587471A4B}.DebugLibDisableLog|Win32.Build.0 = Debug|Win32
+ {9A44F3D6-2252-48FF-9468-21A587471A4B}.DebugLibEnableLog|Win32.ActiveCfg = DebugLibEnableLog|Win32
+ {9A44F3D6-2252-48FF-9468-21A587471A4B}.DebugLibEnableLog|Win32.Build.0 = DebugLibEnableLog|Win32
+ {9A44F3D6-2252-48FF-9468-21A587471A4B}.Release|Win32.ActiveCfg = Release|Win32
+ {9A44F3D6-2252-48FF-9468-21A587471A4B}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal

Added: sandbox/logging/libs/logging/samples/header_only_lib/header_only_lib.vcproj
==============================================================================
--- (empty file)
+++ sandbox/logging/libs/logging/samples/header_only_lib/header_only_lib.vcproj 2008-02-08 09:46:50 EST (Fri, 08 Feb 2008)
@@ -0,0 +1,268 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="header_only_lib"
+ ProjectGUID="{9A44F3D6-2252-48FF-9468-21A587471A4B}"
+ RootNamespace="header_only_lib"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=".,../../../.."
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="DebugLibEnableLog|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=".,../../../.."
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;SETTINGS_USE_LOGGING"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="lib"
+ >
+ <File
+ RelativePath=".\settings_lib\settings.hpp"
+ >
+ </File>
+ <File
+ RelativePath=".\settings_lib\settings_log.hpp"
+ >
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\main.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>

Added: sandbox/logging/libs/logging/samples/header_only_lib/main.cpp
==============================================================================
--- (empty file)
+++ sandbox/logging/libs/logging/samples/header_only_lib/main.cpp 2008-02-08 09:46:50 EST (Fri, 08 Feb 2008)
@@ -0,0 +1,44 @@
+/**
+ 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
+*/
+
+// this is the client application - the one that uses the library
+
+#include "settings_lib/settings.hpp"
+
+// If you have a header-only library, you will still need to initialize its logs;
+// Either the library provides a function like the one below, or you can provide it yourself
+
+void init_library_logs() {
+ // note: if the logging is disabled, anyway, nothing will be logged
+ using namespace ::settings;
+ using namespace bl;
+
+ do_log::l_()->writer().add_formatter( formatter::idx(), "[%] " );
+ do_log::l_()->writer().add_formatter( formatter::time("$mm:$ss ") );
+ do_log::l_()->writer().add_formatter( formatter::append_newline() );
+ do_log::l_()->writer().add_destination( destination::file("out.txt") );
+ do_log::l_()->writer().add_destination( destination::dbg_window() );
+ do_log::l_()->writer().add_destination( destination::cout() );
+ do_log::l_()->mark_as_initialized();
+}
+
+int main() {
+ init_library_logs();
+
+ // use some functions from the library
+ settings::read_first_line("t.txt");
+ settings::read_first_line_or_error("t.txt");
+}
+

Added: sandbox/logging/libs/logging/samples/header_only_lib/settings_lib/settings.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/libs/logging/samples/header_only_lib/settings_lib/settings.hpp 2008-02-08 09:46:50 EST (Fri, 08 Feb 2008)
@@ -0,0 +1,57 @@
+/**
+ 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
+*/
+
+/* Assume you have a header-only library,
+ and you want to allow for logging.
+
+ This example shows you just how to do that:
+ - settings.hpp - part of your library, uses the Boost Logging Lib
+ - settings_log.hpp - sets up using the Boost Logging Lib
+
+
+ Pay attention to the SETTINGS_USE_LOGGING - if not defined, all logging is disabled automatically
+
+*/
+
+#ifndef SETTINGS_HPP
+#define SETTINGS_HPP
+
+#include "settings_lib/settings_log.hpp"
+#include <iostream>
+#include <fstream>
+#include <string>
+
+namespace settings {
+
+ inline void read_first_line(const std::string & file_name) {
+ L_(debug) << "opening file " << file_name;
+ std::ifstream in( file_name.c_str() );
+ std::string line;
+ std::getline(in, line);
+ L_(info) << "first line from " << file_name << " is " << line;
+ }
+
+ inline void read_first_line_or_error(const std::string & file_name) {
+ L_(debug) << "opening file " << file_name;
+ std::ifstream in( file_name.c_str() );
+ std::string line;
+ std::getline(in, line);
+ if ( line.empty() )
+ L_(error) << "file " << file_name << " - first line is empty";
+ }
+
+}
+
+#endif

Added: sandbox/logging/libs/logging/samples/header_only_lib/settings_lib/settings_log.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/libs/logging/samples/header_only_lib/settings_lib/settings_log.hpp 2008-02-08 09:46:50 EST (Fri, 08 Feb 2008)
@@ -0,0 +1,59 @@
+/**
+ 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
+*/
+
+/* Assume you have a header-only library,
+ and you want to allow for logging.
+
+ This example shows you just how to do that:
+ - settings.hpp - part of your library, uses the Boost Logging Lib
+ - settings_log.hpp - sets up using the Boost Logging Lib
+
+ Pay attention to the SETTINGS_USE_LOGGING - if not defined, all logging is disabled automatically
+*/
+
+#ifndef SETTINGS_log_HPP
+#define SETTINGS_log_HPP
+
+#include <boost/logging/format.hpp>
+namespace bl = boost::logging;
+
+namespace settings {
+ typedef bl::logger_format_write<> logger_type;
+
+#ifdef SETTINGS_USE_LOGGING
+ // if doing logging, lets do it based on levels
+ typedef bl::level::holder filter_type;
+#else
+ // john.torjo:
+ // note: yes, it's my fault - the always_disabled filter from Boost Logging Lib needs to allow any no. of arguments
+ // I'll modify it after the review
+ struct always_disabled {
+ static bool is_enabled() { return false; }
+ static bool is_enabled(int) { return false; }
+ };
+ typedef always_disabled filter_type;
+#endif
+
+ struct do_log {
+ static BOOST_DEFINE_LOG(l_, logger_type)
+ static BOOST_DEFINE_LOG_FILTER(l_filter_, filter_type)
+ };
+
+}
+
+#define L_(lvl) BOOST_LOG_USE_LOG_IF_LEVEL( ::settings::do_log::l_(), ::settings::do_log::l_filter_(), lvl )
+
+
+#endif

Added: sandbox/logging/libs/logging/samples/scenarios/custom_tag.cpp
==============================================================================
--- (empty file)
+++ sandbox/logging/libs/logging/samples/scenarios/custom_tag.cpp 2008-02-08 09:46:50 EST (Fri, 08 Feb 2008)
@@ -0,0 +1,73 @@
+/**
+ 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
+*/
+
+
+#include <boost/logging/format_fwd.hpp>
+
+struct my_tag {
+ my_tag(const char * data = "" /* default value */) : data(data) {}
+ const char* data;
+};
+
+namespace bl = boost::logging;
+typedef bl::tag::holder< bl::default_, my_tag> tag_holder;
+BOOST_LOG_FORMAT_MSG( tag_holder )
+
+
+#include <boost/logging/format.hpp>
+#include <boost/logging/format/formatter/tags.hpp>
+
+typedef bl::logger_format_write< > logger_type;
+typedef bl::filter::no_ts filter_type;
+
+
+struct my_tag_formatter : bl::formatter::class_<my_tag_formatter, bl::formatter::implement_op_equal::no_context > {
+ void operator()(tag_holder & val) const {
+ typedef tag_holder::string_type string_type;
+ // automatic conversion - tag holder provides this
+ const my_tag & tag = val;
+ string_type & str = val;
+
+ // print the tag
+ str = tag.data + str;
+ }
+};
+
+
+#define L_(data) BOOST_LOG_USE_LOG_IF_FILTER(g_l(), g_log_filter()->is_enabled() ) .set_tag( my_tag(data) )
+
+BOOST_DEFINE_LOG_FILTER(g_log_filter, filter_type )
+BOOST_DEFINE_LOG(g_l, logger_type)
+
+
+void custom_tag_class_example() {
+ g_l()->writer().add_formatter( bl::formatter::time("$hh:$mm ") );
+ g_l()->writer().add_formatter( my_tag_formatter() );
+
+ g_l()->writer().add_formatter( bl::formatter::append_newline() );
+ g_l()->writer().add_destination( bl::destination::cout() );
+ g_l()->mark_as_initialized();
+
+ int i = 1;
+ L_("tag_a ") << "this is so cool " << i++;
+ L_("tag_b ") << "this is so cool again " << i++;
+}
+
+
+
+
+int main() {
+ custom_tag_class_example();
+}


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