X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FLogger%2FIOStreamTarget.hh;h=aee7e3f3cd303a3b2c874894c68b08d95b8555ab;hb=adcd3672d48f44103f2b4abc6417acf5d0107978;hp=3e0b61ee8a34655dde808a55a88ad604af4685b2;hpb=044a1bfb46ce16c3daac307b8c684604b43dd4cf;p=senf.git diff --git a/Utils/Logger/IOStreamTarget.hh b/Utils/Logger/IOStreamTarget.hh index 3e0b61e..aee7e3f 100644 --- a/Utils/Logger/IOStreamTarget.hh +++ b/Utils/Logger/IOStreamTarget.hh @@ -1,8 +1,8 @@ // $Id$ // -// Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer NETwork research (NET) +// Copyright (C) 2007 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -23,8 +23,8 @@ /** \file \brief IOStreamTarget public header */ -#ifndef HH_IOStreamTarget_ -#define HH_IOStreamTarget_ 1 +#ifndef HH_SENF_Utils_Logger_IOStreamTarget_ +#define HH_SENF_Utils_Logger_IOStreamTarget_ 1 // Custom includes #include @@ -37,26 +37,15 @@ namespace senf { namespace log { - /** \brief Write log messages to arbitrary std::ostream + /** \brief Write %log messages to arbitrary std::ostream - This target will write log messages to an arbitrary std::ostream in the format -
-         [] 
-        
- - The date formatting is set using the Boost.DateTime date_facet, e.g.: - \code - stream.imbue( std::locale(stream.getloc(), - new boost::posix_time::time_facet("%Y%m%d %H:%M:%S")) ); - \endcode - - By default, the date-time will be written in extended ISO format. + This target will write %log messages to an arbitrary std::ostream in the format + \verbatim [][] \endverbatim + The \e area will be omitted if it is \c senf::log::DefaultArea. + \warning The class keeps a reference to the passed stream. - \note This class will permanently and globally change the date formating of the given - stream if no \c boost::posix_time::time_facet has been set. - \ingroup targets */ class IOStreamTarget @@ -72,21 +61,46 @@ namespace log { ///@} /////////////////////////////////////////////////////////////////////////// + void showTime(bool flag = true); ///< Enable or disable output of time field + void showStream(bool flag = true); ///< Enable or disable output of stream field + void showLevel(bool flag = true); ///< Enable or disable output of log level + void showArea(bool flag = true); ///< Enable or disable output of log area + + void timeFormat(std::string const & format); + ///< Set time format + /**< The date formatting is set using the Boost.DateTime + date_facet, e.g. + \code + target.timeFormat("%Y%m%d %H:%M:%S"); + \endcode + If the \c timeFormat is set to the empty string, the + time is written out as unformatted ClockService value. + + By default, the date-time will be written in extended + ISO format. + \param[in] format Date/Time format string */ + protected: - - private: - void v_write(boost::posix_time::ptime timestamp, std::string const & stream, + void v_write(time_type timestamp, std::string const & stream, std::string const & area, unsigned level, std::string const & message); + private: std::ostream & stream_; - }; + std::stringstream datestream_; + bool noformat_; + bool showTime_; + bool showStream_; + bool showLevel_; + bool showArea_; + + }; }} ///////////////////////////////hh.e//////////////////////////////////////// -//#include "IOStreamTarget.cci" +#include "IOStreamTarget.cci" //#include "IOStreamTarget.ct" //#include "IOStreamTarget.cti" #endif