$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: john.groups_at_[hidden]
Date: 2008-01-18 11:05:37
Author: jtorjo
Date: 2008-01-18 11:05:36 EST (Fri, 18 Jan 2008)
New Revision: 42845
URL: http://svn.boost.org/trac/boost/changeset/42845
Log:
[logging]
v0.20.6, 18 jan 2008
- added test for using logger after it's been destroyed - not working yet!
- handle using logger after it's been destroyed (partially)
Added:
   sandbox/logging/lib/logging/tests/test_after_destroyed/
   sandbox/logging/lib/logging/tests/test_after_destroyed/test.cpp   (contents, props changed)
   sandbox/logging/lib/logging/tests/test_after_destroyed/test_after_destroyed.vcproj   (contents, props changed)
Text files modified: 
   sandbox/logging/boost/logging/detail/after_being_destroyed.hpp |     7 ++++++-                                 
   sandbox/logging/lib/logging/tests/test_file/test.cpp           |     1 -                                       
   2 files changed, 6 insertions(+), 2 deletions(-)
Modified: sandbox/logging/boost/logging/detail/after_being_destroyed.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/after_being_destroyed.hpp	(original)
+++ sandbox/logging/boost/logging/detail/after_being_destroyed.hpp	2008-01-18 11:05:36 EST (Fri, 18 Jan 2008)
@@ -54,6 +54,12 @@
         typedef typename destination::msg_type<T>::raw_type raw_type;
         typedef void (*after_destroyed_func)(const raw_type&) ;
 
+
+        void set_after_destroyed(after_destroyed_func f) {
+            m_after_being_destroyed = f;
+        }
+
+    protected:
         // default implementation - do nothing
         static void nothing(const raw_type&) {}
 
@@ -62,7 +68,6 @@
             m_after_being_destroyed(msg); 
         }
 
-    protected:
         after_being_destroyed_defer_to_function () : m_is_destroyed(false), m_after_being_destroyed(¬hing) {}
         ~after_being_destroyed_defer_to_function () {
             m_is_destroyed = true;
Added: sandbox/logging/lib/logging/tests/test_after_destroyed/test.cpp
==============================================================================
--- (empty file)
+++ sandbox/logging/lib/logging/tests/test_after_destroyed/test.cpp	2008-01-18 11:05:36 EST (Fri, 18 Jan 2008)
@@ -0,0 +1,72 @@
+/* 
+    Tests using the log after it's been destroyed
+*/
+
+#include <boost/logging/format.hpp>
+#include <string>
+#include <sstream>
+
+using namespace boost::logging;
+
+typedef logger_format_write< > log_type;
+
+
+
+void test_after_destroyed() ;
+
+bool g_called_correctly = false;
+
+struct last_to_be_destroyed {
+    ~last_to_be_destroyed () {
+        // this is to be called after s_before_log's destructor
+        BOOST_ASSERT(g_called_correctly);
+    }
+} s_last;
+
+
+// this will be initialized before the our log (g_l)
+// thus, it will be destroyed afterwards
+struct before_log {
+    ~before_log() {
+        g_called_correctly = true;
+        test_after_destroyed();
+    }
+} s_before_log;
+
+BOOST_DEFINE_LOG_FILTER(g_log_filter, filter::no_ts ) 
+BOOST_DEFINE_LOG(g_l, log_type)
+
+#define L_ BOOST_LOG_USE_LOG_IF_FILTER(g_l(), g_log_filter()->is_enabled() ) 
+
+// whatever we log to the rolling file, we log here too (easy was to find out all the info that was logged)
+std::stringstream g_stringstream;
+
+
+bool g_log_destroyed = false;
+void called_after_log_destruction(const std::string&) {
+    g_log_destroyed = true;
+}
+
+void test_before_destroyed() {
+    g_l()->writer().add_formatter( formatter::append_newline() );
+    g_l()->writer().add_destination( destination::cout() );
+    g_l()->writer().add_destination( destination::stream(g_stringstream) );
+    g_l()->turn_cache_off();
+    g_l()->set_after_destroyed( called_after_log_destruction);
+
+    L_ << "hello world";
+    BOOST_ASSERT(g_stringstream.str() == "hello world\n");
+    g_stringstream.str("");
+}
+
+void test_after_destroyed() {
+    // this should actually call "called_after_log_destruction" function
+    L_ << "hello world 2";
+    BOOST_ASSERT( g_log_destroyed);
+    // nothing should have been written there
+    BOOST_ASSERT( g_stringstream.str() == "");
+}
+
+int main() {
+    test_before_destroyed();
+}
Added: sandbox/logging/lib/logging/tests/test_after_destroyed/test_after_destroyed.vcproj
==============================================================================
--- (empty file)
+++ sandbox/logging/lib/logging/tests/test_after_destroyed/test_after_destroyed.vcproj	2008-01-18 11:05:36 EST (Fri, 18 Jan 2008)
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="test_after_destroy"
+	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>
Modified: sandbox/logging/lib/logging/tests/test_file/test.cpp
==============================================================================
--- sandbox/logging/lib/logging/tests/test_file/test.cpp	(original)
+++ sandbox/logging/lib/logging/tests/test_file/test.cpp	2008-01-18 11:05:36 EST (Fri, 18 Jan 2008)
@@ -4,7 +4,6 @@
 */
 
 #include <boost/logging/format.hpp>
-#include <boost/logging/writer/ts_write.hpp>
 #include <string>
 
 using namespace boost::logging;