1 /*=========================================================================
4 Module: $RCSfile: gdcmDebug.h,v $
6 Date: $Date: 2005/01/07 19:20:38 $
7 Version: $Revision: 1.13 $
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 =========================================================================*/
22 #include "gdcmCommon.h"
26 //-----------------------------------------------------------------------------
30 * \brief Debug is an object for debugging in program.
31 * It has 2 debugging modes :
32 * - error : for bad library use
33 * - debug : for debugging messages
35 * A debugging message has a level of priority and is
36 * Shown only when the debug level is higher than the
39 class GDCM_EXPORT Debug
42 /// This is a global flag that controls whether any debug, warning
43 /// messages are displayed.
44 static int GetDebugFlag ();
45 static void SetDebugFlag (int flag);
46 static void SetDebugOn () { SetDebugFlag(1); };
47 static void SetDebugOff () { SetDebugFlag(0); };
50 } // end namespace gdcm
52 // Here we define function this is the only way to be able to pass
53 // stuff with indirection like:
54 // gdcmDebug( "my message:" << i << '\t' );
55 // You cannot use function unless you use vnsprintf ...
57 // __FUNCTION is not always defined by preprocessor
59 # define __FUNCTION__ ""
65 * @param msg1 first message part
66 * @param msg2 second message part
68 #define gdcmDebugMacro(x) \
70 if( gdcm::Debug::GetDebugFlag() ) \
72 std::ostringstream osmacro; \
73 osmacro << "Debug: In " __FILE__ ", line " << __LINE__ \
74 << ", function " << __FUNCTION__ << '\n' \
76 std::cerr << osmacro.str() << std::endl; \
83 * @param msg1 first message part
84 * @param msg2 second message part
86 #define gdcmVerboseMacro(x) \
88 if( gdcm::Debug::GetDebugFlag() ) \
90 std::ostringstream osmacro; \
91 osmacro << "Verbose: In " __FILE__ ", line " << __LINE__ \
92 << ", function " __FUNCTION__ "\n" \
94 std::cerr << osmacro.str() << std::endl; \
101 * @param msg1 first message part
102 * @param msg2 second message part
104 #define gdcmErrorMacro(x) \
106 if( gdcm::Debug::GetDebugFlag() ) \
108 std::ostringstream osmacro; \
109 osmacro << "Error: In " __FILE__ ", line " << __LINE__ \
110 << ", function " << __FUNCTION__ << '\n' \
112 std::cerr << osmacro.str() << std::endl; \
121 * @param msg1 first message part
122 * @param msg2 second message part
124 #define gdcmAssertMacro(x) \
128 std::ostringstream osmacro; \
129 osmacro << "Assert: In " __FILE__ ", line " << __LINE__ \
130 << ", function " << __FUNCTION__ \
132 std::cerr << osmacro.str() << std::endl; \