ITK  5.4.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  * https://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  itkOverrideGetNameOfClassMacro(LoggerManager);
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  std::map<NameType, LoggerPointer> m_LoggerSet{};
112 }; // class Logger
113 } // namespace itk
114 
115 #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
Used for centrally managing loggers.
Definition: itkLoggerManager.h:42
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
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:46
itk::LoggerBaseEnums::PriorityLevel::MUSTFLUSH
itk::Object
Base class for most ITK classes.
Definition: itkObject.h:61
itkThreadLogger.h