Boost logo

Boost-Commit :

From: john.groups_at_[hidden]
Date: 2008-02-01 15:19:33


Author: jtorjo
Date: 2008-02-01 15:19:32 EST (Fri, 01 Feb 2008)
New Revision: 43049
URL: http://svn.boost.org/trac/boost/changeset/43049

Log:
[logging]
added fast_start project

Added:
   sandbox/logging/lib/logging/samples/fast_start/
   sandbox/logging/lib/logging/samples/fast_start/no_levels.h (contents, props changed)
   sandbox/logging/lib/logging/samples/fast_start/use_levels.h (contents, props changed)
Properties modified:
   sandbox/logging/lib/logging/tests/test_on_ded_thread/ (props changed)
Text files modified:
   sandbox/logging/lib/logging/internal/vc8/loggingvc8/loggingvc8.vcproj | 8 +
   sandbox/logging/lib/logging/internal/vc8/loggingvc8/test_now.cpp | 176 ++++++---------------------------------
   sandbox/logging/lib/logging/samples/starter/my_app_log.cpp | 1
   3 files changed, 38 insertions(+), 147 deletions(-)

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 2008-02-01 15:19:32 EST (Fri, 01 Feb 2008)
@@ -758,10 +758,18 @@
>
                         </File>
                         <File
+ RelativePath="..\..\..\..\..\boost\logging\detail\raw_doc\getting_started.hpp"
+ >
+ </File>
+ <File
                                 RelativePath="..\..\..\..\..\boost\logging\detail\raw_doc\headers_to_include.hpp"
>
                         </File>
                         <File
+ RelativePath="..\..\..\..\..\boost\logging\detail\raw_doc\known_issues.hpp"
+ >
+ </File>
+ <File
                                 RelativePath="..\..\..\..\..\boost\logging\detail\raw_doc\main.hpp"
>
                         </File>

Modified: sandbox/logging/lib/logging/internal/vc8/loggingvc8/test_now.cpp
==============================================================================
--- sandbox/logging/lib/logging/internal/vc8/loggingvc8/test_now.cpp (original)
+++ sandbox/logging/lib/logging/internal/vc8/loggingvc8/test_now.cpp 2008-02-01 15:19:32 EST (Fri, 01 Feb 2008)
@@ -1,160 +1,42 @@
-/**
-_at_example mul_loggers_one_filter.cpp
+// my_app_log.h - DECLARE your loggers & filters here
+#ifndef my_app_LOG_H_header
+#define my_app_LOG_H_header
 
-_at_copydoc mul_loggers_one_filter
+#include <boost/logging/format/named_write_fwd.hpp>
+// #include <boost/logging/writer/on_dedicated_thread.hpp> // uncomment if you want to do logging on a dedicated thread
 
-_at_page mul_loggers_one_filter mul_loggers_one_filter.cpp Example
+namespace bl = boost::logging;
+typedef bl::named_logger<>::type logger_type;
+typedef bl::level::holder filter_type;
 
+BOOST_DECLARE_LOG_FILTER(g_l_level, filter_type)
+BOOST_DECLARE_LOG(g_l, logger_type)
 
-This usage:
-- You have several loggers
-- You have one filter, which can be turned on or off
-- You want to format the message before it's written
-- Each logger has several log destinations
+#define L_(lvl) BOOST_LOG_USE_LOG_IF_LEVEL(g_l(), g_l_level(), lvl )
 
-Optimizations:
-- use a cache string (from optimize namespace), in order to make formatting the message faster
+// initialize thy logs..
+void init_logs();
 
-Logs:
-- Error messages go into err.txt file
- - formatting - prefix each message by time, index, and append newline
-- Info output goes to console, and a file called out.txt
- - formatting - prefix each message by time, "[app]", and append newline
-- Debug messages go to the debug output window, and the console
- - formatting - prefix each message by "[dbg]", time, and append newline
-
-
-Here's how the output will look like:
-
-The debug output window:
-_at_code
-18:59.24 [dbg] this is so cool 1
-18:59.24 [dbg] this is so cool again 2
-_at_endcode
-
-
-The console:
-_at_code
-18:59.24 [dbg] this is so cool 1
-18:59.24 [dbg] this is so cool again 2
-18:59.24 [app] hello, world
-18:59.24 [app] good to be back ;) 4
-_at_endcode
-
-
-The out.txt file:
-_at_code
-18:59.24 [app] hello, world
-18:59.24 [app] good to be back ;) 4
-_at_endcode
-
-
-The err.txt file
-_at_code
-18:59.24 [1] first error 3
-18:59.24 [2] second error 5
-_at_endcode
-*/
-
-
-
-#include <boost/logging/format.hpp>
-
-#include <sstream>
-#include <string>
-BOOST_LOG_FORMAT_MSG( optimize::cache_string_one_str<> )
-
-using namespace boost::logging;
-
-typedef logger_format_write< > logger_type;
-
-BOOST_DECLARE_LOG_FILTER(g_log_filter, filter::no_ts )
-BOOST_DECLARE_LOG(g_log_err, logger_type)
-BOOST_DECLARE_LOG(g_log_app, logger_type)
-BOOST_DECLARE_LOG(g_log_dbg, logger_type)
-
-#define LDBG_ BOOST_LOG_USE_LOG_IF_FILTER(g_log_dbg(), g_log_filter()->is_enabled() ) << "[dbg] "
-#define LERR_ BOOST_LOG_USE_LOG_IF_FILTER(g_log_err(), g_log_filter()->is_enabled() )
-#define LAPP_ BOOST_LOG_USE_LOG_IF_FILTER(g_log_app(), g_log_filter()->is_enabled() ) << "[app] "
-
-BOOST_DEFINE_LOG_FILTER(g_log_filter, filter::no_ts )
-BOOST_DEFINE_LOG(g_log_err, logger_type)
-BOOST_DEFINE_LOG(g_log_app, logger_type)
-BOOST_DEFINE_LOG(g_log_dbg, logger_type)
-
-
-void f(int a, std::string str) {
-
- BOOST_SCOPED_LOG_CTX(LDBG_) << "func(" << a << ", str=" << str << ")";
-
-#if 0
- struct class_name : ::boost::logging::detail::scoped_gather_base<> {
- class_name() : m_is_enabled(false) { }
- ~class_name() { if ( m_is_enabled) LDBG_ << BOOST_LOG_STR(" end of ") << m_str ; }
- void do_gather(const msg_type & str) const { m_str = str; m_is_enabled = true; }
- mutable msg_type m_str;
- mutable bool m_is_enabled;
-} log_;
- LDBG_ , ::boost::logging::detail::scoped_logger<>(log_) << a << str_param;
 #endif
 
- LDBG_ << "testing";
-}
+// my_app_log.cpp - DEFINE your loggers & filters here
+//#include "my_app_log.h"
+#include <boost/logging/format/named_write.hpp>
+
+BOOST_DEFINE_LOG_FILTER(g_l_level, filter_type )
+BOOST_DEFINE_LOG(g_l, logger_type)
 
-void mul_logger_one_filter_example() {
- // Err log
- g_log_err()->writer().add_formatter( formatter::idx(), "[%] " );
- g_log_err()->writer().add_formatter( formatter::time("$hh:$mm.$ss ") );
- g_log_err()->writer().add_formatter( formatter::append_newline() );
- g_log_err()->writer().add_destination( destination::file("err.txt") );
-
- // 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_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_destination( destination::dbg_window() );
- g_log_dbg()->writer().add_destination( destination::cout() );
-
- g_log_app()->mark_as_initialized();
- g_log_err()->mark_as_initialized();
- g_log_dbg()->mark_as_initialized();
 
- int i = 1;
- LDBG_ << "this is so cool " << i++;
- LDBG_ << "this is so cool again " << i++;
- LERR_ << "first error " << i++;
-
- f(1, "str");
- g_log_filter()->set_enabled(false);
- f(2, "str2");
- g_log_filter()->set_enabled(true);
- f(3, "str3");
-
- std::string hello = "hello", world = "world";
- LAPP_ << hello << ", " << world;
-
- g_log_filter()->set_enabled(false);
- LDBG_ << "this will not be written anywhere";
- LAPP_ << "this won't be written anywhere either";
- LERR_ << "this error is not logged " << i++;
-
- g_log_filter()->set_enabled(true);
- LAPP_ << "good to be back ;) " << i++;
- LERR_ << "second error " << i++;
+void init_logs() {
+ // formatting : time [idx] message \n
+ // destinations : console, file "out.txt" and debug window
+ g_l()->writer().write("%time%($hh:$mm.$ss.$mili) [%idx%] |\n", "cout file(out.txt) debug");
+ g_l()->mark_as_initialized();
 }
 
-
-
-
-int main() {
- mul_logger_one_filter_example();
+void use_logger() {
+ int i = 1;
+ L_(debug) << "this is a simple message " << i;
+ std::string hello = "hello";
+ L_(info) << hello << " world";
 }
-
-
-// End of file
-

Added: sandbox/logging/lib/logging/samples/fast_start/no_levels.h
==============================================================================
--- (empty file)
+++ sandbox/logging/lib/logging/samples/fast_start/no_levels.h 2008-02-01 15:19:32 EST (Fri, 01 Feb 2008)
@@ -0,0 +1,42 @@
+// my_app_log.h - DECLARE your loggers & filters here
+#ifndef my_app_LOG_H_header
+#define my_app_LOG_H_header
+
+#include <boost/logging/format/named_write_fwd.hpp>
+// #include <boost/logging/writer/on_dedicated_thread.hpp> // uncomment if you want to do logging on a dedicated thread
+
+namespace bl = boost::logging;
+typedef bl::named_logger<>::type logger_type;
+typedef bl::filter::no_ts filter_type;
+
+BOOST_DECLARE_LOG_FILTER(g_l_filter, filter_type)
+BOOST_DECLARE_LOG(g_l, logger_type)
+
+#define L_ BOOST_LOG_USE_LOG_IF_FILTER( g_l(), g_log_filter()->is_enabled() )
+
+// initialize thy logs..
+void init_logs();
+
+#endif
+
+// my_app_log.cpp - DEFINE your loggers & filters here
+#include "my_app_log.h"
+#include <boost/logging/format/named_write.hpp>
+
+BOOST_DEFINE_LOG_FILTER(g_log_filter, filter_type )
+BOOST_DEFINE_LOG(g_l, logger_type)
+
+
+void init_logs() {
+ // formatting : time [idx] message \n
+ // destinations : console, file "out.txt" and debug window
+ g_l()->writer().write("%time%($hh:$mm.$ss.$mili) [%idx%] |\n", "cout file(out.txt) debug");
+ g_l()->mark_as_initialized();
+}
+
+void use_logger() {
+ int i = 1;
+ L_ << "this is a simple message " << i;
+ std::string hello = "hello";
+ L_ << hello << " world";
+}

Added: sandbox/logging/lib/logging/samples/fast_start/use_levels.h
==============================================================================
--- (empty file)
+++ sandbox/logging/lib/logging/samples/fast_start/use_levels.h 2008-02-01 15:19:32 EST (Fri, 01 Feb 2008)
@@ -0,0 +1,42 @@
+// my_app_log.h - DECLARE your loggers & filters here
+#ifndef my_app_LOG_H_header
+#define my_app_LOG_H_header
+
+#include <boost/logging/format/named_write_fwd.hpp>
+// #include <boost/logging/writer/on_dedicated_thread.hpp> // uncomment if you want to do logging on a dedicated thread
+
+namespace bl = boost::logging;
+typedef bl::named_logger<>::type logger_type;
+typedef bl::level::holder filter_type;
+
+BOOST_DECLARE_LOG_FILTER(g_l_level, filter_type)
+BOOST_DECLARE_LOG(g_l, logger_type)
+
+#define L_(lvl) BOOST_LOG_USE_LOG_IF_LEVEL(g_l(), g_l_level(), lvl )
+
+// initialize thy logs..
+void init_logs();
+
+#endif
+
+// my_app_log.cpp - DEFINE your loggers & filters here
+#include "my_app_log.h"
+#include <boost/logging/format/named_write.hpp>
+
+BOOST_DEFINE_LOG_FILTER(g_l_level, filter_type )
+BOOST_DEFINE_LOG(g_l, logger_type)
+
+
+void init_logs() {
+ // formatting : time [idx] message \n
+ // destinations : console, file "out.txt" and debug window
+ g_l()->writer().write("%time%($hh:$mm.$ss.$mili) [%idx%] |\n", "cout file(out.txt) debug");
+ g_l()->mark_as_initialized();
+}
+
+void use_logger() {
+ int i = 1;
+ L_(debug) << "this is a simple message " << i;
+ std::string hello = "hello";
+ L_(info) << hello << " world";
+}

Modified: sandbox/logging/lib/logging/samples/starter/my_app_log.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/starter/my_app_log.cpp (original)
+++ sandbox/logging/lib/logging/samples/starter/my_app_log.cpp 2008-02-01 15:19:32 EST (Fri, 01 Feb 2008)
@@ -24,4 +24,5 @@
     g_l()->writer().add_destination( destination::cout() );
     g_l()->writer().add_destination( destination::dbg_window() );
     g_l()->writer().add_destination( destination::file("out.txt") );
+ g_l()->mark_as_initialized();
 }


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