00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __itkLogger_h
00019 #define __itkLogger_h
00020
00021 #if defined(_MSC_VER)
00022
00023 #pragma warning( disable : 4786 )
00024
00025 #pragma warning ( disable : 4503 )
00026 #endif
00027
00028 #include "itkMacro.h"
00029 #include "itkObject.h"
00030 #include "itkObjectFactory.h"
00031 #include "itkMultipleLogOutput.h"
00032 #include "itkRealTimeClock.h"
00033
00034 namespace itk
00035 {
00046 class ITKCommon_EXPORT Logger : public Object
00047 {
00048
00049 public:
00050
00051 typedef Logger Self;
00052 typedef Object Superclass;
00053 typedef SmartPointer<Self> Pointer;
00054 typedef SmartPointer<const Self> ConstPointer;
00055
00057 itkTypeMacro( Logger, Object );
00058
00060 itkNewMacro( Self );
00061
00062 typedef MultipleLogOutput::OutputType OutputType;
00063
00066 typedef enum
00067 {
00068 MUSTFLUSH=0,
00069 FATAL,
00070 CRITICAL,
00071 WARNING,
00072 INFO,
00073 DEBUG,
00074 NOTSET
00075 } PriorityLevelType;
00076
00077 itkSetStringMacro(Name);
00078
00079 itkGetStringMacro(Name);
00080
00084 virtual void SetPriorityLevel( PriorityLevelType level )
00085 {
00086 m_PriorityLevel = level;
00087 }
00088
00092 virtual PriorityLevelType GetPriorityLevel() const
00093 {
00094 return m_PriorityLevel;
00095 }
00096
00097 virtual void SetLevelForFlushing( PriorityLevelType level )
00098 {
00099 m_LevelForFlushing = level;
00100 }
00101
00102 virtual PriorityLevelType GetLevelForFlushing() const
00103 {
00104 return m_LevelForFlushing;
00105 }
00106
00108 virtual void AddLogOutput( OutputType* output );
00109
00110 virtual void Write(PriorityLevelType level, std::string const & content);
00111
00112 virtual void Flush();
00113
00114 protected:
00115
00117 Logger();
00118
00120 virtual ~Logger();
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 private:
00134
00135 RealTimeClock::Pointer m_Clock;
00136
00137 std::string m_Name;
00138
00139 };
00140
00141
00142 }
00143
00144
00145 #endif // __itkLogger_h