itkLoggerBase.h
Go to the documentation of this file.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 typedef enum
00071 {
00072 REALVALUE=0,
00073 HUMANREADABLE
00074 } TimeStampFormatType;
00075
00085 itkSetMacro( TimeStampFormat, TimeStampFormatType );
00086 itkGetConstReferenceMacro( TimeStampFormat, TimeStampFormatType );
00088
00097 itkSetStringMacro( HumanReadableFormat );
00098 itkGetStringMacro( HumanReadableFormat );
00100
00102 virtual std::string BuildFormattedEntry(PriorityLevelType level,
00103 std::string const & content);
00104
00108 virtual void SetPriorityLevel( PriorityLevelType level )
00109 {
00110 m_PriorityLevel = level;
00111 }
00112
00116 virtual PriorityLevelType GetPriorityLevel() const
00117 {
00118 return m_PriorityLevel;
00119 }
00120
00121 virtual void SetLevelForFlushing( PriorityLevelType level )
00122 {
00123 m_LevelForFlushing = level;
00124 }
00125
00126 virtual PriorityLevelType GetLevelForFlushing() const
00127 {
00128 return m_LevelForFlushing;
00129 }
00130
00132 virtual void AddLogOutput( OutputType* output );
00133
00134
00135 virtual void Write(PriorityLevelType level, std::string const & content);
00137 void Debug ( std::string const& message )
00138 {
00139 this->Write ( LoggerBase::DEBUG, message );
00140 }
00141 void Info ( std::string const& message )
00142 {
00143 this->Write ( LoggerBase::INFO, message );
00144 }
00145 void Warning ( std::string const& message )
00146 {
00147 this->Write ( LoggerBase::WARNING, message );
00148 }
00149 void Critical ( std::string const& message )
00150 {
00151 this->Write ( LoggerBase::CRITICAL, message );
00152 }
00153 void Error ( std::string const& message )
00154 {
00155 this->Write ( LoggerBase::CRITICAL, message );
00156 }
00157 void Fatal ( std::string const& message )
00158 {
00159 this->Write ( LoggerBase::FATAL, message );
00160 }
00162
00163 virtual void Flush();
00164
00165 protected:
00166
00168 LoggerBase();
00169
00171 virtual ~LoggerBase();
00172
00174 virtual void PrintSelf(std::ostream &os, Indent indent) const;
00175
00176 protected:
00177
00178 PriorityLevelType m_PriorityLevel;
00179
00180 PriorityLevelType m_LevelForFlushing;
00181
00182 MultipleLogOutput::Pointer m_Output;
00183
00184 RealTimeClock::Pointer m_Clock;
00185
00186 TimeStampFormatType m_TimeStampFormat;
00187
00188 std::string m_HumanReadableFormat;
00189
00190 private:
00191
00192 std::string m_Name;
00193
00194 };
00195
00196 }
00197
00198 #endif // __itkLoggerBase_h
00199