1*f8e07b45SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f8e07b45SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f8e07b45SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f8e07b45SAndrew Rist  * distributed with this work for additional information
6*f8e07b45SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f8e07b45SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f8e07b45SAndrew Rist  * "License"); you may not use this file except in compliance
9*f8e07b45SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f8e07b45SAndrew Rist  *
11*f8e07b45SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f8e07b45SAndrew Rist  *
13*f8e07b45SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f8e07b45SAndrew Rist  * software distributed under the License is distributed on an
15*f8e07b45SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f8e07b45SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f8e07b45SAndrew Rist  * specific language governing permissions and limitations
18*f8e07b45SAndrew Rist  * under the License.
19*f8e07b45SAndrew Rist  *
20*f8e07b45SAndrew Rist  *************************************************************/
21*f8e07b45SAndrew Rist 
22*f8e07b45SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef __FRAMEWORK_MACROS_DEBUG_LOGMECHANISM_HXX_
25cdf0e10cSrcweir #define __FRAMEWORK_MACROS_DEBUG_LOGMECHANISM_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //*****************************************************************************************************************
28cdf0e10cSrcweir //	generic macros for logging
29cdf0e10cSrcweir //*****************************************************************************************************************
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #ifdef	ENABLE_LOGMECHANISM
32cdf0e10cSrcweir 
33cdf0e10cSrcweir 	//_____________________________________________________________________________________________________________
34cdf0e10cSrcweir 	//	includes
35cdf0e10cSrcweir 	//_____________________________________________________________________________________________________________
36cdf0e10cSrcweir 
37cdf0e10cSrcweir 	#ifndef _RTL_STRING_HXX_
38cdf0e10cSrcweir 	#include <rtl/string.hxx>
39cdf0e10cSrcweir 	#endif
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 	#include <stdio.h>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir 	/*_____________________________________________________________________________________________________________
44cdf0e10cSrcweir 		WRITE_LOGFILE( SFILENAME, STEXT )
45cdf0e10cSrcweir 
46cdf0e10cSrcweir 		Log any information in file. We append any information at file and don't clear it anymore.
47cdf0e10cSrcweir 		( Use new scope in macro to declare pFile more then on time in same "parentscope"!
48cdf0e10cSrcweir 	  	  Don't control pFile before access! What will you doing if its not valid? Log an error ...
49cdf0e10cSrcweir   	  	  An error and an error is an error ... )
50cdf0e10cSrcweir 
51cdf0e10cSrcweir         Attention:  You must use "%s" and STEXT as parameter ... because otherwise encoded strings (they include e.g. %...)
52cdf0e10cSrcweir                     are handled wrong.
53cdf0e10cSrcweir 	_____________________________________________________________________________________________________________*/
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 	#define	WRITE_LOGFILE( SFILENAME, STEXT )																	\
56cdf0e10cSrcweir 				{																								\
57cdf0e10cSrcweir 					::rtl::OString	_swriteLogfileFileName	( SFILENAME	);										\
58cdf0e10cSrcweir 					::rtl::OString	_swriteLogfileText		( STEXT		);										\
59cdf0e10cSrcweir 					FILE* pFile = fopen( _swriteLogfileFileName.getStr(), "a" );								\
60cdf0e10cSrcweir                     fprintf( pFile, "%s", _swriteLogfileText.getStr() );                                        \
61cdf0e10cSrcweir                     fclose ( pFile                                    );                                        \
62cdf0e10cSrcweir 				}
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 	/*_____________________________________________________________________________________________________________
65cdf0e10cSrcweir 		LOGTYPE
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 		For other debug macros we need information about the output mode. If user forget to set this information we
68cdf0e10cSrcweir 		do it for him. Valid values are:	LOGTYPE_FILECONTINUE
69cdf0e10cSrcweir 											LOGTYPE_FILEEXIT
70cdf0e10cSrcweir 											LOGTYPE_MESSAGEBOX
71cdf0e10cSrcweir 		The normal case is LOGTYPE_MESSAGEBOX to show assertions in normal manner!
72cdf0e10cSrcweir 	_____________________________________________________________________________________________________________*/
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 	#define	LOGTYPE_MESSAGEBOX		1
75cdf0e10cSrcweir 	#define	LOGTYPE_FILECONTINUE	2
76cdf0e10cSrcweir 	#define	LOGTYPE_FILEEXIT		3
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	#ifndef	LOGTYPE
79cdf0e10cSrcweir 		#define	LOGTYPE																							\
80cdf0e10cSrcweir 					LOGTYPE_MESSAGEBOX
81cdf0e10cSrcweir 	#endif
82cdf0e10cSrcweir 
83cdf0e10cSrcweir #else	// #ifdef ENABLE_LOGMECHANISM
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	/*_____________________________________________________________________________________________________________
86cdf0e10cSrcweir 		If right testmode is'nt set - implements these macro empty!
87cdf0e10cSrcweir 	_____________________________________________________________________________________________________________*/
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 	#define	WRITE_LOGFILE( SFILENAME, STEXT )
90cdf0e10cSrcweir 	#undef	LOGTYPE
91cdf0e10cSrcweir 
92cdf0e10cSrcweir #endif	// #ifdef ENABLE_LOGMECHANISM
93cdf0e10cSrcweir 
94cdf0e10cSrcweir //*****************************************************************************************************************
95cdf0e10cSrcweir //	end of file
96cdf0e10cSrcweir //*****************************************************************************************************************
97cdf0e10cSrcweir 
98cdf0e10cSrcweir #endif	// #ifndef __FRAMEWORK_MACROS_DEBUG_LOGMECHANISM_HXX_
99