|
Boost-Commit : |
From: john.groups_at_[hidden]
Date: 2007-11-02 08:38:10
Author: jtorjo
Date: 2007-11-02 08:38:08 EDT (Fri, 02 Nov 2007)
New Revision: 40681
URL: http://svn.boost.org/trac/boost/changeset/40681
Log:
[logging]
v0.10.1, 2 nov 2007
- added TSS - however, not tested (TSS is off, for now)
- compiles on VS2005, gcc 3.4.2 , gcc 4.1 and gcc 4.3
Added:
sandbox/logging/boost/logging/detail/tss/
sandbox/logging/boost/logging/detail/tss/tss.hpp (contents, props changed)
sandbox/logging/boost/logging/detail/tss/tss_ensure_proper_delete.hpp (contents, props changed)
sandbox/logging/boost/logging/detail/tss/tss_impl.hpp (contents, props changed)
sandbox/logging/boost/logging/detail/tss/tss_impl_pthread.hpp (contents, props changed)
sandbox/logging/boost/logging/detail/tss/tss_impl_win32.hpp (contents, props changed)
Properties modified:
sandbox/logging/lib/logging/internal/vc8/loggingvc8/ (props changed)
Text files modified:
sandbox/logging/boost/logging/defaults.hpp | 13 ++++++++++---
sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp | 4 ++++
sandbox/logging/boost/logging/detail/raw_doc/workflow.hpp | 2 +-
sandbox/logging/boost/logging/detail/ts/ts_resource.hpp | 28 ++++++++++++++++++++++++----
sandbox/logging/boost/logging/filter.hpp | 17 +++++++++++++----
sandbox/logging/boost/logging/format/destination/rolling_file.hpp | 5 ++++-
sandbox/logging/boost/logging/level.hpp | 36 +++++++++++++++++++++++-------------
sandbox/logging/boost/logging/macros.hpp | 22 +++++++++++++++-------
sandbox/logging/lib/logging/internal/vc8/loggingvc8/loggingvc8.vcproj | 36 ++++++++++++++++++++++++++++++------
sandbox/logging/lib/logging/samples/scenarios/custom_fmt_dest.cpp | 2 +-
10 files changed, 125 insertions(+), 40 deletions(-)
Modified: sandbox/logging/boost/logging/defaults.hpp
==============================================================================
--- sandbox/logging/boost/logging/defaults.hpp (original)
+++ sandbox/logging/boost/logging/defaults.hpp 2007-11-02 08:38:08 EDT (Fri, 02 Nov 2007)
@@ -21,7 +21,6 @@
#endif
#include <boost/logging/detail/ts/ts.hpp>
-#include <boost/logging/detail/ts/ts_resource.hpp>
#include <string>
#include <boost/config.hpp>
@@ -86,9 +85,13 @@
namespace level {
struct holder_no_ts ;
struct holder_ts ;
- struct holder_tls_with_cache ;
+ struct holder_tss_with_cache ;
}
+ namespace locker {
+ template<class type, class mutex > struct ts_resource ;
+ template<class , int> struct tss_resource_with_cache ;
+ }
struct default_types {
@@ -107,7 +110,11 @@
struct lock_resource {
template<class lock_type> struct finder {
- typedef typename locker::ts_resource<lock_type> type;
+//#ifndef BOOST_LOG_NO_TSS
+ // typedef typename locker::tss_resource_with_cache<lock_type, 5> type;
+//#else
+ typedef typename locker::ts_resource<lock_type, boost::logging::threading::mutex > type;
+//#endif
};
};
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-02 08:38:08 EDT (Fri, 02 Nov 2007)
@@ -1,6 +1,10 @@
/**
@page page_changelog Changelog
+v0.10.1, 2 nov 2007
+- added TSS - however, not tested (TSS is off, for now)
+- compiles on VS2005, gcc 3.4.2 , gcc 4.1 and gcc 4.3
+
v0.9.12.3, 1 nov 2007
- move ts/* files to detail directory
- doc - standalone page with changelog
Modified: sandbox/logging/boost/logging/detail/raw_doc/workflow.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/workflow.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/workflow.hpp 2007-11-02 08:38:08 EDT (Fri, 02 Nov 2007)
@@ -71,7 +71,7 @@
(gathering the message and then writing it). Otherwise, the log message is completely ignored.
What "it's enabled" is depends on the filter class you use:
-- if it's a simple class (filter::no_ts, filter::ts, filter::use_tls_with_cache), it's simply the @c is_enabled function (Example 1, above)
+- if it's a simple class (filter::no_ts, filter::ts, filter::use_tss_with_cache), it's simply the @c is_enabled function (Example 1, above)
- if it's a more complex class, it's up to you
- for instance, the level::holder_no_ts exposes an <tt>is_enabled(level)</tt>, so you can ask if a certain level is enabled (Example 2, above)
Thus, logging takes place only if that certain level is enabled (@c debug for LDBG_, @c info for LAPP_, @c error for LERR_)
Modified: sandbox/logging/boost/logging/detail/ts/ts_resource.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/ts/ts_resource.hpp (original)
+++ sandbox/logging/boost/logging/detail/ts/ts_resource.hpp 2007-11-02 08:38:08 EDT (Fri, 02 Nov 2007)
@@ -22,6 +22,8 @@
#endif
#include <boost/logging/detail/ts/ts.hpp>
+#include <boost/logging/detail/tss/tss.hpp>
+#include <time.h>
namespace boost { namespace logging {
@@ -103,21 +105,36 @@
type m_val;
};
+
+
+
+#ifndef BOOST_LOG_NO_TSS
+
/**
Locks a resource, and uses TLS. This holds the value, and each thread caches it.
Once at a given period (like, every 5 seconds), when used, the latest object is copied.
@sa locker
+ @sa default_cache_millis how many secs to cache the data. By default, 5
*/
- template<class type> struct tls_resource_with_cache {
+ template<class type, int default_cache_secs = 5> struct tss_resource_with_cache {
// FIXME - implement using TLS!!!
+// I NEED TO CREATE TESTS FOR tss_value / tss_resource_with_cache
- typedef tls_resource_with_cache<type> self_type;
-
- tls_resource_with_cache(const type& val , int /* cache_millis */ ) : m_val(val) {}
+ typedef tss_resource_with_cache<type, default_cache_secs> self_type;
+ private:
+ struct value_and_time {
+ value_and_time(const type & val = type() ) : val(val) {
+ time_ = time(0);
+ }
+ type val;
+ time_t time_;
+ };
public:
+ tss_resource_with_cache(const type& val , int cache_secs = default_cache_secs ) : m_val(val), m_cache_secs(cache_secs) {}
+
struct read;
struct write;
friend struct read;
@@ -148,9 +165,12 @@
private:
+ int m_cache_secs;
+ tss_value<value_and_time> m_cache;
type m_val;
};
+#endif
}}}
Added: sandbox/logging/boost/logging/detail/tss/tss.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/detail/tss/tss.hpp 2007-11-02 08:38:08 EDT (Fri, 02 Nov 2007)
@@ -0,0 +1,81 @@
+// tss.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_tss_HPP_DEFINED
+#define JT28092007_tss_HPP_DEFINED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+// not tested yet
+#define BOOST_LOG_NO_TSS
+
+
+
+#if !defined(BOOST_LOG_NO_TSS)
+
+#include <boost/logging/detail/fwd.hpp>
+#include <boost/logging/macros.hpp>
+
+#if defined(BOOST_LOG_TSS_USE_INTERNAL)
+// use internal implementation
+#include <boost/logging/detail/tss/tss_impl.hpp>
+#define BOOST_LOG_TSS_DEFAULT_CLASS = ::boost::logging::thread_specific_ptr
+
+#elif defined(BOOST_LOG_TSS_USE_BOOST)
+// use the boost implementation
+#include <boost/thread/tss.hpp>
+#define BOOST_LOG_TSS_DEFAULT_CLASS = ::boost::thread_specific_ptr
+
+#else
+
+// in case the user specified a custom class, maybe he specified its name as well
+#define BOOST_LOG_TSS_DEFAULT_CLASS BOOST_LOG_TSS_USE_CUSTOM
+#endif
+
+namespace boost { namespace logging {
+
+template<class type, template<typename> class thread_specific_ptr_type BOOST_LOG_TSS_DEFAULT_CLASS > struct tss_value {
+ tss_value(const type & default_ = type() ) : m_default( default_) {}
+
+ type * get() const {
+ type * result = m_value.get();
+ if ( !result) {
+#if defined(BOOST_LOG_TSS_USE_INTERNAL)
+ result = detail::new_object_ensure_delete<type>(m_default);
+#else
+ result = new type(m_default);
+#endif
+ m_value.set( result );
+ }
+ return result;
+ }
+
+ type* operator->() const { return get(); }
+ type& operator*() const { return *get(); }
+private:
+ thread_specific_ptr_type<type> m_value;
+ // the default value - to assign each time a new value is created
+ type m_default;
+};
+
+}}
+
+#endif // !BOOST_LOG_NO_TSS
+
+#endif
+
Added: sandbox/logging/boost/logging/detail/tss/tss_ensure_proper_delete.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/detail/tss/tss_ensure_proper_delete.hpp 2007-11-02 08:38:08 EDT (Fri, 02 Nov 2007)
@@ -0,0 +1,66 @@
+// tss_ensure_proper_delete.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_tss_ensure_proper_delete_HPP_DEFINED
+#define JT28092007_tss_ensure_proper_delete_HPP_DEFINED
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+# pragma once
+#endif
+
+#include <boost/logging/detail/fwd.hpp>
+#include <vector>
+
+namespace boost { namespace logging { namespace detail {
+
+struct do_delete_base {
+ virtual ~do_delete_base () {}
+};
+
+template<class type> struct do_delete : do_delete_base {
+ do_delete(type * val) : m_val(val) {}
+ ~do_delete() { delete m_val; }
+ type * m_val;
+};
+
+struct delete_array : std::vector< do_delete_base* > {
+ ~delete_array () {
+ for ( const_iterator b = begin(), e = end(); b != e; ++b)
+ delete *b;
+ }
+};
+
+inline delete_array & object_deleter() {
+ static delete_array a;
+ return a;
+}
+
+template<class type> inline type * new_object_ensure_delete() {
+ type * val = new type;
+ object_deleter().push_back( new do_delete<type>(val) );
+ return val;
+}
+
+template<class type> inline type * new_object_ensure_delete(const type & init) {
+ type * val = new type(init);
+ object_deleter().push_back( new do_delete<type>(val) );
+ return val;
+}
+
+}}}
+
+#endif
+
Added: sandbox/logging/boost/logging/detail/tss/tss_impl.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/detail/tss/tss_impl.hpp 2007-11-02 08:38:08 EDT (Fri, 02 Nov 2007)
@@ -0,0 +1,84 @@
+// Copyright (C) 2001-2003 William E. Kempf
+// Copyright (C) 2006 Roland Schwarz
+//
+// 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)
+
+// 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_BOOST_TSS_impl_WEK070601_HPP
+#define JT28092007_BOOST_TSS_impl_WEK070601_HPP
+
+#include <boost/config.hpp>
+#include <boost/utility.hpp>
+#include <boost/logging/detail/ts/ts.hpp>
+
+
+#define BOOST_LOG_TSS_SLOTS_SIZE 128
+
+namespace boost { namespace logging {
+
+
+namespace detail {
+
+class tss : private noncopyable
+{
+public:
+ tss() ;
+
+ inline ~tss();
+ inline void* get() const;
+ inline void set(void* value);
+
+private:
+ unsigned int m_slot; //This is a "pseudo-slot", not a native slot
+};
+
+}}}
+
+#include <boost/logging/detail/tss/tss_ensure_proper_delete.hpp>
+#if defined(BOOST_WINDOWS)
+#include <boost/logging/detail/tss/tss_impl_win32.hpp>
+#else
+#include <boost/logging/detail/tss/tss_impl_pthread.hpp>
+#endif
+
+
+namespace boost { namespace logging {
+
+template <typename T> class thread_specific_ptr : private noncopyable
+{
+ detail::tss m_tss;
+public:
+ thread_specific_ptr() {}
+ ~thread_specific_ptr() { reset(); }
+
+ T* get() const { return static_cast<T*>(m_tss.get()); }
+ T* operator->() const { return get(); }
+ T& operator*() const { return *get(); }
+ T* release() { T* temp = get(); if (temp) m_tss.set(0); return temp; }
+ void reset(T* p=0)
+ {
+ T* cur = get();
+ if (cur == p) return;
+ m_tss.set(p);
+ }
+
+};
+
+
+}}
+
+#endif
+
Added: sandbox/logging/boost/logging/detail/tss/tss_impl_pthread.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/detail/tss/tss_impl_pthread.hpp 2007-11-02 08:38:08 EDT (Fri, 02 Nov 2007)
@@ -0,0 +1,112 @@
+// Copyright (C) 2001-2003 William E. Kempf
+// Copyright (C) 2006 Roland Schwarz
+//
+// 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)
+
+// 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_BOOST_TSS_IMPL_PTHREAD
+#define JT28092007_BOOST_TSS_IMPL_PTHREAD
+
+#include <vector>
+#include <memory>
+#include <pthread.h>
+
+namespace boost { namespace logging { namespace detail {
+
+typedef std::vector<void*> tss_slots;
+
+inline pthread_key_t & tss_data_native_key() {
+ static pthread_key_t key;
+ return key;
+}
+
+inline tss_slots* get_slots()
+{
+ tss_slots* slots = 0;
+ slots = static_cast<tss_slots*>( pthread_getspecific(tss_data_native_key()));
+ if (slots == 0)
+ {
+ std::auto_ptr<tss_slots> temp( new_object_ensure_delete<tss_slots>() );
+ // pre-allocate a few elems, so that we'll be fast
+ temp->resize(BOOST_LOG_TSS_SLOTS_SIZE);
+
+ pthread_setspecific(tss_data_native_key(), temp.get());
+ slots = temp.release();
+ }
+
+ return slots;
+}
+
+extern "C" inline void cleanup_slots(void* p) {}
+
+inline void init_tss_data()
+{
+ pthread_key_create(&tss_data_native_key(), &cleanup_slots);
+}
+
+
+
+inline unsigned int slot_idx() {
+ typedef boost::logging::threading::mutex mutex;
+ static mutex cs;
+ static unsigned int idx = 0;
+
+ scoped_lock lk(cs);
+
+ // note: if the Logging Lib is used with TLS, I'm guaranteed this will be called before main(),
+ // and that this will work
+ if ( !idx)
+ init_tss_data();
+
+ ++idx;
+ return idx;
+}
+
+inline tss::~tss()
+{
+ boost::mutex::scoped_lock lock(*tss_data_mutex);
+ tss_data_dec_use(lock);
+}
+
+inline void* tss::get() const
+{
+ tss_slots* slots = get_slots();
+
+ if (!slots)
+ return 0;
+
+ if (m_slot >= slots->size())
+ return 0;
+
+ return (*slots)[m_slot];
+}
+
+inline void tss::set(void* value)
+{
+ tss_slots* slots = get_slots();
+
+ if (m_slot >= slots->size())
+ {
+ slots->resize(m_slot + 1);
+ }
+
+ (*slots)[m_slot] = value;
+}
+
+}}}
+
+
+#endif
Added: sandbox/logging/boost/logging/detail/tss/tss_impl_win32.hpp
==============================================================================
--- (empty file)
+++ sandbox/logging/boost/logging/detail/tss/tss_impl_win32.hpp 2007-11-02 08:38:08 EDT (Fri, 02 Nov 2007)
@@ -0,0 +1,138 @@
+// Copyright (C) 2001-2003 William E. Kempf
+// Copyright (C) 2006 Roland Schwarz
+//
+// 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)
+
+// 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_BOOST_TSS_IMPL_WIN32
+#define JT28092007_BOOST_TSS_IMPL_WIN32
+
+#include <vector>
+#include <memory>
+#include <boost/assert.hpp>
+
+# include <windef.h>
+
+#ifndef WINBASEAPI
+#define WINBASEAPI
+#endif
+
+#ifndef TLS_OUT_OF_INDEXES
+#define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
+#endif
+
+WINBASEAPI DWORD WINAPI TlsAlloc( VOID);
+WINBASEAPI LPVOID WINAPI TlsGetValue(DWORD dwTlsIndex);
+WINBASEAPI BOOL WINAPI TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue);
+
+
+namespace boost { namespace logging {
+
+namespace detail {
+
+
+typedef std::vector<void*> tss_slots;
+
+inline DWORD& tss_data_native_key () {
+ static DWORD key = TLS_OUT_OF_INDEXES;
+ return key;
+}
+
+// note: this should be called ONLY ONCE
+inline void init_tss_data()
+{
+ //Allocate tls slot
+
+ // if you get an assertion here, this function was called twice - should never happen!
+ BOOST_ASSERT( tss_data_native_key() == TLS_OUT_OF_INDEXES);
+ // now, allocate it
+ tss_data_native_key() = TlsAlloc();
+}
+
+inline unsigned long slot_idx() {
+ typedef boost::logging::threading::mutex mutex;
+ static mutex cs;
+ static unsigned int idx = 0;
+
+ mutex::scoped_lock lk(cs);
+
+ // note: if the Logging Lib is used with TLS, I'm guaranteed this will be called before main(),
+ // and that this will work
+ if ( !idx)
+ init_tss_data();
+
+ ++idx;
+ return idx;
+}
+
+
+
+inline tss_slots* get_slots()
+{
+ tss_slots* slots = 0;
+ slots = static_cast<tss_slots*>( TlsGetValue( tss_data_native_key() ));
+
+ if (slots == 0)
+ {
+ std::auto_ptr<tss_slots> temp( new_object_ensure_delete<tss_slots>() );
+ // pre-allocate a few elems, so that we'll be fast
+ temp->resize(BOOST_LOG_TSS_SLOTS_SIZE);
+
+ if (!TlsSetValue(tss_data_native_key(), temp.get()))
+ return 0;
+
+ slots = temp.release();
+ }
+
+ return slots;
+}
+
+inline tss::tss() : m_slot( slot_idx() )
+{
+}
+
+
+inline tss::~tss()
+{
+}
+
+inline void* tss::get() const
+{
+ tss_slots* slots = get_slots();
+
+ if (m_slot >= slots->size())
+ return 0;
+
+ return (*slots)[m_slot];
+}
+
+inline void tss::set(void* value)
+{
+ tss_slots* slots = get_slots();
+
+ if (m_slot >= slots->size())
+ {
+ slots->resize(m_slot + 1);
+ }
+
+ (*slots)[m_slot] = value;
+}
+
+
+}}}
+
+
+#endif
Modified: sandbox/logging/boost/logging/filter.hpp
==============================================================================
--- sandbox/logging/boost/logging/filter.hpp (original)
+++ sandbox/logging/boost/logging/filter.hpp 2007-11-02 08:38:08 EDT (Fri, 02 Nov 2007)
@@ -23,6 +23,7 @@
#include <boost/logging/detail/fwd.hpp>
#include <boost/logging/detail/forward_constructor.hpp>
+#include <boost/logging/detail/tss/tss.hpp>
namespace boost {
@@ -68,7 +69,7 @@
The filters defined by the library are:
- filter::no_ts
- filter::ts
- - filter::use_tls_with_cache
+ - filter::use_tss_with_cache
- filter::always_enabled
- filter::always_disabled
- filter::debug_enabled
@@ -153,6 +154,11 @@
mutable threading::mutex m_cs;
};
+
+
+
+#ifndef BOOST_LOG_NO_TSS
+
/**
Uses TLS (Thread Local Storage) to find out if a filter is enabled or not. It caches the current "is_enabled" on each thread.
Then, at a given period, it retrieves the real "is_enabled".
@@ -162,10 +168,10 @@
Another implementation can be done, which could be faster - where you retrieve the "is_enabled" each X calls on a given thread
(like, every 20 calls on a given thread)
*/
-struct use_tls_with_cache {
- typedef locker::tls_resource_with_cache<bool> data;
+struct use_tss_with_cache {
+ typedef locker::tss_resource_with_cache<bool> data;
- use_tls_with_cache(int cache_millis) : m_enabled(true, cache_millis) {}
+ use_tss_with_cache(int cache_millis) : m_enabled(true, cache_millis) {}
bool is_enabled() const {
data::read enabled(m_enabled);
return enabled.use();
@@ -178,6 +184,9 @@
data m_enabled;
};
+#endif // #ifndef BOOST_LOG_NO_TSS
+
+
} // namespace filter
Modified: sandbox/logging/boost/logging/format/destination/rolling_file.hpp
==============================================================================
--- sandbox/logging/boost/logging/format/destination/rolling_file.hpp (original)
+++ sandbox/logging/boost/logging/format/destination/rolling_file.hpp 2007-11-02 08:38:08 EDT (Fri, 02 Nov 2007)
@@ -64,7 +64,10 @@
namespace detail {
template<class convert_dest >
struct rolling_file_info {
- rolling_file_info (const std::string& name_prefix, rolling_file_settings flags ) : m_flags(flags), m_cur_idx(0) {
+
+ rolling_file_info (const std::string& name_prefix, rolling_file_settings flags )
+ // many thanks to Martin Bauer
+ : m_name_prefix(name_prefix), m_flags(flags), m_cur_idx(0) {
namespace fs = boost::filesystem;
if ( m_flags.initial_erase()) {
Modified: sandbox/logging/boost/logging/level.hpp
==============================================================================
--- sandbox/logging/boost/logging/level.hpp (original)
+++ sandbox/logging/boost/logging/level.hpp 2007-11-02 08:38:08 EDT (Fri, 02 Nov 2007)
@@ -22,6 +22,7 @@
#endif
#include <boost/logging/detail/fwd.hpp>
+#include <boost/logging/detail/tss/tss.hpp>
namespace boost { namespace logging {
@@ -105,15 +106,31 @@
};
/**
+ @brief Filter - holds the level - and tells you at compile time if a filter is enabled or not.
+
+ Fix (compile time) holder
+ */
+ template<int fix_level = debug> struct holder_compile_time {
+ static bool is_enabled(type level) {
+ return fix_level >= level;
+ }
+ };
+
+
+
+
+#ifndef BOOST_LOG_NO_TSS
+
+ /**
@brief Filter - holds the level, in a thread-safe way, using TLS.
Uses TLS (Thread Local Storage) to find out if a level is enabled or not. It caches the current "is_enabled" on each thread.
Then, at a given period, it retrieves the real "level".
*/
- struct holder_tls_with_cache {
- typedef locker::tls_resource_with_cache<type> data;
+ struct holder_tss_with_cache {
+ typedef locker::tss_resource_with_cache<type> data;
- holder_tls_with_cache(int cache_millis, type default_level = enable_all) : m_level(default_level, cache_millis) {}
+ holder_tss_with_cache(int cache_millis, type default_level = enable_all) : m_level(default_level, cache_millis) {}
bool is_enabled(type test_level) const {
data::read cur_level(m_level);
return test_level >= cur_level.use();
@@ -126,16 +143,9 @@
data m_level;
};
- /**
- @brief Filter - holds the level - and tells you at compile time if a filter is enabled or not.
+#endif
+
- Fix (compile time) holder
- */
- template<int fix_level = debug> struct holder_compile_time {
- static bool is_enabled(type level) {
- return fix_level >= level;
- }
- };
typedef boost::logging::level_holder_type holder;
} // namespace level
@@ -171,7 +181,7 @@
@endcode
- @sa level::holder_no_ts, level::holder_ts, level::holder_tls_with_cache
+ @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) {}
Modified: sandbox/logging/boost/logging/macros.hpp
==============================================================================
--- sandbox/logging/boost/logging/macros.hpp (original)
+++ sandbox/logging/boost/logging/macros.hpp 2007-11-02 08:38:08 EDT (Fri, 02 Nov 2007)
@@ -59,6 +59,11 @@
- BOOST_LOG_COMPILE_FAST_OFF
- BOOST_LOG_COMPILE_FAST
+BOOST_LOG_TSS_USE_INTERNAL
+BOOST_LOG_TSS_USE_BOOST
+BOOST_LOG_TSS_USE_CUSTOM
+BOOST_LOG_NO_TSS
+
*/
#ifdef BOOST_LOG_COMPILE_FAST_ON
@@ -73,8 +78,11 @@
+#if !defined(BOOST_LOG_TSS_USE_INTERNAL) && !defined(BOOST_LOG_TSS_USE_BOOST) && !defined(BOOST_LOG_TSS_USE_CUSTOM) && !defined(BOOST_LOG_NO_TSS)
+// use has not specified what TSS strategy to use
+#define BOOST_LOG_TSS_USE_INTERNAL
-
+#endif
@@ -92,23 +100,23 @@
#define BOOST_DEFINE_LOG(name,type) type& name ## _boost_log_impl_() \
{ static type i; return i; } \
- namespace { boost::logging::detail::fake_using_log ensure_log_is_created_before_main ## name ( name ## _boost_log_impl_() ); } \
- boost::logging::detail::log_keeper<type, name ## _boost_log_impl_, ::boost::logging::detail::fast_compile_with_default_gather<>::log_type, name ## _boost_log_impl_light_ > name; \
::boost::logging::detail::fast_compile_with_default_gather<>::log_type & name ## _boost_log_impl_light_() \
{ typedef ::boost::logging::detail::fast_compile_with_default_gather<>::gather_msg gather_msg; \
typedef type::write_type write_msg; \
static ::boost::logging::implement_default_logger< gather_msg, write_msg* > p( &(name ## _boost_log_impl_().writer()) ); \
- return p; }
+ return p; } \
+ namespace { boost::logging::detail::fake_using_log ensure_log_is_created_before_main ## name ( name ## _boost_log_impl_() ); } \
+ boost::logging::detail::log_keeper<type, name ## _boost_log_impl_, ::boost::logging::detail::fast_compile_with_default_gather<>::log_type, name ## _boost_log_impl_light_ > name;
#define BOOST_DEFINE_LOG_WITH_ARGS(name,type, args) type& name ## _boost_log_impl_() \
{ static type i ( args ); return i; } \
- namespace { boost::logging::detail::fake_using_log ensure_log_is_created_before_main ## name ( name ## _boost_log_impl_() ); } \
- boost::logging::detail::log_keeper<type, name ## _boost_log_impl_, ::boost::logging::detail::fast_compile_with_default_gather<>::log_type, name ## _boost_log_impl_light_ > name; \
::boost::logging::detail::fast_compile_with_default_gather<>::log_type & name ## _boost_log_impl_light_() \
{ typedef ::boost::logging::detail::fast_compile_with_default_gather<>::gather_msg gather_msg; \
typedef type::write_type write_msg; \
static ::boost::logging::implement_default_logger< gather_msg, write_msg* > p( &(name ## _boost_log_impl_().writer()) ); \
- return p; }
+ return p; } \
+ namespace { boost::logging::detail::fake_using_log ensure_log_is_created_before_main ## name ( name ## _boost_log_impl_() ); } \
+ boost::logging::detail::log_keeper<type, name ## _boost_log_impl_, ::boost::logging::detail::fast_compile_with_default_gather<>::log_type, name ## _boost_log_impl_light_ > name;
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-02 08:38:08 EDT (Fri, 02 Nov 2007)
@@ -640,27 +640,27 @@
Name="ts"
>
<File
- RelativePath="..\..\..\..\..\boost\logging\ts\ts.hpp"
+ RelativePath="..\..\..\..\..\boost\logging\detail\ts\ts.hpp"
>
</File>
<File
- RelativePath="..\..\..\..\..\boost\logging\ts\ts_boost.hpp"
+ RelativePath="..\..\..\..\..\boost\logging\detail\ts\ts_boost.hpp"
>
</File>
<File
- RelativePath="..\..\..\..\..\boost\logging\ts\ts_none.hpp"
+ RelativePath="..\..\..\..\..\boost\logging\detail\ts\ts_none.hpp"
>
</File>
<File
- RelativePath="..\..\..\..\..\boost\logging\ts\ts_posix.hpp"
+ RelativePath="..\..\..\..\..\boost\logging\detail\ts\ts_posix.hpp"
>
</File>
<File
- RelativePath="..\..\..\..\..\boost\logging\ts\ts_resource.hpp"
+ RelativePath="..\..\..\..\..\boost\logging\detail\ts\ts_resource.hpp"
>
</File>
<File
- RelativePath="..\..\..\..\..\boost\logging\ts\ts_win32.hpp"
+ RelativePath="..\..\..\..\..\boost\logging\detail\ts\ts_win32.hpp"
>
</File>
</Filter>
@@ -772,6 +772,30 @@
>
</File>
</Filter>
+ <Filter
+ Name="tss"
+ >
+ <File
+ RelativePath="..\..\..\..\..\boost\logging\detail\tss\tss.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\boost\logging\detail\tss\tss_ensure_proper_delete.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\boost\logging\detail\tss\tss_impl.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\boost\logging\detail\tss\tss_impl_pthread.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\..\boost\logging\detail\tss\tss_impl_win32.hpp"
+ >
+ </File>
+ </Filter>
</Filter>
<Filter
Name="internal docs"
Modified: sandbox/logging/lib/logging/samples/scenarios/custom_fmt_dest.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/custom_fmt_dest.cpp (original)
+++ sandbox/logging/lib/logging/samples/scenarios/custom_fmt_dest.cpp 2007-11-02 08:38:08 EDT (Fri, 02 Nov 2007)
@@ -75,7 +75,7 @@
-#define BOOST_LOG_COMPILE_FAST_OFF
+#define BOOST_LOG_COMPILE_FAST_ON
#include <boost/logging/format_fwd.hpp>
// Step 1: Optimize : use a cache string, to make formatting the message faster
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