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