// $Id$ // // Copyright (C) 2007 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) // Kompetenzzentrum fuer Satelitenkommunikation (SatCom) // Stefan Bund // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** \mainpage The SENF Logging library The Loggger infrastructure implements a highly flexible compile- and run-time configurable logging infrastructure supporting multiple streams, user definable log areas and fine grained log levels. Logging can be configured at compile and runtime on any combination of above parameters. The library supports a host of log targets and messages can be routed into multiple targets at the same time. To allow concise usage of the library, a utility to define logging defaults for any scope is provided. \see \ref logging \n \ref config \n \section logging_tutorial Tutorial introduction Using the logging library mostly concerns using \ref SENF_LOG statements in your code. There are some other helpers used to simplify specifying parameters. \code namespace foo { // Define a new log stream with default level, runtime limit and compile time limit // set to senf::log::MESSAGE SENF_LOG_DEF_STREAM( UserLog, senf::log::MESSAAGE, senf::log::MESSAGE, senf::log::MESSAGE ); class Froblizer { // Define a log area which will automatically be used by all members of this class. // This is a combination of SENF_LOG_DEF_AREA and SENF_LOG_DEFAULT_AREA. SENF_LOG_CLASS_AREA(); // Set default log parameters for this scope. The values here are not really // necessary since these are the global default values SENF_LOG_DEFAULT_STREAM(foo::UserLog); SENF_LOG_DEFAULT_LEVEL(senf::log::NOTICE); // Define an alias for emergency debug messages // The log area is inherited from the default at the place, where this // alias is used *not* where it is defined SENF_LOG_DEF_ALIAS(LogEmerg, (senf::log::Debug)(senf::log::CRITICAL)); void test(); public: void froblize(); }; } void foo::Froblizer::froblize() { SENF_LOG(("This is the UserLog at level NOTICE in the FroblizeArea")); SENF_LOG((senf::log::WARNING) ("Same stream and area but at warning level")); SENF_LOG((LogEmerg) ("This goes to the DebugLog at level CRITICAL in the FroblizerArea")); } void foo::Froblizer::test() { // Change the default log level for this method. stream and area are taken // from the next scope up SENF_LOG_DEFAULT_LEVEL(senf::log::VERBOSE); SENF_LOG(("Log to UserLog stream in Froblizer area however at VERBOSE level")); } \endcode \implementation I would have much preferred a more C++ like implementation. However given the design goals \li Flexible configuration at compile and runtime \li Concise usage and simple interface \li Zero overhead for compile-time disabled log messages I did not find any non-mcaro implementation which was not either completely convoluted, unusable or slow. So I turned to a macro based implementation which can provide all the design goals stated above. */ // Local Variables: // mode: c++ // fill-column: 100 // comment-column: 40 // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" // mode: flyspell // mode: auto-fill // End: