|
Boost-Commit : |
From: john.groups_at_[hidden]
Date: 2008-01-14 19:10:24
Author: jtorjo
Date: 2008-01-14 19:10:23 EST (Mon, 14 Jan 2008)
New Revision: 42782
URL: http://svn.boost.org/trac/boost/changeset/42782
Log:
[logging]
v0.13.13, 15 jan 2008
- added test_named_spacer test
Added:
sandbox/logging/lib/logging/tests/test_named_spacer/
sandbox/logging/lib/logging/tests/test_named_spacer/test.cpp (contents, props changed)
sandbox/logging/lib/logging/tests/test_named_spacer/test.vcproj (contents, props changed)
sandbox/logging/lib/logging/tests/test_named_spacer/test_named_spacer.sln (contents, props changed)
Text files modified:
sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp | 3 ++-
sandbox/logging/boost/logging/detail/scenario.hpp | 6 ++++++
sandbox/logging/boost/logging/format/formatter/defaults.hpp | 1 +
sandbox/logging/boost/logging/format/formatter/named_spacer.hpp | 2 +-
sandbox/logging/lib/logging/tests/test_template/test.vcproj | 2 +-
5 files changed, 11 insertions(+), 3 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 2008-01-14 19:10:23 EST (Mon, 14 Jan 2008)
@@ -1,7 +1,8 @@
/**
@page page_changelog Changelog
-_at_section changelog_cur_ver Current Version: v0.13.12, 14 jan 2008
+@section changelog_cur_ver Current Version: v0.13.13, 15 jan 2008
+- added test_named_spacer test
- solved bug if user doesn't use formatters/destinations, but uses cached string classes
- solved bug in rolling_file - it could not compile on gcc
- added test_rolling_file (tests rolling_file)
Modified: sandbox/logging/boost/logging/detail/scenario.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/scenario.hpp (original)
+++ sandbox/logging/boost/logging/detail/scenario.hpp 2008-01-14 19:10:23 EST (Mon, 14 Jan 2008)
@@ -109,6 +109,9 @@
*/
namespace usage {
+ // ... bring it in this namespace
+ typedef ::boost::logging::default_ default_;
+
/** @brief Filter usage settings : filter_::change and filter_::level
*/
@@ -435,6 +438,9 @@
To see how you can specify the logger/filter based on how you will %use them, see usage namespace.
*/
namespace ts {
+ // ... bring it in this namespace
+ typedef ::boost::logging::default_ default_;
+
/** @brief filter uses levels? */
struct level_ {
/** @brief type of %filter levels %usage */
Modified: sandbox/logging/boost/logging/format/formatter/defaults.hpp
==============================================================================
--- sandbox/logging/boost/logging/format/formatter/defaults.hpp (original)
+++ sandbox/logging/boost/logging/format/formatter/defaults.hpp 2008-01-14 19:10:23 EST (Mon, 14 Jan 2008)
@@ -27,6 +27,7 @@
#include <boost/logging/format/formatter/time.hpp>
#include <boost/logging/format/formatter/time_strf.hpp>
#include <boost/logging/format/formatter/spacer.hpp>
+#include <boost/logging/format/formatter/thread_id.hpp>
#include <stdio.h>
#include <time.h>
#include <sstream>
Modified: sandbox/logging/boost/logging/format/formatter/named_spacer.hpp
==============================================================================
--- sandbox/logging/boost/logging/format/formatter/named_spacer.hpp (original)
+++ sandbox/logging/boost/logging/format/formatter/named_spacer.hpp 2008-01-14 19:10:23 EST (Mon, 14 Jan 2008)
@@ -234,7 +234,7 @@
@bug Use_tags.cpp example when on dedicated thread, fails with named_spacer. If using the old code, it works.
*/
-template< class convert = do_convert_format::prepend, class lock_resource = default_, class format_base = default_ >
+template< class convert = default_, class lock_resource = default_, class format_base = default_ >
struct named_spacer_t : is_generic, non_const_context< detail::named_spacer_context<convert,lock_resource,format_base> > {
typedef non_const_context< detail::named_spacer_context<convert,lock_resource,format_base> > context_base;
Added: sandbox/logging/lib/logging/tests/test_named_spacer/test.cpp
==============================================================================
--- (empty file)
+++ sandbox/logging/lib/logging/tests/test_named_spacer/test.cpp 2008-01-14 19:10:23 EST (Mon, 14 Jan 2008)
@@ -0,0 +1,139 @@
+/*
+ Tests named_spacer
+*/
+
+#include <boost/logging/format.hpp>
+#include <boost/logging/format/formatter/named_spacer.hpp>
+
+using namespace boost::logging::scenario::usage;
+typedef use< filter_::change::single_thread, filter_::level::no_levels, logger_::change::single_thread, logger_::favor::single_thread > finder;
+
+using namespace boost::logging;
+
+BOOST_DEFINE_LOG_FILTER(g_log_filter, finder::filter )
+BOOST_DEFINE_LOG(g_l, finder::logger )
+
+#define L_ BOOST_LOG_USE_LOG_IF_FILTER(g_l, g_log_filter->is_enabled() )
+
+
+// whatever we log, is logged here too (easy was to find out all the info that was logged)
+std::stringstream g_out;
+
+
+// writes a letter (a-z); on each write, it increments the letter, and rolls back to 'a' once reaching 'z'
+struct abc : formatter::class_<abc, formatter::implement_op_equal::no_context> {
+ abc() : cur_letter('a') {}
+
+ void operator()(std::string & str) const {
+ str = cur_letter + str;
+ if ( ++cur_letter > 'z')
+ cur_letter = 'a';
+ }
+
+ mutable char cur_letter;
+};
+
+// our named spacer - the one we're testing
+formatter::named_spacer_t<boost::logging::default_, lock_resource_finder::single_thread > g_ns;
+
+// we're constantly writing hello world
+std::string g_msg = "hello world";
+
+// current thread id - note : in our processing, we only need to know it as string.
+std::string g_thread_id;
+
+void init_logs() {
+ g_l->writer().add_formatter( g_ns
+ .add( "idx", formatter::idx() )
+ .add( "tid", formatter::thread_id() )
+ .add( "abc", abc() ));
+ g_l->writer().add_formatter( formatter::append_newline() );
+ g_l->writer().add_destination( destination::stream(g_out) );
+ g_l->writer().add_destination( destination::cout() );
+ g_l->turn_cache_off();
+}
+
+void test_with_all_formatters() {
+ g_ns.string("[%idx%] {%tid%} (%abc%)-");
+ L_ << g_msg;
+ BOOST_ASSERT( g_out.str() == "[1] {" + g_thread_id + "} (a)-hello world\n");
+ g_out.str("");
+
+ g_ns.string("[%idx%] (%abc%)-{%tid%}/");
+ L_ << g_msg;
+ BOOST_ASSERT( g_out.str() == "[2] (b)-{" + g_thread_id + "}/hello world\n");
+ g_out.str("");
+
+ g_ns.string("[%idx%]/[%abc%]/[%tid%]/ ");
+ L_ << g_msg;
+ BOOST_ASSERT( g_out.str() == "[3]/[c]/[" + g_thread_id + "]/ hello world\n");
+ g_out.str("");
+}
+
+void test_with_2_formatters() {
+ g_ns.string("[%idx%] (%abc%)-");
+ L_ << g_msg;
+ BOOST_ASSERT( g_out.str() == "[4] (d)-hello world\n");
+ g_out.str("");
+
+ g_ns.string("[%tid%] (%idx%)-");
+ L_ << g_msg;
+ BOOST_ASSERT( g_out.str() == "[" + g_thread_id + "] (5)-hello world\n");
+ g_out.str("");
+
+ g_ns.string("[%abc%] [%tid%]: ");
+ L_ << g_msg;
+ BOOST_ASSERT( g_out.str() == "[e] [" + g_thread_id + "]: hello world\n");
+ g_out.str("");
+
+}
+
+void test_with_1_formatter() {
+ g_ns.string("[%idx%]/ ");
+ L_ << g_msg;
+ BOOST_ASSERT( g_out.str() == "[6]/ hello world\n");
+ g_out.str("");
+
+ g_ns.string("{%tid%}- ");
+ L_ << g_msg;
+ BOOST_ASSERT( g_out.str() == "{" + g_thread_id + "}- hello world\n");
+ g_out.str("");
+
+ g_ns.string("%abc%/ ");
+ L_ << g_msg;
+ BOOST_ASSERT( g_out.str() == "f/ hello world\n");
+ g_out.str("");
+
+}
+
+
+void test_with_no_formatters() {
+ g_ns.string("/ ");
+ L_ << g_msg;
+ BOOST_ASSERT( g_out.str() == "/ hello world\n");
+ g_out.str("");
+
+ g_ns.string("abc ");
+ L_ << g_msg;
+ BOOST_ASSERT( g_out.str() == "abc hello world\n");
+ g_out.str("");
+
+ g_ns.string("");
+ L_ << g_msg;
+ BOOST_ASSERT( g_out.str() == "hello world\n");
+ g_out.str("");
+
+}
+
+
+int main() {
+ init_logs();
+ std::ostringstream out;
+ out << detail::get_thread_id();
+ g_thread_id = out.str();
+
+ test_with_all_formatters();
+ test_with_2_formatters();
+ test_with_1_formatter();
+ test_with_no_formatters();
+}
Added: sandbox/logging/lib/logging/tests/test_named_spacer/test.vcproj
==============================================================================
--- (empty file)
+++ sandbox/logging/lib/logging/tests/test_named_spacer/test.vcproj 2008-01-14 19:10:23 EST (Mon, 14 Jan 2008)
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="test_named_spacer"
+ ProjectGUID="{C5897099-5FA2-4E12-AFFC-2015364347FA}"
+ RootNamespace="test"
+ 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"
+ AdditionalLibraryDirectories="D:\boosts\boost_1_33_1\bin\boost\libs\thread\build\libboost_thread.lib\vc-8_0\debug\threading-multi"
+ 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>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath=".\test.cpp"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
Added: sandbox/logging/lib/logging/tests/test_named_spacer/test_named_spacer.sln
==============================================================================
--- (empty file)
+++ sandbox/logging/lib/logging/tests/test_named_spacer/test_named_spacer.sln 2008-01-14 19:10:23 EST (Mon, 14 Jan 2008)
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcproj", "{C5897099-5FA2-4E12-AFFC-2015364347FA}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {C5897099-5FA2-4E12-AFFC-2015364347FA}.Debug|Win32.ActiveCfg = Debug|Win32
+ {C5897099-5FA2-4E12-AFFC-2015364347FA}.Debug|Win32.Build.0 = Debug|Win32
+ {C5897099-5FA2-4E12-AFFC-2015364347FA}.Release|Win32.ActiveCfg = Release|Win32
+ {C5897099-5FA2-4E12-AFFC-2015364347FA}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
Modified: sandbox/logging/lib/logging/tests/test_template/test.vcproj
==============================================================================
--- sandbox/logging/lib/logging/tests/test_template/test.vcproj (original)
+++ sandbox/logging/lib/logging/tests/test_template/test.vcproj 2008-01-14 19:10:23 EST (Mon, 14 Jan 2008)
@@ -20,7 +20,7 @@
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
- CharacterSet="1"
+ CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
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