1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef __FRAMEWORK_MACROS_DEBUG_LOGMECHANISM_HXX_ 29 #define __FRAMEWORK_MACROS_DEBUG_LOGMECHANISM_HXX_ 30 31 //***************************************************************************************************************** 32 // generic macros for logging 33 //***************************************************************************************************************** 34 35 #ifdef ENABLE_LOGMECHANISM 36 37 //_____________________________________________________________________________________________________________ 38 // includes 39 //_____________________________________________________________________________________________________________ 40 41 #ifndef _RTL_STRING_HXX_ 42 #include <rtl/string.hxx> 43 #endif 44 45 #include <stdio.h> 46 47 /*_____________________________________________________________________________________________________________ 48 WRITE_LOGFILE( SFILENAME, STEXT ) 49 50 Log any information in file. We append any information at file and don't clear it anymore. 51 ( Use new scope in macro to declare pFile more then on time in same "parentscope"! 52 Don't control pFile before access! What will you doing if its not valid? Log an error ... 53 An error and an error is an error ... ) 54 55 Attention: You must use "%s" and STEXT as parameter ... because otherwise encoded strings (they include e.g. %...) 56 are handled wrong. 57 _____________________________________________________________________________________________________________*/ 58 59 #define WRITE_LOGFILE( SFILENAME, STEXT ) \ 60 { \ 61 ::rtl::OString _swriteLogfileFileName ( SFILENAME ); \ 62 ::rtl::OString _swriteLogfileText ( STEXT ); \ 63 FILE* pFile = fopen( _swriteLogfileFileName.getStr(), "a" ); \ 64 fprintf( pFile, "%s", _swriteLogfileText.getStr() ); \ 65 fclose ( pFile ); \ 66 } 67 68 /*_____________________________________________________________________________________________________________ 69 LOGTYPE 70 71 For other debug macros we need information about the output mode. If user forget to set this information we 72 do it for him. Valid values are: LOGTYPE_FILECONTINUE 73 LOGTYPE_FILEEXIT 74 LOGTYPE_MESSAGEBOX 75 The normal case is LOGTYPE_MESSAGEBOX to show assertions in normal manner! 76 _____________________________________________________________________________________________________________*/ 77 78 #define LOGTYPE_MESSAGEBOX 1 79 #define LOGTYPE_FILECONTINUE 2 80 #define LOGTYPE_FILEEXIT 3 81 82 #ifndef LOGTYPE 83 #define LOGTYPE \ 84 LOGTYPE_MESSAGEBOX 85 #endif 86 87 #else // #ifdef ENABLE_LOGMECHANISM 88 89 /*_____________________________________________________________________________________________________________ 90 If right testmode is'nt set - implements these macro empty! 91 _____________________________________________________________________________________________________________*/ 92 93 #define WRITE_LOGFILE( SFILENAME, STEXT ) 94 #undef LOGTYPE 95 96 #endif // #ifdef ENABLE_LOGMECHANISM 97 98 //***************************************************************************************************************** 99 // end of file 100 //***************************************************************************************************************** 101 102 #endif // #ifndef __FRAMEWORK_MACROS_DEBUG_LOGMECHANISM_HXX_ 103