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