]> Creatis software - gdcm.git/blob - src/gdcmDebug.cxx
ENH: Adding the Debug redirection to a file stream instead of cerr. I guess is useful...
[gdcm.git] / src / gdcmDebug.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmDebug.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/01/13 22:30:11 $
7   Version:   $Revision: 1.17 $
8                                                                                 
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.
12                                                                                 
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.
16                                                                                 
17 =========================================================================*/
18
19 #include "gdcmDebug.h"
20 #include <iostream>
21
22 namespace gdcm 
23 {
24
25 /// warning message level to be displayed
26 static bool DebugFlag = false;
27 static bool DebugToFile = false;
28 static std::ofstream DebugFile;
29 //-----------------------------------------------------------------------------
30 /**
31  * \brief   Accessor
32  * @param   flag Set the debug flag
33  */ 
34 void Debug::SetDebugFlag (bool flag) 
35 {
36    DebugFlag = flag;
37 }
38
39 /**
40  * \brief   Accessor
41  * @param   level Get the debug flag
42  */ 
43 bool Debug::GetDebugFlag ()
44 {
45    return DebugFlag;
46 }
47
48 /**
49  * \brief   Accessor
50  * @param   flag Set the debug flag to redirect to file
51  */ 
52 void Debug::SetDebugToFile (bool flag) 
53 {
54    DebugToFile = flag;
55 }
56
57 /**
58  * \brief   Accessor
59  * @param   level Get the debug flag to redirect to file
60  */ 
61 bool Debug::GetDebugToFile ()
62 {
63    return DebugToFile;
64 }
65
66 /**
67  * \brief   Accessor
68  * @param   flag Set the debug flag to redirect to file
69  *          Absolutely nothing is check. You have to pass in
70  *          a correct filename
71  */ 
72 void Debug::SetDebugFilename (std::string const& filename)
73 {
74    DebugToFile = true;  // Just in case ... 
75    DebugFlag = true;    // Just in case ... 
76    DebugFile.open( filename.c_str() );
77 }
78
79 std::ofstream & Debug::GetDebugFile ()
80 {
81   return DebugFile;
82 }
83
84 } // end namespace gdcm
85
86