ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkLoggerBase.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkLoggerBase_h
19 #define __itkLoggerBase_h
20 
21 #include "itkMultipleLogOutput.h"
22 #include "itkRealTimeClock.h"
23 
24 namespace itk
25 {
37 class ITKCommon_EXPORT LoggerBase:public Object
38 {
39 public:
40 
41  typedef LoggerBase Self;
42  typedef Object Superclass;
45 
47  itkTypeMacro(LoggerBase, Object);
48 
50 
53  typedef enum {
54  MUSTFLUSH = 0,
60  NOTSET
61  } PriorityLevelType;
62 
63  itkSetStringMacro(Name);
64  itkGetStringMacro(Name);
65 
67  typedef enum {
68  REALVALUE = 0,
69  HUMANREADABLE
70  } TimeStampFormatType;
71 
81  itkSetMacro(TimeStampFormat, TimeStampFormatType);
82  itkGetConstReferenceMacro(TimeStampFormat, TimeStampFormatType);
84 
93  itkSetStringMacro(HumanReadableFormat);
94  itkGetStringMacro(HumanReadableFormat);
96 
98  virtual std::string BuildFormattedEntry(PriorityLevelType level,
99  std::string const & content);
100 
104  virtual void SetPriorityLevel(PriorityLevelType level)
105  {
106  m_PriorityLevel = level;
107  }
108 
112  virtual PriorityLevelType GetPriorityLevel() const
113  {
114  return m_PriorityLevel;
115  }
116 
117  virtual void SetLevelForFlushing(PriorityLevelType level)
118  {
119  m_LevelForFlushing = level;
120  }
121 
122  virtual PriorityLevelType GetLevelForFlushing() const
123  {
124  return m_LevelForFlushing;
125  }
126 
128  virtual void AddLogOutput(OutputType *output);
129 
130  virtual void Write(PriorityLevelType level, std::string const & content);
131 
133  void Debug(std::string const & message)
134  {
135  this->Write (LoggerBase::DEBUG, message);
136  }
137 
138  void Info(std::string const & message)
139  {
140  this->Write (LoggerBase::INFO, message);
141  }
142 
143  void Warning(std::string const & message)
144  {
145  this->Write (LoggerBase::WARNING, message);
146  }
147 
148  void Critical(std::string const & message)
149  {
150  this->Write (LoggerBase::CRITICAL, message);
151  }
152 
153  void Error(std::string const & message)
154  {
155  this->Write (LoggerBase::CRITICAL, message);
156  }
157 
158  void Fatal(std::string const & message)
159  {
160  this->Write (LoggerBase::FATAL, message);
161  }
162 
163  virtual void Flush();
164 
165 protected:
166 
168  LoggerBase();
169 
171  virtual ~LoggerBase();
172 
174  virtual void PrintSelf(std::ostream & os, Indent indent) const;
175 
176 protected:
177 
179 
181 
183 
185 
187 
189 private:
190 
191  std::string m_Name;
192 }; // class LoggerBase
193 } // namespace itk
194 
195 #endif // __itkLoggerBase_h
196