KWStyle - itkLoggerBase.cxx
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkLoggerBase.cxx.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 DEF =========================================================================*/
17
18 #include "itkLoggerBase.h"
19
20 namespace itk
21 {
22
23 LoggerBase::LoggerBase()
24 {
25   this->m_PriorityLevel = LoggerBase::NOTSET;
26   this->m_LevelForFlushing = LoggerBase::MUSTFLUSH;
27   this->m_Clock = RealTimeClock::New();
28   this->m_Output = MultipleLogOutput::New();
29 }
30
31 LoggerBase::~LoggerBase()
32 {
33 IND //  this->m_Output->Flush();
34 }
35
36 /** Adds an output stream to the MultipleLogOutput for writing. */
37 void LoggerBase::AddLogOutput( OutputType* output )
38 {
39   // delegates to MultipleLogOutput
40   this->m_Output->AddLogOutput( output ); 
41 }
42
43 void LoggerBase::Write(PriorityLevelType level, std::string const & content)
44 {
45   if( this->m_PriorityLevel >= level )
46 IND **{
47     this->m_Output->Write(this->BuildFormattedEntry(level,content));
48     if( this->m_LevelForFlushing >= level )
49 IND ****{
50       this->m_Output->Flush();
51 IND ****}
52 IND **}
53 }
54
55 void LoggerBase::Flush()
56 {
57   this->m_Output->Flush();
58 }
59
60 LEN std::string LoggerBase::BuildFormattedEntry(PriorityLevelType level, std::string const & content)
61 {
62 LEN,IND ****static std::string m_LevelString[] = { "(MUSTFLUSH) ", "(FATAL) ", "(ERROR) ",
63 IND ********"(WARNING) ", "(INFO) ", "(DEBUG) ", "(NOTSET) " };
64 IND ****OStringStream s;
65 IND ****s.precision(30);
66 LEN,IND ****s << m_Clock->GetTimeStamp() << "  :  " << this->GetName() <<  "  " <<  m_LevelString[level] << content;
67     return s.str();
68 }
69
70 /** Print contents of a LoggerBase */
71 void LoggerBase::PrintSelf(std::ostream &os, Indent indent) const
72 {
73   Superclass::PrintSelf(os,indent);
74
75   os << indent << "Name: " << this->GetName() << std::endl;
76   os << indent << "PriorityLevel: " << this->GetPriorityLevel()   << std::endl;
77 LEN   os << indent << "LevelForFlushing: " << this->GetLevelForFlushing() << std::endl;
78 }
79
80 //namespace
81
82 EOF

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