1 /*=========================================================================
4 Module: $RCSfile: gdcmDebug.cxx,v $
6 Date: $Date: 2005/11/05 13:21:32 $
7 Version: $Revision: 1.26 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
19 #include "gdcmDebug.h"
24 //-----------------------------------------------------------------------------
25 // Warning message level to be displayed
26 static bool DebugFlag = false;
27 static bool WarningFlag = false;
28 static bool DebugToFile = false;
29 static std::ofstream DebugFile;
31 //-----------------------------------------------------------------------------
32 // Constructor / Destructor
40 if ( DebugFile.is_open() )
44 //-----------------------------------------------------------------------------
47 * \brief Sets both the debug flag and warning flag
48 * (both used for debugging purpose)
49 * @param flag Set the debug flag and warning flag
51 void Debug::SetDebugFlag (bool flag)
53 // To help tracking a bug, both flags are necessary
59 * \brief Gets the debug flag value
60 * (used to warn user when file contains some oddity)
61 * @return debug flag value
63 bool Debug::GetDebugFlag ()
69 * \brief Sets the warning flag
70 * @param flag Set the warning flag
72 void Debug::SetWarningFlag (bool flag)
74 // Cannot unset Warning flag if Debug flag is on.
75 if (flag == false && DebugFlag == true)
81 * \brief Gets the warning flag value
82 * @return warning flag value
84 bool Debug::GetWarningFlag ()
90 * @param flag whether we want to redirect to file
92 void Debug::SetDebugToFile (bool flag)
98 * \brief Accessor to know whether debug info are redirected to file
100 bool Debug::GetDebugToFile ()
106 * \brief Set the filename the debug stream should be redirect to
107 * Settting a filename also sets DebugToFile to true
108 * @param filename File to redirect debug info
109 * Absolutely nothing is check. You have to pass in
112 void Debug::SetDebugFilename (std::string const &filename)
114 DebugToFile = true; // Just in case ...
115 DebugFlag = true; // Just in case ...
116 if ( DebugFile.is_open() )
118 DebugFile.open( filename.c_str() );
122 * \brief Internal use only. Allow us to retrieve the static from anywhere
126 std::ofstream &Debug::GetDebugFile ()
131 //-----------------------------------------------------------------------------
134 //-----------------------------------------------------------------------------
137 //-----------------------------------------------------------------------------
140 //-----------------------------------------------------------------------------
141 } // end namespace gdcm