1f8e07b45SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f8e07b45SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f8e07b45SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f8e07b45SAndrew Rist  * distributed with this work for additional information
6f8e07b45SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f8e07b45SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f8e07b45SAndrew Rist  * "License"); you may not use this file except in compliance
9f8e07b45SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f8e07b45SAndrew Rist  *
11f8e07b45SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f8e07b45SAndrew Rist  *
13f8e07b45SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f8e07b45SAndrew Rist  * software distributed under the License is distributed on an
15f8e07b45SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f8e07b45SAndrew Rist  * KIND, either express or implied.  See the License for the
17f8e07b45SAndrew Rist  * specific language governing permissions and limitations
18f8e07b45SAndrew Rist  * under the License.
19f8e07b45SAndrew Rist  *
20f8e07b45SAndrew Rist  *************************************************************/
21f8e07b45SAndrew Rist 
22f8e07b45SAndrew 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 
writeToLogFile(const char * SFILENAME,const char * STEXT)55*24c56ab9SHerbert Dürr 	inline void writeToLogFile( const char* SFILENAME, const char* 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 
writeToLogFile(const char * pFILENAME,const rtl::OString & rTEXT)64*24c56ab9SHerbert Dürr 	inline void writeToLogFile( const char* pFILENAME, const rtl::OString& rTEXT ) { writeToLogFile( pFILENAME, rTEXT.getStr()); }
65*24c56ab9SHerbert Dürr 
66*24c56ab9SHerbert Dürr 	#define WRITE_LOGFILE( SFILENAME, STEXT ) { writeToLogFile( (SFILENAME), (STEXT) ); }
67*24c56ab9SHerbert Dürr 
68cdf0e10cSrcweir 	/*_____________________________________________________________________________________________________________
69cdf0e10cSrcweir 		LOGTYPE
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 		For other debug macros we need information about the output mode. If user forget to set this information we
72cdf0e10cSrcweir 		do it for him. Valid values are:	LOGTYPE_FILECONTINUE
73cdf0e10cSrcweir 											LOGTYPE_FILEEXIT
74cdf0e10cSrcweir 											LOGTYPE_MESSAGEBOX
75cdf0e10cSrcweir 		The normal case is LOGTYPE_MESSAGEBOX to show assertions in normal manner!
76cdf0e10cSrcweir 	_____________________________________________________________________________________________________________*/
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	#define	LOGTYPE_MESSAGEBOX		1
79cdf0e10cSrcweir 	#define	LOGTYPE_FILECONTINUE	2
80cdf0e10cSrcweir 	#define	LOGTYPE_FILEEXIT		3
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 	#ifndef	LOGTYPE
83cdf0e10cSrcweir 		#define	LOGTYPE																							\
84cdf0e10cSrcweir 					LOGTYPE_MESSAGEBOX
85cdf0e10cSrcweir 	#endif
86cdf0e10cSrcweir 
87cdf0e10cSrcweir #else	// #ifdef ENABLE_LOGMECHANISM
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 	/*_____________________________________________________________________________________________________________
90cdf0e10cSrcweir 		If right testmode is'nt set - implements these macro empty!
91cdf0e10cSrcweir 	_____________________________________________________________________________________________________________*/
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 	#define	WRITE_LOGFILE( SFILENAME, STEXT )
94cdf0e10cSrcweir 	#undef	LOGTYPE
95cdf0e10cSrcweir 
96cdf0e10cSrcweir #endif	// #ifdef ENABLE_LOGMECHANISM
97cdf0e10cSrcweir 
98cdf0e10cSrcweir //*****************************************************************************************************************
99cdf0e10cSrcweir //	end of file
100cdf0e10cSrcweir //*****************************************************************************************************************
101cdf0e10cSrcweir 
102cdf0e10cSrcweir #endif	// #ifndef __FRAMEWORK_MACROS_DEBUG_LOGMECHANISM_HXX_
103