|
Boost-Commit : |
From: john.groups_at_[hidden]
Date: 2008-02-03 12:37:14
Author: jtorjo
Date: 2008-02-03 12:37:13 EST (Sun, 03 Feb 2008)
New Revision: 43076
URL: http://svn.boost.org/trac/boost/changeset/43076
Log:
[logging]
making mul_levels_mul_logers.cpp simple - so that I can see what's the problem on linux (fedora8)
Text files modified:
sandbox/logging/lib/logging/internal/vc8/loggingvc8/test_now.cpp | 79 ----------------------------------------
sandbox/logging/lib/logging/samples/scenarios/mul_levels_mul_logers.cpp | 3 -
2 files changed, 0 insertions(+), 82 deletions(-)
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-03 12:37:13 EST (Sun, 03 Feb 2008)
@@ -1,74 +1,11 @@
-/**
-_at_example mul_levels_mul_logers.cpp
-
-_at_copydoc mul_levels_mul_logers
-
-_at_page mul_levels_mul_logers mul_levels_mul_logers.cpp Example
-
-
-This usage:
-- You have multiple levels (in this example: debug < info < error)
-- You want to format the message before it's written
- (in this example: prefix it by time, by index and append newline to it)
-- You have several loggers
-- Each logger has several log destinations
-
-Optimizations:
-- use a cache string (from optimize namespace), in order to make formatting the message faster
-
-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 "[app]", time, and append newline
-- Debug messages go to the debug output window, and a file called out.txt
- - formatting - prefix each message by "[dbg]", time, and append newline
-
-
-Here's how the output will look like:
-
-The debug output window:
-_at_code
-07:52.30 [dbg] this is so cool 1
-07:52.30 [dbg] this is so cool again 2
-_at_endcode
-
-
-The console:
-_at_code
-07:52.30 [app] hello, world
-07:52.30 [app] good to be back ;) 4
-_at_endcode
-
-
-The out.txt file:
-_at_code
-07:52.30 [dbg] this is so cool 1
-07:52.30 [dbg] this is so cool again 2
-07:52.30 [app] hello, world
-07:52.30 [app] good to be back ;) 4
-_at_endcode
-
-
-The err.txt file
-_at_code
-07:52.30 [1] first error 3
-07:52.30 [2] second error 5
-_at_endcode
-*/
-
#include <boost/logging/format/named_write.hpp>
typedef boost::logging::named_logger<>::type logger_type;
#define LDBG_ BOOST_LOG_USE_LOG_IF_LEVEL(g_log_dbg(), g_log_level(), debug ) << "[dbg] "
-#define LERR_ BOOST_LOG_USE_LOG_IF_LEVEL(g_log_err(), g_log_level(), error )
-#define LAPP_ BOOST_LOG_USE_LOG_IF_LEVEL(g_log_app(), g_log_level(), info ) << "[app] "
BOOST_DEFINE_LOG_FILTER(g_log_level, boost::logging::level::holder )
-BOOST_DEFINE_LOG(g_log_err, logger_type)
-BOOST_DEFINE_LOG(g_log_app, logger_type)
BOOST_DEFINE_LOG(g_log_dbg, logger_type)
using namespace boost::logging;
@@ -76,36 +13,20 @@
void mul_levels_mul_logers_example() {
// reuse the same destination for 2 logs
destination::file out("out.txt");
- g_log_app()->writer().replace_destination("file", out);
g_log_dbg()->writer().replace_destination("file", out);
// formatting (first param) and destinations (second param)
- g_log_err()->writer().write("[%idx%] %time%($hh:$mm.$ss) |\n", "file(err.txt)");
- g_log_app()->writer().write("%time%($hh:$mm.$ss) |\n", "file cout");
g_log_dbg()->writer().write("%time%($hh:$mm.$ss) |\n", "file cout debug");
-
- g_log_app()->mark_as_initialized();
- g_log_err()->mark_as_initialized();
g_log_dbg()->mark_as_initialized();
// Step 8: use it...
int i = 1;
LDBG_ << "this is so cool " << i++;
- LDBG_ << "this is so cool again " << i++;
- LERR_ << "first error " << i++;
-
- std::string hello = "hello", world = "world";
- LAPP_ << hello << ", " << world;
g_log_level()->set_enabled(level::error);
LDBG_ << "this will not be written anywhere";
- LAPP_ << "this won't be written anywhere either";
g_log_level()->set_enabled(level::info);
- LAPP_ << "good to be back ;) " << i++;
- LERR_ << "second error " << i++;
-
- // Step 9 : Enjoy!
}
Modified: sandbox/logging/lib/logging/samples/scenarios/mul_levels_mul_logers.cpp
==============================================================================
--- sandbox/logging/lib/logging/samples/scenarios/mul_levels_mul_logers.cpp (original)
+++ sandbox/logging/lib/logging/samples/scenarios/mul_levels_mul_logers.cpp 2008-02-03 12:37:13 EST (Sun, 03 Feb 2008)
@@ -88,7 +88,6 @@
g_log_dbg()->mark_as_initialized();
- // Step 8: use it...
int i = 1;
LDBG_ << "this is so cool " << i++;
LDBG_ << "this is so cool again " << i++;
@@ -104,8 +103,6 @@
g_log_level()->set_enabled(level::info);
LAPP_ << "good to be back ;) " << i++;
LERR_ << "second error " << i++;
-
- // Step 9 : Enjoy!
}
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