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 00086 void logfile( const Pathname & logfile_r ); 00087 00089 void logNothing(); 00090 00092 void logToStdErr(); 00093 00098 void setLineWriter( const shared_ptr<LineWriter> & writer_r ); 00099 00100 public: 00102 struct TmpExcessive 00103 { 00104 TmpExcessive(); 00105 ~TmpExcessive(); 00106 }; 00107 00109 struct TmpLineWriter 00110 { 00111 TmpLineWriter( const shared_ptr<LineWriter> & writer_r = shared_ptr<LineWriter>() ); 00112 ~TmpLineWriter(); 00113 private: 00114 shared_ptr<LineWriter> _writer; 00115 }; 00116 00117 private: 00119 LogControl() 00120 {} 00121 }; 00123 00125 std::ostream & operator<<( std::ostream & str, const LogControl & obj ); 00126 00128 } // namespace base 00131 } // namespace zypp 00133 #endif // ZYPP_BASE_LOGCONTROL_H
1.4.6