KWStyle - itkLoggerBase.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkLoggerBase.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:41 $
7   Version:   $Revision: 1.4 $
8
9   Copyright (c) Insight Software Consortium. All rights reserved.
10   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11
12      This software is distributed WITHOUT ANY WARRANTY; without even
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14      PURPOSE.  See the above copyright notices for more information.
15
16 =========================================================================*/
17
18 #ifndef __itkLoggerBase_h
19 #define __itkLoggerBase_h
20
21 #if defined(_MSC_VER)
22 LEN,IND ***//Warning about: identifier was truncated to '255' characters in the debug information (MVC6.0 Debug)
23 IND ***#pragma warning( disable : 4786 )
24 LEN,IND **// warning C4503: 'insert' : decorated name length exceeded, name was truncated
25 IND **#pragma warning ( disable : 4503 )
26 #endif
27
28 #include "itkMacro.h"
29 #include "itkObject.h"
30 #include "itkObjectFactory.h"
31 #include "itkMultipleLogOutput.h"
32 #include "itkRealTimeClock.h"
33
34 namespace itk
35 {
36 /** \class LoggerBase
37 IND *   \brief Class LoggerBase is meant for logging information during a run.
38 IND *
39 IND * \author Hee-Su Kim, Compute Science Dept. Kyungpook National University,
40 IND *                     ISIS Center, Georgetown University.
41 IND *
42 IND *
43  *  \ingroup OSSystemObjects LoggingObjects
44 IND */
45
46 class ITKCommon_EXPORT LoggerBase : public Object
47 {
48
49 public:
50
51   typedef LoggerBase  Self;
52 TDA   typedef Object  Superclass;
53 TDA   typedef SmartPointer<Self>  Pointer;
54 TDA   typedef SmartPointer<const Self>  ConstPointer;
55
56   /** Run-time type information (and related methods). */
57   itkTypeMacro( LoggerBase, Object );
58
59   typedef  MultipleLogOutput::OutputType   OutputType;
60
61   /** Definition of types of messages. These codes will be used to regulate the
62    * level of detail of messages reported to the final outputs */
63   typedef enum
64 IND **{
65     MUSTFLUSH=0,
66     FATAL,
67     CRITICAL,
68     WARNING,
69     INFO,
70     DEBUG,
71     NOTSET
72 IND **} PriorityLevelType;
73
74   itkSetStringMacro(Name);
75   itkGetStringMacro(Name);
76
77   /** Provides a default formatted log entry */
78 LEN   virtual std::string BuildFormattedEntry(PriorityLevelType level, std::string const & content);
79
80   /** Set the priority level for the current logger. Only messages that have
81    * priorities equal or greater than the one set here will be posted to the
82    * current outputs */
83   virtual void SetPriorityLevel( PriorityLevelType level )
84 IND **{
85     m_PriorityLevel = level;
86 IND **}
87
88   /** Get the priority level for the current logger. Only messages that have
89    * priorities equal or greater than the one set here will be posted to the
90    * current outputs */
91   virtual PriorityLevelType GetPriorityLevel() const
92 IND **{
93     return m_PriorityLevel;
94 IND **}
95
96   virtual void SetLevelForFlushing( PriorityLevelType level )
97 IND **{
98     m_LevelForFlushing = level;
99 IND **}
100
101   virtual PriorityLevelType GetLevelForFlushing() const
102 IND **{
103     return m_LevelForFlushing;
104 IND **}
105
106   /** Registers another output stream with the multiple output. */
107 SEM   virtual void AddLogOutput( OutputType* output ) ;
108
109
110 SEM   virtual void Write(PriorityLevelType level, std::string const & content) ;
111   /** Helper methods */
112 LEN   void Debug ( std::string const& message ) { this->Write ( LoggerBase::DEBUG, message ); }
113 LEN   void Info ( std::string const& message ) { this->Write ( LoggerBase::INFO, message ); }
114 LEN   void Warning ( std::string const& message ) { this->Write ( LoggerBase::WARNING, message ); }
115 LEN   void Critical ( std::string const& message ) { this->Write ( LoggerBase::CRITICAL, message ); }
116 LEN   void Error ( std::string const& message ) { this->Write ( LoggerBase::CRITICAL, message ); }
117 LEN   void Fatal ( std::string const& message ) { this->Write ( LoggerBase::FATAL, message ); }
118
119   virtual void Flush();
120
121 protected:
122
123   /** Constructor */
124   LoggerBase();
125
126   /** Destructor */
127   virtual ~LoggerBase();
128
129   /** Print contents of a LoggerBase */
130   virtual void PrintSelf(std::ostream &os, Indent indent) const;
131
132 protected:
133
134   PriorityLevelType m_PriorityLevel;
135
136   PriorityLevelType m_LevelForFlushing;
137
138   MultipleLogOutput::Pointer  m_Output;
139
140   RealTimeClock::Pointer  m_Clock;
141 private:
142
143   std::string m_Name;
144
145 };  // class LoggerBase
146
147
148 // namespace itk
149
150
151 #endif  // __itkLoggerBase_h
152

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:19PM
© Kitware Inc.