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, std::string const & content);
00071
00075 virtual void SetPriorityLevel( PriorityLevelType level )
00076 {
00077 m_PriorityLevel = level;
00078 }
00079
00083 virtual PriorityLevelType GetPriorityLevel() const
00084 {
00085 return m_PriorityLevel;
00086 }
00087
00088 virtual void SetLevelForFlushing( PriorityLevelType level )
00089 {
00090 m_LevelForFlushing = level;
00091 }
00092
00093 virtual PriorityLevelType GetLevelForFlushing() const
00094 {
00095 return m_LevelForFlushing;
00096 }
00097
00099 virtual void AddLogOutput( OutputType* output ) ;
00100
00101
00102 virtual void Write(PriorityLevelType level, std::string const & content) ;
00104 void Debug ( std::string const& message ) { this->Write ( LoggerBase::DEBUG, message ); }
00105 void Info ( std::string const& message ) { this->Write ( LoggerBase::INFO, message ); }
00106 void Warning ( std::string const& message ) { this->Write ( LoggerBase::WARNING, message ); }
00107 void Critical ( std::string const& message ) { this->Write ( LoggerBase::CRITICAL, message ); }
00108 void Error ( std::string const& message ) { this->Write ( LoggerBase::CRITICAL, message ); }
00109 void Fatal ( std::string const& message ) { this->Write ( LoggerBase::FATAL, message ); }
00111
00112 virtual void Flush();
00113
00114 protected:
00115
00117 LoggerBase();
00118
00120 virtual ~LoggerBase();
00121
00123 virtual void PrintSelf(std::ostream &os, Indent indent) const;
00124
00125 protected:
00126
00127 PriorityLevelType m_PriorityLevel;
00128
00129 PriorityLevelType m_LevelForFlushing;
00130
00131 MultipleLogOutput::Pointer m_Output;
00132
00133 RealTimeClock::Pointer m_Clock;
00134 private:
00135
00136 std::string m_Name;
00137
00138 };
00139
00140
00141 }
00142
00143
00144 #endif // __itkLoggerBase_h
00145