diff --git a/Utils/Logger/AreaRegistry.test.cc b/Utils/Logger/AreaRegistry.test.cc index f451098006a820a0df087f8a24fcd2ce7c026278..c17dbf32d4a09db4869440744333012493f6cb76 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 0429267f40ada9b1a24ea8d1bfd83a1e341d2e54..70e9131323ee685f850355de1d0c897ad5796ccf 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 c373a0f1a6dd1c20b5c0b91c89467ef2db4ba980..f5e3a6faa73208d3952b35da97080ceeb58cb5f1 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 3e0b61ee8a34655dde808a55a88ad604af4685b2..1df363193778ff22b7a004eb682fedae4980fbc4 100644 --- a/Utils/Logger/IOStreamTarget.hh +++ b/Utils/Logger/IOStreamTarget.hh @@ -43,6 +43,8 @@ namespace log { <pre> <date> [<area>] <message> </pre> + + 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 76168437f867e98946ea736241f710aac107fb1c..9051f9f3c22f46d11642da55dff3454a31561f08 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. + <dl><dt>VERBOSE</dt><dd>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.</dd> - \c NONE is used to in some special places to inherit the default log level. + <dt>NOTICE</dt><dd>Arbitrary unimportant notice. Message which normally should be disabled + but might be informative to better understand the programs operation.</dd> + + <dt>MESSAGE</dt><dd>Purely informative message which should be displayed if not explicitly + disabled.</dd> + + <dt>IMPORTANT</dt><dd>Important information or warning which really should be read.</dd> + + <dt>CRITICAL</dt><dd>Error condition which does not terminate the program completely but has + non-reversible adverse effects</dd> + + <dt>FATAL</dt><dd>Error condition which does terminate program execution or enforces a + restart or some kind of re-initialization with loss of state and context.</dd></dl> + + There are also some special values which <em>must not be used as a log level</em>: + + <dl><dt>DISABLED</dt><dd>Disable all log messages.</dd> + + <dt>NONE</dt><dd>Special value which signifies inheritance of the default log + level.</dd></dl> + + 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 bc1d2204b7bc17ae677a0aaa90b08b9f2bbf41cf..d7a7e898ac224a105028a3fef95b6929342457ed 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 5b8dd1b9ddb9a3dec3f4a94486c910bc22361df2..02226ca8901fee320d907e72b9b02b9aed20e503 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 270852cf97481ab8ba56468b64189c49d0dd8d42..09b0edba9cc095f7be6946daa7625996db761ba9 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", };