ITK  5.2.0
Insight Toolkit
itkLoggerManager.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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:
46  using Superclass = Object;
49 
51  itkTypeMacro(LoggerManager, Object);
52 
54  itkNewMacro(Self);
55 
57 
59 
62 
63  using NameType = std::string;
64 
67  CreateLogger(const NameType & name,
68  PriorityLevelEnum level,
70 
73  CreateThreadLogger(const NameType & name,
74  PriorityLevelEnum level,
76 
78  void
79  AddLogger(const NameType & name, Logger * logger);
80 
81  Logger *
82  GetLogger(const NameType & name);
83 
84  void
85  SetPriorityLevel(PriorityLevelEnum level);
86 
87  void
88  SetLevelForFlushing(PriorityLevelEnum level);
89 
90  void
91  AddLogOutput(OutputType * output);
92 
93  void
94  Write(PriorityLevelEnum level, std::string const & content);
95 
96  void
97  Flush();
98 
99 protected:
101  LoggerManager() = default;
102 
104  ~LoggerManager() override = default;
105 
107  void
108  PrintSelf(std::ostream & os, Indent indent) const override;
109 
110 private:
111  using ContainerType = std::map<NameType, LoggerPointer>;
112 
114 }; // class Logger
115 } // namespace itk
116 
117 #endif // itkLoggerManager_h
itkObjectFactory.h
itk::LoggerBase::PriorityLevelEnum
LoggerBaseEnums::PriorityLevel PriorityLevelEnum
Definition: itkLoggerBase.h:94
itk::LoggerManager::NameType
std::string NameType
Definition: itkLoggerManager.h:63
itk::Logger
Used for logging information during a run.
Definition: itkLogger.h:36
itk::LoggerBaseEnums::PriorityLevel
PriorityLevel
Definition: itkLoggerBase.h:43
itk::LoggerBase::OutputType
MultipleLogOutput::OutputType OutputType
Definition: itkLoggerBase.h:92
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::LoggerManager::m_LoggerSet
ContainerType m_LoggerSet
Definition: itkLoggerManager.h:113
itk::LoggerManager::ContainerType
std::map< NameType, LoggerPointer > ContainerType
Definition: itkLoggerManager.h:111
itk::LoggerManager
Used for centrally managing loggers.
Definition: itkLoggerManager.h:42
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::LogOutput
Represents an output stream.
Definition: itkLogOutput.h:39
itkObject.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::Logger::Pointer
SmartPointer< Self > Pointer
Definition: itkLogger.h:43
itk::ThreadLogger::Pointer
SmartPointer< Self > Pointer
Definition: itkThreadLogger.h:45
itk::LoggerBaseEnums::PriorityLevel::MUSTFLUSH
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:62
itkThreadLogger.h