summaryrefslogtreecommitdiff
path: root/boost/log
diff options
context:
space:
mode:
Diffstat (limited to 'boost/log')
-rw-r--r--boost/log/attributes/attribute_value_impl.hpp2
-rw-r--r--boost/log/detail/config.hpp18
-rw-r--r--boost/log/detail/light_rw_mutex.hpp2
-rw-r--r--boost/log/detail/threadsafe_queue.hpp7
-rw-r--r--boost/log/detail/timestamp.hpp5
-rw-r--r--boost/log/expressions/formatter.hpp14
-rw-r--r--boost/log/keywords/max_files.hpp40
-rw-r--r--boost/log/sinks/text_file_backend.hpp15
-rw-r--r--boost/log/utility/formatting_ostream.hpp35
-rw-r--r--boost/log/utility/once_block.hpp2
-rw-r--r--boost/log/utility/setup/file.hpp1
11 files changed, 122 insertions, 19 deletions
diff --git a/boost/log/attributes/attribute_value_impl.hpp b/boost/log/attributes/attribute_value_impl.hpp
index 50ba812271..b21091e58b 100644
--- a/boost/log/attributes/attribute_value_impl.hpp
+++ b/boost/log/attributes/attribute_value_impl.hpp
@@ -64,7 +64,7 @@ public:
/*!
* Constructor with initialization of the stored value
*/
- explicit attribute_value_impl(BOOST_RV_REF(value_type) v) : m_value(v) {}
+ explicit attribute_value_impl(BOOST_RV_REF(value_type) v) : m_value(boost::move(v)) {}
/*!
* Attribute value dispatching method.
diff --git a/boost/log/detail/config.hpp b/boost/log/detail/config.hpp
index 5ddfd403b6..ce9aeb2dc1 100644
--- a/boost/log/detail/config.hpp
+++ b/boost/log/detail/config.hpp
@@ -23,6 +23,13 @@
#define __MSVCRT_VERSION__ 0x0700
#endif
+#include <boost/predef/os.h>
+
+// Try including WinAPI config as soon as possible so that any other headers don't include Windows SDK headers
+#if defined(BOOST_OS_WINDOWS_AVAILABLE)
+#include <boost/detail/winapi/config.hpp>
+#endif
+
#include <limits.h> // To bring in libc macros
#include <boost/config.hpp>
@@ -31,10 +38,6 @@
# error Boost.Log: RTTI is required by the library
#endif
-#if defined(BOOST_WINDOWS)
-#include <boost/detail/winapi/config.hpp>
-#endif
-
#if defined(_MSC_VER) && _MSC_VER >= 1600
# define BOOST_LOG_HAS_PRAGMA_DETECT_MISMATCH
#endif
@@ -178,6 +181,13 @@
# define BOOST_LOG_NORETURN
#endif
+// GCC and compatible compilers may require marking types that may alias other types
+#if defined(__GNUC__)
+# define BOOST_LOG_MAY_ALIAS __attribute__ ((__may_alias__))
+#else
+# define BOOST_LOG_MAY_ALIAS
+#endif
+
#if !defined(BOOST_LOG_BUILDING_THE_LIB)
// Detect if we're dealing with dll
diff --git a/boost/log/detail/light_rw_mutex.hpp b/boost/log/detail/light_rw_mutex.hpp
index 1ecf700047..39762b3ed2 100644
--- a/boost/log/detail/light_rw_mutex.hpp
+++ b/boost/log/detail/light_rw_mutex.hpp
@@ -145,7 +145,7 @@ namespace aux {
//! A light read/write mutex
class light_rw_mutex
{
- struct { void* p; } m_Mutex;
+ struct BOOST_LOG_MAY_ALIAS mutex_state { void* p; } m_Mutex;
public:
BOOST_LOG_API light_rw_mutex();
diff --git a/boost/log/detail/threadsafe_queue.hpp b/boost/log/detail/threadsafe_queue.hpp
index b94fa4fe8e..2ab2172b13 100644
--- a/boost/log/detail/threadsafe_queue.hpp
+++ b/boost/log/detail/threadsafe_queue.hpp
@@ -43,12 +43,7 @@ namespace aux {
//! Base class for the thread-safe queue implementation
struct threadsafe_queue_impl
{
- struct
-#if defined(__GNUC__)
- // Explicitly mark the type so that it may alias other types
- __attribute__ ((__may_alias__))
-#endif
- pointer_storage
+ struct BOOST_LOG_MAY_ALIAS pointer_storage
{
union
{
diff --git a/boost/log/detail/timestamp.hpp b/boost/log/detail/timestamp.hpp
index 3f55ac238e..95c1f0a945 100644
--- a/boost/log/detail/timestamp.hpp
+++ b/boost/log/detail/timestamp.hpp
@@ -18,6 +18,9 @@
#include <boost/cstdint.hpp>
#include <boost/log/detail/config.hpp>
+#if defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
+#include <boost/detail/winapi/basic_types.hpp>
+#endif
#include <boost/log/detail/header.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
@@ -73,7 +76,7 @@ public:
*/
#if defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
-typedef uint64_t (__stdcall* get_tick_count_t)();
+typedef uint64_t (WINAPI* get_tick_count_t)();
extern BOOST_LOG_API get_tick_count_t get_tick_count;
inline timestamp get_timestamp()
diff --git a/boost/log/expressions/formatter.hpp b/boost/log/expressions/formatter.hpp
index 5dc6a5b132..bdbabb504e 100644
--- a/boost/log/expressions/formatter.hpp
+++ b/boost/log/expressions/formatter.hpp
@@ -128,6 +128,16 @@ public:
strm << static_cast< T&& >(val);
return strm;
}
+#if defined(BOOST_MSVC) && BOOST_MSVC < 1800
+ // MSVC 10 and 11 generate broken code for the perfect forwarding version above if T is an array type (e.g. a string literal)
+ template< typename T, unsigned int N >
+ BOOST_FORCEINLINE StreamT& operator<< (T (&val)[N]) const
+ {
+ StreamT& strm = this->get();
+ strm << val;
+ return strm;
+ }
+#endif
#else
template< typename T >
BOOST_FORCEINLINE StreamT& operator<< (T& val) const
@@ -364,13 +374,13 @@ public:
basic_formatter(FunT&& fun) : m_Formatter(boost::forward< FunT >(fun))
{
}
-#elif !defined(BOOST_MSVC) || BOOST_MSVC > 1400
+#elif !defined(BOOST_MSVC) || BOOST_MSVC >= 1600
template< typename FunT >
basic_formatter(FunT const& fun, typename disable_if_c< move_detail::is_rv< FunT >::value, int >::type = 0) : m_Formatter(fun)
{
}
#else
- // MSVC 8 blows up in unexpected ways if we use SFINAE to disable constructor instantiation
+ // MSVC 9 blows up in unexpected ways if we use SFINAE to disable constructor instantiation
template< typename FunT >
basic_formatter(FunT const& fun) : m_Formatter(fun)
{
diff --git a/boost/log/keywords/max_files.hpp b/boost/log/keywords/max_files.hpp
new file mode 100644
index 0000000000..5d898e31e8
--- /dev/null
+++ b/boost/log/keywords/max_files.hpp
@@ -0,0 +1,40 @@
+/*
+ * Copyright Andrey Semashev 2007 - 2015.
+ * 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)
+ */
+/*!
+ * \file keywords/max_files.hpp
+ * \author Erich Keane
+ * \date 29.12.2015
+ *
+ * The header contains the \c max_files keyword declaration.
+ */
+
+#ifndef BOOST_LOG_KEYWORDS_MAX_FILES_HPP_INCLUDED_
+#define BOOST_LOG_KEYWORDS_MAX_FILES_HPP_INCLUDED_
+
+#include <boost/parameter/keyword.hpp>
+#include <boost/log/detail/config.hpp>
+
+#ifdef BOOST_HAS_PRAGMA_ONCE
+#pragma once
+#endif
+
+namespace boost {
+
+BOOST_LOG_OPEN_NAMESPACE
+
+namespace keywords {
+
+//! The keyword allows to specify maximum total number of log files
+BOOST_PARAMETER_KEYWORD(tag, max_files)
+
+} // namespace keywords
+
+BOOST_LOG_CLOSE_NAMESPACE // namespace log
+
+} // namespace boost
+
+#endif // BOOST_LOG_KEYWORDS_MAX_FILES_HPP_INCLUDED_
diff --git a/boost/log/sinks/text_file_backend.hpp b/boost/log/sinks/text_file_backend.hpp
index 7fe6df80ad..68f698848f 100644
--- a/boost/log/sinks/text_file_backend.hpp
+++ b/boost/log/sinks/text_file_backend.hpp
@@ -27,6 +27,7 @@
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/log/keywords/max_size.hpp>
+#include <boost/log/keywords/max_files.hpp>
#include <boost/log/keywords/min_free_space.hpp>
#include <boost/log/keywords/target.hpp>
#include <boost/log/keywords/file_name.hpp>
@@ -129,7 +130,8 @@ namespace aux {
BOOST_LOG_API shared_ptr< collector > make_collector(
filesystem::path const& target_dir,
uintmax_t max_size,
- uintmax_t min_free_space
+ uintmax_t min_free_space,
+ uintmax_t max_files = (std::numeric_limits< uintmax_t >::max)()
);
template< typename ArgsT >
inline shared_ptr< collector > make_collector(ArgsT const& args)
@@ -137,7 +139,8 @@ namespace aux {
return aux::make_collector(
filesystem::path(args[keywords::target]),
args[keywords::max_size | (std::numeric_limits< uintmax_t >::max)()],
- args[keywords::min_free_space | static_cast< uintmax_t >(0)]);
+ args[keywords::min_free_space | static_cast< uintmax_t >(0)],
+ args[keywords::max_files | (std::numeric_limits< uintmax_t >::max)()]);
}
} // namespace aux
@@ -159,6 +162,11 @@ inline shared_ptr< collector > make_collector(T1 const& a1, T2 const& a2, T3 con
{
return aux::make_collector((a1, a2, a3));
}
+template< typename T1, typename T2, typename T3, typename T4 >
+inline shared_ptr< collector > make_collector(T1 const& a1, T2 const& a2, T3 const& a3, T4 const& a4)
+{
+ return aux::make_collector((a1, a2, a3, a4));
+}
#else
@@ -190,6 +198,9 @@ inline shared_ptr< collector > make_collector(T1 const& a1, T2 const& a2, T3 con
* the collector tries to maintain. If the threshold is exceeded, the oldest
* file(s) is deleted to free space. The threshold is not maintained, if not
* specified.
+ * \li \c max_files - Specifies the maximum number of log files stored. If the number of files exceeds
+ * this threshold, the oldest file(s) is deleted to free space. The threshhold is
+ * not maintained if not specified.
*
* \return The file collector.
*/
diff --git a/boost/log/utility/formatting_ostream.hpp b/boost/log/utility/formatting_ostream.hpp
index 4d57ac4e32..d3732d36f4 100644
--- a/boost/log/utility/formatting_ostream.hpp
+++ b/boost/log/utility/formatting_ostream.hpp
@@ -21,6 +21,7 @@
#include <locale>
#include <boost/core/explicit_operator_bool.hpp>
#include <boost/utility/string_ref_fwd.hpp>
+#include <boost/utility/string_view_fwd.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/log/detail/config.hpp>
#include <boost/log/detail/attachable_sstream_buf.hpp>
@@ -404,7 +405,7 @@ public:
}
// When no native character type is supported, the following overloads are disabled as they have ambiguous meaning.
- // Use basic_string_ref, basic_string_view or basic_string to explicitly indicate that the data is a string.
+ // Use basic_string_view or basic_string to explicitly indicate that the data is a string.
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
basic_formatting_ostream& operator<< (wchar_t c)
{
@@ -540,6 +541,14 @@ public:
template< typename OtherCharT, typename OtherTraitsT >
friend typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type
+ operator<< (basic_formatting_ostream& strm, basic_string_view< OtherCharT, OtherTraitsT > const& str)
+ {
+ return strm.formatted_write(str.data(), static_cast< std::streamsize >(str.size()));
+ }
+
+ // Deprecated overload
+ template< typename OtherCharT, typename OtherTraitsT >
+ friend typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type
operator<< (basic_formatting_ostream& strm, basic_string_ref< OtherCharT, OtherTraitsT > const& str)
{
return strm.formatted_write(str.data(), static_cast< std::streamsize >(str.size()));
@@ -561,6 +570,14 @@ public:
template< typename OtherCharT, typename OtherTraitsT >
friend typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type
+ operator<< (basic_formatting_ostream& strm, basic_string_view< OtherCharT, OtherTraitsT >& str)
+ {
+ return strm.formatted_write(str.data(), static_cast< std::streamsize >(str.size()));
+ }
+
+ // Deprecated overload
+ template< typename OtherCharT, typename OtherTraitsT >
+ friend typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type
operator<< (basic_formatting_ostream& strm, basic_string_ref< OtherCharT, OtherTraitsT >& str)
{
return strm.formatted_write(str.data(), static_cast< std::streamsize >(str.size()));
@@ -583,6 +600,14 @@ public:
template< typename OtherCharT, typename OtherTraitsT >
friend typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type
+ operator<< (basic_formatting_ostream&& strm, basic_string_view< OtherCharT, OtherTraitsT > const& str)
+ {
+ return strm.formatted_write(str.data(), static_cast< std::streamsize >(str.size()));
+ }
+
+ // Deprecated overload
+ template< typename OtherCharT, typename OtherTraitsT >
+ friend typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type
operator<< (basic_formatting_ostream&& strm, basic_string_ref< OtherCharT, OtherTraitsT > const& str)
{
return strm.formatted_write(str.data(), static_cast< std::streamsize >(str.size()));
@@ -604,6 +629,14 @@ public:
template< typename OtherCharT, typename OtherTraitsT >
friend typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type
+ operator<< (basic_formatting_ostream&& strm, basic_string_view< OtherCharT, OtherTraitsT >& str)
+ {
+ return strm.formatted_write(str.data(), static_cast< std::streamsize >(str.size()));
+ }
+
+ // Deprecated overload
+ template< typename OtherCharT, typename OtherTraitsT >
+ friend typename aux::enable_if_streamable_char_type< OtherCharT, basic_formatting_ostream& >::type
operator<< (basic_formatting_ostream&& strm, basic_string_ref< OtherCharT, OtherTraitsT >& str)
{
return strm.formatted_write(str.data(), static_cast< std::streamsize >(str.size()));
diff --git a/boost/log/utility/once_block.hpp b/boost/log/utility/once_block.hpp
index 99bb5db082..40f2fff8c1 100644
--- a/boost/log/utility/once_block.hpp
+++ b/boost/log/utility/once_block.hpp
@@ -82,7 +82,7 @@ public:
~once_block_sentry() BOOST_NOEXCEPT
{
- if (m_flag.status != once_block_flag::initialized)
+ if (BOOST_UNLIKELY(m_flag.status != once_block_flag::initialized))
rollback();
}
diff --git a/boost/log/utility/setup/file.hpp b/boost/log/utility/setup/file.hpp
index 89c30c4607..e1b4280e9c 100644
--- a/boost/log/utility/setup/file.hpp
+++ b/boost/log/utility/setup/file.hpp
@@ -143,6 +143,7 @@ BOOST_PP_REPEAT_FROM_TO(1, BOOST_LOG_MAX_PARAMETER_ARGS, BOOST_LOG_INIT_LOG_TO_F
* \li \c target The target directory to store rotated files in. See <tt>sinks::file::make_collector</tt>.
* \li \c max_size The maximum total size of rotated files in the target directory. See <tt>sinks::file::make_collector</tt>.
* \li \c min_free_space Minimum free space in the target directory. See <tt>sinks::file::make_collector</tt>.
+ * \li \c max_files The maximum total number of rotated files in the target directory. See <tt>sinks::file::make_collector</tt>.
* \li \c scan_method The method of scanning the target directory for log files. See <tt>sinks::file::scan_method</tt>.
* \li \c filter Specifies a filter to install into the sink. May be a string that represents a filter,
* or a filter lambda expression.