|
Boost-Commit : |
From: john.groups_at_[hidden]
Date: 2007-11-14 10:55:54
Author: jtorjo
Date: 2007-11-14 10:55:53 EST (Wed, 14 Nov 2007)
New Revision: 41092
URL: http://svn.boost.org/trac/boost/changeset/41092
Log:
[logging]
v0.11.12, 14 nov 2007
- solved bug when using append_newline_if_needed() - when not used with string
Text files modified:
sandbox/logging/boost/logging/detail/raw_doc/acknowledgments.hpp | 2 +-
sandbox/logging/boost/logging/detail/raw_doc/changelog.hpp | 3 ++-
sandbox/logging/boost/logging/format/formatter/convert_format.hpp | 37 ++++++++++++++++++++++++++++++++++++-
sandbox/logging/boost/logging/format/formatter/defaults.hpp | 6 +++---
sandbox/logging/lib/logging/samples/scenarios/one_loger_one_filter.cpp | 2 +-
sandbox/logging/lib/logging/tests/do_not_use/testfast.cpp | 14 +++++---------
6 files changed, 48 insertions(+), 16 deletions(-)
Modified: sandbox/logging/boost/logging/detail/raw_doc/acknowledgments.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/raw_doc/acknowledgments.hpp (original)
+++ sandbox/logging/boost/logging/detail/raw_doc/acknowledgments.hpp 2007-11-14 10:55:53 EST (Wed, 14 Nov 2007)
@@ -14,7 +14,7 @@
- Pavel Savara - for feedback about docs, thread-safety and gcc
- Jens Seidel - for helping me with issues with gcc (different versions), and extra feedback
- Martin Baeker - for testing my lib, and pointing out problems
-
+- Thomas Kreisel - for testing my lib in Linux, providing patches, finding possible problems in my lib
*/
}}
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-14 10:55:53 EST (Wed, 14 Nov 2007)
@@ -1,7 +1,8 @@
/**
@page page_changelog Changelog
-_at_section changelog_cur_ver Current Version: v0.11.11, 13 nov 2007
+@section changelog_cur_ver Current Version: v0.11.12, 14 nov 2007
+- solved bug when using append_newline_if_needed() - when not used with string
- solved bug at opening file for initial overwrite
- added destination::stream and test_log_output
- applied small patch from Jens Seidel - many thanks!
Modified: sandbox/logging/boost/logging/format/formatter/convert_format.hpp
==============================================================================
--- sandbox/logging/boost/logging/format/formatter/convert_format.hpp (original)
+++ sandbox/logging/boost/logging/format/formatter/convert_format.hpp 2007-11-14 10:55:53 EST (Wed, 14 Nov 2007)
@@ -63,10 +63,22 @@
typedef boost::logging::char_type char_type;
typedef std::basic_string<char_type> string_type;
+ inline const string_type & get_underlying_string(const string_type & str) { return str; }
+ template<class string> const string & get_underlying_string(const ::boost::logging::optimize::cache_string_one_str<string> & str) {
+ return str;
+ }
+ template<class string> const string & get_underlying_string(const ::boost::logging::optimize::cache_string_several_str<string> & str) {
+ return str;
+ }
+ template<class string, class p1, class p2, class p3, class p4, class p5, class p6, class p7, class p8, class p9, class p10> const string& get_underlying_string(const ::boost::logging::tag::holder<string,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10> & str) {
+ return str;
+ }
+
/**
Example : write_time
*/
namespace prepend {
+
inline void write(const char_type * src, string_type & dest ) {
const char_type * end = src;
for ( ; *end; ++end) {}
@@ -133,11 +145,18 @@
}
-
struct do_convert_format {
typedef std::basic_string<char_type> string_type;
struct prepend {
+ static inline const string_type & get_underlying_string(const string_type & str) { return convert::get_underlying_string(str); }
+ template<class string> static inline const string & get_underlying_string(const ::boost::logging::optimize::cache_string_several_str<string> & str) {
+ return convert::get_underlying_string(str);
+ }
+ template<class string, class p1, class p2, class p3, class p4, class p5, class p6, class p7, class p8, class p9, class p10> static inline const string& get_underlying_string(const ::boost::logging::tag::holder<string,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10> & str) {
+ return convert::get_underlying_string(str);
+ }
+
template<class src_type, class string> static void write(const src_type & src, string & dest) {
convert::prepend::write(src, dest);
}
@@ -147,6 +166,14 @@
};
struct append {
+ static inline const string_type & get_underlying_string(const string_type & str) { return convert::get_underlying_string(str); }
+ template<class string> static inline const string & get_underlying_string(const ::boost::logging::optimize::cache_string_several_str<string> & str) {
+ return convert::get_underlying_string(str);
+ }
+ template<class string, class p1, class p2, class p3, class p4, class p5, class p6, class p7, class p8, class p9, class p10> static inline const string& get_underlying_string(const ::boost::logging::tag::holder<string,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10> & str) {
+ return convert::get_underlying_string(str);
+ }
+
template<class src_type, class string> static void write(const src_type & src, string & dest) {
convert::append::write(src, dest);
}
@@ -156,6 +183,14 @@
};
struct modify {
+ static inline const string_type & get_underlying_string(const string_type & str) { return convert::get_underlying_string(str); }
+ template<class string> static inline const string & get_underlying_string(const ::boost::logging::optimize::cache_string_several_str<string> & str) {
+ return convert::get_underlying_string(str);
+ }
+ template<class string, class p1, class p2, class p3, class p4, class p5, class p6, class p7, class p8, class p9, class p10> static inline const string& get_underlying_string(const ::boost::logging::tag::holder<string,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10> & str ) {
+ return convert::get_underlying_string(str);
+ }
+
template<class src_type, class string> static void write(const src_type & src, string & dest) {
convert::modify::write(src, dest);
}
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 2007-11-14 10:55:53 EST (Wed, 14 Nov 2007)
@@ -72,7 +72,7 @@
*/
template<class convert = do_convert_format::append> struct append_newline_t : is_generic, boost::logging::op_equal::always_equal {
template<class msg_type> void operator()(msg_type & str) const {
- convert::write( (const char_type*)BOOST_LOG_STR("\n"), str );
+ convert::write( BOOST_LOG_STR("\n"), str );
}
};
@@ -86,8 +86,8 @@
template<class convert = do_convert_format::append> struct append_newline_if_needed_t : is_generic, boost::logging::op_equal::always_equal {
template<class msg_type> void operator()(msg_type & str) const {
bool is_needed = true;
- if ( !str.empty())
- if ( str[ str.size() - 1] == '\n')
+ if ( ! convert::get_underlying_string(str).empty())
+ if ( *(convert::get_underlying_string(str).rbegin()) == '\n')
is_needed = false;
if ( is_needed)
Modified: sandbox/logging/lib/logging/samples/scenarios/one_loger_one_filter.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/one_loger_one_filter.cpp (original)
+++ sandbox/logging/lib/logging/samples/scenarios/one_loger_one_filter.cpp 2007-11-14 10:55:53 EST (Wed, 14 Nov 2007)
@@ -81,7 +81,7 @@
// That is, how the message is to be formatted and where should it be written to
g_l->writer().add_formatter( formatter::idx() );
- g_l->writer().add_formatter( formatter::append_newline() );
+ g_l->writer().add_formatter( formatter::append_newline_if_needed() );
g_l->writer().add_destination( destination::file("out.txt") );
g_l->writer().add_destination( destination::cout() );
g_l->writer().add_destination( destination::dbg_window() );
Modified: sandbox/logging/lib/logging/tests/do_not_use/testfast.cpp
==============================================================================
--- sandbox/logging/lib/logging/tests/do_not_use/testfast.cpp (original)
+++ sandbox/logging/lib/logging/tests/do_not_use/testfast.cpp 2007-11-14 10:55:53 EST (Wed, 14 Nov 2007)
@@ -100,9 +100,9 @@
// filter does not use levels
filter_::level::no_levels,
// the logger is initialized once, when only one thread is running
- logger_::change::set_once_when_one_thread,
+ logger_::change::single_thread
// the logger favors speed (on a dedicated thread)
- logger_::favor::speed> finder;
+ > finder;
// Step 4: declare which filters and loggers you'll use (usually in a header file)
BOOST_DECLARE_LOG_FILTER(g_log_filter, finder::filter )
@@ -135,10 +135,6 @@
}
void your_scenario_example() {
- std::ofstream file;
- file.open("blah.txt", std::ios::trunc);
- file << "blabla" ;
- file.close();
// Step 7: add formatters and destinations
// That is, how the message is to be formatted and where should it be written to
@@ -151,20 +147,20 @@
// App log
g_log_app->writer().add_formatter( formatter::time("$hh:$mm.$ss ") );
- g_log_app->writer().add_formatter( formatter::append_newline() );
+ g_log_app->writer().add_formatter( formatter::append_newline_if_needed() );
// g_log_app->writer().add_destination( destination::file("out.txt", destination::file_settings().initial_overwrite(true) ) );
g_log_app->writer().add_destination( destination::file("out.txt") );
g_log_app->writer().add_destination( destination::cout() );
// Debug log
g_log_dbg->writer().add_formatter( formatter::time("$hh:$mm.$ss ") );
- g_log_dbg->writer().add_formatter( formatter::append_newline() );
+ g_log_dbg->writer().add_formatter( formatter::append_newline_if_needed() );
g_log_dbg->writer().add_destination( destination::dbg_window() );
g_log_dbg->writer().add_destination( destination::cout() );
// Step 8: use it...
int i = 1;
- LDBG_ << "this is so cool " << i++;
+ LDBG_ << "this is so cool " << i++ << "\n";
LDBG_ << "this is so cool again " << i++;
LERR_ << "first error " << i++;
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