ITK  4.2.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  void PrintSelf(std::ostream & s, Indent indent) const;
103 
104 private:
105 
106  typedef std::map< NameType, LoggerPointer > ContainerType;
107 
109 }; // class Logger
110 } // namespace itk
111 
112 #endif // __itkLoggerManager_h
113