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(),
}; \
}
- /** \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);
///\}
///\}
for (; i != i_end; ++i) {
stream_ << timestamp << sep;
- if (! area.empty())
+ if (area != "senf::log::DefaultArea")
stream_ << "[" << area << "] ";
stream_ << *i << "\n";
sep = '-';
<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
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
\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 */
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
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
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
"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",
};