ITK  4.6.0
Insight Segmentation and Registration Toolkit
itkLoggerManager.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 __itkLoggerManager_h
19 #define __itkLoggerManager_h
20 
21 #include "itkObject.h"
22 #include "itkObjectFactory.h"
23 #include "itkThreadLogger.h"
24 
25 #include <string>
26 #include <map>
27 
28 namespace itk
29 {
42 class ITKCommon_EXPORT LoggerManager:public Object
43 {
44 public:
45 
47  typedef Object Superclass;
50 
52  itkTypeMacro(LoggerManager, Object);
53 
55  itkNewMacro(Self);
56 
58 
60 
63 
64  typedef std::string NameType;
65 
67  LoggerPointer CreateLogger(
68  const NameType & name,
69  PriorityLevelType level,
70  PriorityLevelType levelForFlushing = LoggerBase::MUSTFLUSH);
71 
73  ThreadLoggerPointer CreateThreadLogger(
74  const NameType & name,
75  PriorityLevelType level,
76  PriorityLevelType levelForFlushing = LoggerBase::MUSTFLUSH);
77 
79  void AddLogger(const NameType & name, Logger *logger);
80 
81  Logger * GetLogger(const NameType & name);
82 
83  void SetPriorityLevel(PriorityLevelType level);
84 
85  void SetLevelForFlushing(PriorityLevelType level);
86 
87  void AddLogOutput(OutputType *output);
88 
89  void Write(PriorityLevelType level, std::string const & content);
90 
91  void Flush();
92 
93 protected:
94 
97 
99  virtual ~LoggerManager() {}
100 
102  virtual void PrintSelf(std::ostream & s, Indent indent) const ITK_OVERRIDE;
103 
104 private:
105 
106  typedef std::map< NameType, LoggerPointer > ContainerType;
107 
109 }; // class Logger
110 } // namespace itk
111 
112 #endif // __itkLoggerManager_h
ContainerType m_LoggerSet
Light weight base class for most itk classes.
Used for centrally managing loggers.
Represents an output stream.
Definition: itkLogOutput.h:39
ThreadLogger::Pointer ThreadLoggerPointer
SmartPointer< const Self > ConstPointer
LoggerManager Self
std::map< NameType, LoggerPointer > ContainerType
Logger::Pointer LoggerPointer
SmartPointer< Self > Pointer
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Base class for most ITK classes.
Definition: itkObject.h:57
Logger::OutputType OutputType
Logger::PriorityLevelType PriorityLevelType
Used for logging information during a run.
Definition: itkLogger.h:36