LogControl.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_BASE_LOGCONTROL_H
00013 #define ZYPP_BASE_LOGCONTROL_H
00014 
00015 #include <iosfwd>
00016 
00017 #include "zypp/base/Logger.h"
00018 #include "zypp/base/PtrTypes.h"
00019 #include "zypp/Pathname.h"
00020 
00022 namespace zypp
00023 { 
00024 
00025   namespace base
00026   { 
00027 
00029     //
00030     //  CLASS NAME : LogControl
00031     //
00036     class LogControl
00037     {
00038       friend std::ostream & operator<<( std::ostream & str, const LogControl & obj );
00039 
00040     public:
00042       static LogControl instance()
00043       { return LogControl(); }
00044 
00045 
00051       struct LineWriter
00052       {
00053         virtual void writeOut( const std::string & /*formated_r*/ )
00054         {}
00055         virtual ~LineWriter() {}
00056       };
00057 
00063       struct LineFormater
00064       {
00065         virtual std::string format( const std::string & /*group_r*/,
00066                                     logger::LogLevel    /*level_r*/,
00067                                     const char *        /*file_r*/,
00068                                     const char *        /*func_r*/,
00069                                     int                 /*line_r*/,
00070                                     const std::string & /*message_r*/ );
00071         virtual ~LineFormater() {}
00072       };
00073 
00074     public:
00079       void setLineFormater( const shared_ptr<LineFormater> & formater_r );
00080 
00087       void logfile( const Pathname & logfile_r );
00088       void logfile( const Pathname & logfile_r, mode_t mode_r );
00089 
00091       void logNothing();
00092 
00094       void logToStdErr();
00095 
00100       void setLineWriter( const shared_ptr<LineWriter> & writer_r );
00101 
00102     public:
00104       struct TmpExcessive
00105       {
00106         TmpExcessive();
00107         ~TmpExcessive();
00108       };
00109 
00111       struct TmpLineWriter
00112       {
00113         TmpLineWriter( const shared_ptr<LineWriter> & writer_r = shared_ptr<LineWriter>() );
00114         ~TmpLineWriter();
00115       private:
00116         shared_ptr<LineWriter> _writer;
00117       };
00118 
00119     private:
00121       LogControl()
00122       {}
00123     };
00125 
00127     std::ostream & operator<<( std::ostream & str, const LogControl & obj );
00128 
00130   } // namespace base
00133 } // namespace zypp
00135 #endif // ZYPP_BASE_LOGCONTROL_H

Generated on Thu Jul 6 00:07:20 2006 for zypp by  doxygen 1.4.6