ITK  4.8.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 
105  {
106  m_PriorityLevel = level;
107  }
108 
113  {
114  return m_PriorityLevel;
115  }
116 
118  {
119  m_LevelForFlushing = level;
120  }
121 
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 ITK_OVERRIDE;
175 
176 protected:
177 
179 
181 
183 
185 
187 
189 
190 private:
191 
192  std::string m_Name;
193 }; // class LoggerBase
194 } // namespace itk
195 
196 #endif // itkLoggerBase_h
void Info(std::string const &message)
PriorityLevelType m_LevelForFlushing
SmartPointer< Self > Pointer
Definition: itkLoggerBase.h:43
Represents an output stream.
Definition: itkLogOutput.h:39
void Debug(std::string const &message)
MultipleLogOutput::Pointer m_Output
virtual PriorityLevelType GetLevelForFlushing() const
MultipleLogOutput::OutputType OutputType
Definition: itkLoggerBase.h:47
virtual void SetPriorityLevel(PriorityLevelType level)
Used for logging information during a run.
Definition: itkLoggerBase.h:37
virtual void SetLevelForFlushing(PriorityLevelType level)
void Error(std::string const &message)
void Warning(std::string const &message)
TimeStampFormatType m_TimeStampFormat
RealTimeClock::Pointer m_Clock
void Fatal(std::string const &message)
std::string m_Name
std::string m_HumanReadableFormat
SmartPointer< const Self > ConstPointer
Definition: itkLoggerBase.h:44
LoggerBase Self
Definition: itkLoggerBase.h:41
Control indentation during Print() invocation.
Definition: itkIndent.h:49
PriorityLevelType m_PriorityLevel
Base class for most ITK classes.
Definition: itkObject.h:57
virtual PriorityLevelType GetPriorityLevel() const
void Critical(std::string const &message)