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: logfile.h,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 ************************************************************************/
30 #ifndef _RTL_LOGFILE_H_
31 #define _RTL_LOGFILE_H_
33 #include <sal/types.h>
40 /** This function allows to log arbitrary messages even in a product-environment.
42 The logfile is created on first access and closed, when the sal-library gets unloaded.
43 The file is line buffered. A log file is not created if no log messages are
46 The first time, rtl_logfile_trace is called, it checks for the bootstrap variable
47 RTL_LOGFILE. If the variable is not empty, it creates a file with the name
48 $(RTL_LOGFILE)_$(PID).log, where $(PID) is the process id of the running process.
50 @param pszformat A format string with fprintf-syntax
51 @param ... An arbitrary number of arguments for fprintf, matching the
54 void SAL_CALL
rtl_logfile_trace( const sal_Char
* pszFormat
, ... );
56 /** Like rtl_logfile_trace, but prefixing every log entry with the current time
60 a format string with fprintf-like syntax
63 an arbitrary number of arguments for fprintf, matching the given format
68 void SAL_CALL
rtl_logfile_longTrace(char const * format
, ...);
70 /** Return if a log file is written.
72 @return true if a log file is written
76 sal_Bool SAL_CALL
rtl_logfile_hasLogFile( void );
83 #define RTL_LOGFILE_TRACE( string ) \
84 rtl_logfile_longTrace( "| : %s\n", string )
85 #define RTL_LOGFILE_TRACE1( frmt, arg1 ) \
86 rtl_logfile_longTrace( "| : " ); \
87 rtl_logfile_trace( frmt, arg1 ); \
88 rtl_logfile_trace( "\n" )
90 #define RTL_LOGFILE_TRACE2( frmt, arg1 , arg2 ) \
91 rtl_logfile_longTrace( "| : " ); \
92 rtl_logfile_trace( frmt, arg1 , arg2 ); \
93 rtl_logfile_trace( "\n" )
94 #define RTL_LOGFILE_TRACE3( frmt, arg1 , arg2 , arg3 ) \
95 rtl_logfile_longTrace( "| : " ); \
96 rtl_logfile_trace( frmt, arg1 , arg2 , arg3 ); \
97 rtl_logfile_trace( "\n" )
99 // Now the macros with project and author arguments. The strings
100 // are formatted in a way, so that the log file can be parsed by
101 // post processing scripts.
102 #define RTL_LOGFILE_TRACE_AUTHOR( project, author, string ) \
103 rtl_logfile_longTrace( "| %s (%s) : %s\n", \
107 #define RTL_LOGFILE_TRACE_AUTHOR1( project, author, frmt, arg1 ) \
108 rtl_logfile_longTrace( "| %s (%s) : ", \
111 rtl_logfile_trace( frmt, arg1 ); \
112 rtl_logfile_trace( "\n" )
114 #define RTL_LOGFILE_TRACE_AUTHOR2( project, author, frmt, arg1 , arg2 ) \
115 rtl_logfile_longTrace( "| %s (%s) : ", \
118 rtl_logfile_trace( frmt, arg1 , arg2 ); \
119 rtl_logfile_trace( "\n" )
120 #define RTL_LOGFILE_TRACE_AUTHOR3( project, author, frmt, arg1 , arg2 , arg3 ) \
121 rtl_logfile_longTrace( "| %s (%s) : ", \
124 rtl_logfile_trace( frmt, arg1 , arg2 , arg3 ); \
125 rtl_logfile_trace( "\n" )
127 #define RTL_LOGFILE_TRACE( string ) ((void)0)
128 #define RTL_LOGFILE_TRACE1( frmt, arg1 ) ((void)0)
129 #define RTL_LOGFILE_TRACE2( frmt, arg1 , arg2 ) ((void)0)
130 #define RTL_LOGFILE_TRACE3( frmt, arg1 , arg2 , arg3 ) ((void)0)
132 #define RTL_LOGFILE_TRACE_AUTHOR( project, author, string ) ((void)0)
133 #define RTL_LOGFILE_TRACE_AUTHOR1( project, author, frmt, arg1 ) ((void)0)
134 #define RTL_LOGFILE_TRACE_AUTHOR2( project, author, frmt, arg1 , arg2 ) ((void)0)
135 #define RTL_LOGFILE_TRACE_AUTHOR3( project, author, frmt, arg1 , arg2 , arg3 ) ((void)0)