00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __itkLoggerBase_h
00019 #define __itkLoggerBase_h
00020
00021 #include "itkObject.h"
00022 #include "itkObjectFactory.h"
00023 #include "itkMultipleLogOutput.h"
00024 #include "itkRealTimeClock.h"
00025
00026 namespace itk
00027 {
00038 class ITKCommon_EXPORT LoggerBase : public Object
00039 {
00040
00041 public:
00042
00043 typedef LoggerBase Self;
00044 typedef Object Superclass;
00045 typedef SmartPointer<Self> Pointer;
00046 typedef SmartPointer<const Self> ConstPointer;
00047
00049 itkTypeMacro( LoggerBase, Object );
00050
00051 typedef MultipleLogOutput::OutputType OutputType;
00052
00055 typedef enum
00056 {
00057 MUSTFLUSH=0,
00058 FATAL,
00059 CRITICAL,
00060 WARNING,
00061 INFO,
00062 DEBUG,
00063 NOTSET
00064 } PriorityLevelType;
00065
00066 itkSetStringMacro(Name);
00067 itkGetStringMacro(Name);
00068
00070 virtual std::string BuildFormattedEntry(PriorityLevelType level,
00071 std::string const & content);
00072
00076 virtual void SetPriorityLevel( PriorityLevelType level )
00077 {
00078 m_PriorityLevel = level;
00079 }
00080
00084 virtual PriorityLevelType GetPriorityLevel() const
00085 {
00086 return m_PriorityLevel;
00087 }
00088
00089 virtual void SetLevelForFlushing( PriorityLevelType level )
00090 {
00091 m_LevelForFlushing = level;
00092 }
00093
00094 virtual PriorityLevelType GetLevelForFlushing() const
00095 {
00096 return m_LevelForFlushing;
00097 }
00098
00100 virtual void AddLogOutput( OutputType* output ) ;
00101
00102
00103 virtual void Write(PriorityLevelType level, std::string const & content) ;
00105 void Debug ( std::string const& message )
00106 {
00107 this->Write ( LoggerBase::DEBUG, message );
00108 }
00109 void Info ( std::string const& message )
00110 {
00111 this->Write ( LoggerBase::INFO, message );
00112 }
00113 void Warning ( std::string const& message )
00114 {
00115 this->Write ( LoggerBase::WARNING, message );
00116 }
00117 void Critical ( std::string const& message )
00118 {
00119 this->Write ( LoggerBase::CRITICAL, message );
00120 }
00121 void Error ( std::string const& message )
00122 {
00123 this->Write ( LoggerBase::CRITICAL, message );
00124 }
00125 void Fatal ( std::string const& message )
00126 {
00127 this->Write ( LoggerBase::FATAL, message );
00128 }
00130
00131 virtual void Flush();
00132
00133 protected:
00134
00136 LoggerBase();
00137
00139 virtual ~LoggerBase();
00140
00142 virtual void PrintSelf(std::ostream &os, Indent indent) const;
00143
00144 protected:
00145
00146 PriorityLevelType m_PriorityLevel;
00147
00148 PriorityLevelType m_LevelForFlushing;
00149
00150 MultipleLogOutput::Pointer m_Output;
00151
00152 RealTimeClock::Pointer m_Clock;
00153
00154 private:
00155
00156 std::string m_Name;
00157
00158 };
00159
00160
00161 }
00162
00163
00164 #endif // __itkLoggerBase_h
00165