Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

LogFormat.hh

Go to the documentation of this file.
00001 // $Id: LogFormat.hh 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2009
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 #ifndef HH_SENF_Utils_Logger_LogFormat_
00027 #define HH_SENF_Utils_Logger_LogFormat_ 1
00028 
00029 // Custom includes
00030 #include <sstream>
00031 #include "TimeSource.hh"
00032 #include <senf/Utils/Console/LazyDirectory.hh>
00033 
00034 //#include "LogFormat.mpp"
00035 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00036 
00037 namespace senf {
00038 namespace log {
00039 namespace detail {
00040 
00041     class LogFormat
00042     {
00043     public:
00044         LogFormat();
00045         explicit LogFormat(console::ScopedDirectory<> & dir);
00046 
00047         void showTime(bool flag = true); 
00048         void showStream(bool flag = true); 
00049         void showLevel(bool flag = true); 
00050         void showArea(bool flag = true); 
00051 
00052         void timeFormat(std::string const & format);
00054 
00066         void tag(std::string const & tag); 
00067 
00068     protected:
00069         std::string prefix(time_type timestamp, std::string const & stream,
00070                            std::string const & area, unsigned level);
00071         bool isPlainFormat() const;
00072         void consoleFormat(std::ostream & os);
00073 
00074     private:
00075 
00076         std::string tag_;
00077         std::string timeFormat_;
00078         std::stringstream datestream_;
00079         bool noformat_;
00080         bool showTime_;
00081         bool showStream_;
00082         bool showLevel_;
00083         bool showArea_;
00084         time_type timeBase_;
00085     };
00086 
00087     void quoteNonPrintable(std::string & s);
00088     std::string getDefaultTag();
00089 
00090 }}}
00091 
00092 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00093 #include "LogFormat.cci"
00094 //#include "LogFormat.ct"
00095 //#include "LogFormat.cti"
00096 #endif
00097 
00098 
00099 // Local Variables:
00100 // mode: c++
00101 // fill-column: 100
00102 // comment-column: 40
00103 // c-file-style: "senf"
00104 // indent-tabs-mode: nil
00105 // ispell-local-dictionary: "american"
00106 // compile-command: "scons -u test"
00107 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research