From: g0dil Date: Thu, 1 Nov 2007 10:19:27 +0000 (+0000) Subject: Utils/Logger: Fix 'senf::log::DefaultArea as empty-string' ambiguity X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=012a592d56be453719b7fbba492b56ae804c048f;p=senf.git Utils/Logger: Fix 'senf::log::DefaultArea as empty-string' ambiguity git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@489 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Utils/Logger/AreaRegistry.test.cc b/Utils/Logger/AreaRegistry.test.cc index f451098..c17dbf3 100644 --- a/Utils/Logger/AreaRegistry.test.cc +++ b/Utils/Logger/AreaRegistry.test.cc @@ -37,7 +37,9 @@ BOOST_AUTO_UNIT_TEST(areaRegistry) { - char const * areas[] = { "", "senf::log::test::Foo", "senf::log::test::myArea" }; + char const * areas[] = { "senf::log::DefaultArea", + "senf::log::test::Foo", + "senf::log::test::myArea" }; BOOST_CHECK_EQUAL_COLLECTIONS( senf::log::AreaRegistry::instance().begin(), senf::log::AreaRegistry::instance().end(), diff --git a/Utils/Logger/Definitions.hh b/Utils/Logger/Definitions.hh index 0429267..70e9131 100644 --- a/Utils/Logger/Definitions.hh +++ b/Utils/Logger/Definitions.hh @@ -107,12 +107,11 @@ namespace log { }; \ } - /** \brief Default global log stream */ - SENF_LOG_DEF_STREAM(Debug, MESSAGE, MESSAGE, MESSAGE); + /** \brief Default global log stream */ + SENF_LOG_DEF_STREAM(Debug, MESSAGE, MESSAGE, MESSAGE); - /** \brief Default global log area */ - SENF_LOG_DEF_AREA_I(DefaultArea, - std::string v_name() const { return ""; }); + /** \brief Default global log area */ + SENF_LOG_DEF_AREA(DefaultArea); ///\} ///\} diff --git a/Utils/Logger/IOStreamTarget.cc b/Utils/Logger/IOStreamTarget.cc index c373a0f..f5e3a6f 100644 --- a/Utils/Logger/IOStreamTarget.cc +++ b/Utils/Logger/IOStreamTarget.cc @@ -68,7 +68,7 @@ prefix_ void senf::log::IOStreamTarget::v_write(boost::posix_time::ptime timesta for (; i != i_end; ++i) { stream_ << timestamp << sep; - if (! area.empty()) + if (area != "senf::log::DefaultArea") stream_ << "[" << area << "] "; stream_ << *i << "\n"; sep = '-'; diff --git a/Utils/Logger/IOStreamTarget.hh b/Utils/Logger/IOStreamTarget.hh index 3e0b61e..1df3631 100644 --- a/Utils/Logger/IOStreamTarget.hh +++ b/Utils/Logger/IOStreamTarget.hh @@ -43,6 +43,8 @@ namespace log {
          [] 
         
+ + The \e area will be omitted it it is \c senf::log::DefaultArea. The date formatting is set using the Boost.DateTime date_facet, e.g.: \code diff --git a/Utils/Logger/Levels.hh b/Utils/Logger/Levels.hh index 7616843..9051f9f 100644 --- a/Utils/Logger/Levels.hh +++ b/Utils/Logger/Levels.hh @@ -39,9 +39,37 @@ namespace log { These are the valid log levels with some additional special values: - \c DISABLED is a special value used as level limit to disable all messages. +
VERBOSE
Really verbose log messages. Messages at this level are used for + internal debugging. They should be enabled only selectively within the areas currently under + inspection.
- \c NONE is used to in some special places to inherit the default log level. +
NOTICE
Arbitrary unimportant notice. Message which normally should be disabled + but might be informative to better understand the programs operation.
+ +
MESSAGE
Purely informative message which should be displayed if not explicitly + disabled.
+ +
IMPORTANT
Important information or warning which really should be read.
+ +
CRITICAL
Error condition which does not terminate the program completely but has + non-reversible adverse effects
+ +
FATAL
Error condition which does terminate program execution or enforces a + restart or some kind of re-initialization with loss of state and context.
+ + There are also some special values which must not be used as a log level: + +
DISABLED
Disable all log messages.
+ +
NONE
Special value which signifies inheritance of the default log + level.
+ + Log levels are classes, not numbers. Each log level class has a \c value member which gives + that levels numeric priority. The larger the number, the more important the message is. + + \implementation The log levels need to be classes since areas and streams are classes: Since + log arguments (stream, area and level) may appear in any order and number, it is much + simpler to parse them if they are all of the same type. */ ///\ingroup loglevels @@ -67,9 +95,13 @@ namespace log { \see loglevels */ struct CRITICAL : public detail::LevelBase { static unsigned const value = 5; }; + /** \brief Log level FATAL + \see loglevels */ + struct FATAL : public detail::LevelBase { static unsigned const value = 6; }; + /** \brief Disable logging \see loglevels */ - struct DISABLED : public detail::LevelBase { static unsigned const value = 6; }; + struct DISABLED : public detail::LevelBase { static unsigned const value = 7; }; /** \brief Inherit log level \see loglevels */ diff --git a/Utils/Logger/Mainpage.dox b/Utils/Logger/Mainpage.dox index bc1d220..d7a7e89 100644 --- a/Utils/Logger/Mainpage.dox +++ b/Utils/Logger/Mainpage.dox @@ -40,7 +40,7 @@ Log messages are arbitrarily created throughout the code using simple log statements (which are macros). Besides the log message itself, every log message is labeled with additional information: The \e stream, the \e area and a log \e level. If the message is not compile-time - disabled, the message is then directed to one of several log \e targets. + disabled, the message is then directed to one or several log \e targets. A \e stream combines log messages with a single purpose: Debug messages, access logging and so on. Any number of streams may be defined. There is one predefined default stream called \c @@ -48,7 +48,8 @@ The \e area gives information about the source location of the message. Areas may be defined and assigned arbitrarily but should be used to label messages from a single class or subsystem. It - is possible to reuse a class as it's own area tag, which is often desireable. (see: \ref + is possible to reuse a class as it's own area tag, which is often desireable. There is a + default area \c senf::log::DefaultArea which is used, when no other area is assigned. (see: \ref SENF_LOG_DEF_AREA, \ref SENF_LOG_CLASS_AREA) The log \e level gives information on the importance of the message. The list of log-levels is diff --git a/Utils/Logger/Target.hh b/Utils/Logger/Target.hh index 5b8dd1b..02226ca 100644 --- a/Utils/Logger/Target.hh +++ b/Utils/Logger/Target.hh @@ -379,9 +379,7 @@ namespace log { somehow format and write the log message. Every log message always possesses a complete set of - meta information (\a stream, \a area and \a level). The - \a area may be an empty string if the message was - written from the senf::log::DefaultArea. + meta information (\a stream, \a area and \a level). \note This member must \e not block since it may be called from any unknown context. This prohibits diff --git a/Utils/Logger/Target.test.cc b/Utils/Logger/Target.test.cc index 270852c..09b0edb 100644 --- a/Utils/Logger/Target.test.cc +++ b/Utils/Logger/Target.test.cc @@ -81,7 +81,7 @@ BOOST_AUTO_UNIT_TEST(target) "senf::log::Debug-senf::log::test::Foo-VERBOSE-REJECT", "senf::log::Debug--NONE-ACCEPT", "senf::log::test::myStream-senf::log::test::Foo-VERBOSE-ACCEPT", - "senf::log::test::myStream--NONE-REJECT", + "senf::log::test::myStream-senf::log::DefaultArea-NONE-REJECT", "senf::log::test::myStream--IMPORTANT-REJECT", };