xref: /AOO41X/main/sal/inc/rtl/logfile.h (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef _RTL_LOGFILE_H_
28*cdf0e10cSrcweir #define _RTL_LOGFILE_H_
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <sal/types.h>
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #ifdef __cplusplus
33*cdf0e10cSrcweir extern "C" {
34*cdf0e10cSrcweir #endif
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir /**	This function allows to log arbitrary messages even in a product-environment.
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir 	The logfile is created on first access and closed, when the sal-library gets unloaded.
40*cdf0e10cSrcweir 	The file is line buffered. A log file is not created if no log messages are
41*cdf0e10cSrcweir 	written.
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir 	The first time, rtl_logfile_trace is called, it checks for the bootstrap variable
44*cdf0e10cSrcweir 	RTL_LOGFILE. If the variable is not empty, it creates a file with the name
45*cdf0e10cSrcweir 	$(RTL_LOGFILE)_$(PID).log, where $(PID) is the process id of the running process.
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir 	@param pszformat A format string with fprintf-syntax
48*cdf0e10cSrcweir 	@param ...       An arbitrary number of arguments for fprintf, matching the
49*cdf0e10cSrcweir 	                 format string.
50*cdf0e10cSrcweir */
51*cdf0e10cSrcweir void SAL_CALL rtl_logfile_trace( const sal_Char* pszFormat, ... );
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir /** Like rtl_logfile_trace, but prefixing every log entry with the current time
54*cdf0e10cSrcweir     and thread ID.
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir 	@param format
57*cdf0e10cSrcweir     a format string with fprintf-like syntax
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir 	@param ...
60*cdf0e10cSrcweir     an arbitrary number of arguments for fprintf, matching the given format
61*cdf0e10cSrcweir     string
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir     @since UDK 3.2.0
64*cdf0e10cSrcweir */
65*cdf0e10cSrcweir void SAL_CALL rtl_logfile_longTrace(char const * format, ...);
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir /** Return if a log file is written.
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir 	@return true if a log file is written
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir     @since UDK 3.2.11
72*cdf0e10cSrcweir */
73*cdf0e10cSrcweir sal_Bool SAL_CALL rtl_logfile_hasLogFile( void );
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir #ifdef __cplusplus
76*cdf0e10cSrcweir }
77*cdf0e10cSrcweir #endif
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir #ifdef TIMELOG
80*cdf0e10cSrcweir #define RTL_LOGFILE_TRACE( string )  \
81*cdf0e10cSrcweir              rtl_logfile_longTrace( "| : %s\n", string )
82*cdf0e10cSrcweir #define RTL_LOGFILE_TRACE1( frmt, arg1 ) \
83*cdf0e10cSrcweir              rtl_logfile_longTrace( "| : " ); \
84*cdf0e10cSrcweir              rtl_logfile_trace( frmt, arg1 ); \
85*cdf0e10cSrcweir              rtl_logfile_trace( "\n" )
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir #define RTL_LOGFILE_TRACE2( frmt, arg1 , arg2 ) \
88*cdf0e10cSrcweir              rtl_logfile_longTrace( "| : " ); \
89*cdf0e10cSrcweir              rtl_logfile_trace( frmt, arg1 , arg2 ); \
90*cdf0e10cSrcweir              rtl_logfile_trace( "\n" )
91*cdf0e10cSrcweir #define RTL_LOGFILE_TRACE3( frmt, arg1 , arg2 , arg3 ) \
92*cdf0e10cSrcweir              rtl_logfile_longTrace( "| : " ); \
93*cdf0e10cSrcweir              rtl_logfile_trace( frmt, arg1 , arg2 , arg3 ); \
94*cdf0e10cSrcweir              rtl_logfile_trace( "\n" )
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir //	Now the macros with project and author arguments.  The strings
97*cdf0e10cSrcweir //	are formatted in a way, so that the log file can be parsed by
98*cdf0e10cSrcweir //	post processing scripts.
99*cdf0e10cSrcweir #define RTL_LOGFILE_TRACE_AUTHOR( project, author, string )  \
100*cdf0e10cSrcweir              rtl_logfile_longTrace( "| %s (%s) : %s\n", \
101*cdf0e10cSrcweir 								project,\
102*cdf0e10cSrcweir 								author,\
103*cdf0e10cSrcweir                                 string )
104*cdf0e10cSrcweir #define RTL_LOGFILE_TRACE_AUTHOR1( project, author, frmt, arg1 ) \
105*cdf0e10cSrcweir              rtl_logfile_longTrace( "| %s (%s) : ", \
106*cdf0e10cSrcweir 								project,\
107*cdf0e10cSrcweir 								author );\
108*cdf0e10cSrcweir              rtl_logfile_trace( frmt, arg1 ); \
109*cdf0e10cSrcweir              rtl_logfile_trace( "\n" )
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir #define RTL_LOGFILE_TRACE_AUTHOR2( project, author, frmt, arg1 , arg2 ) \
112*cdf0e10cSrcweir              rtl_logfile_longTrace( "| %s (%s) : ", \
113*cdf0e10cSrcweir 								project,\
114*cdf0e10cSrcweir 								author ); \
115*cdf0e10cSrcweir              rtl_logfile_trace( frmt, arg1 , arg2 ); \
116*cdf0e10cSrcweir              rtl_logfile_trace( "\n" )
117*cdf0e10cSrcweir #define RTL_LOGFILE_TRACE_AUTHOR3( project, author, frmt, arg1 , arg2 , arg3 ) \
118*cdf0e10cSrcweir              rtl_logfile_longTrace( "| %s (%s) : ", \
119*cdf0e10cSrcweir 								project,\
120*cdf0e10cSrcweir 								author ); \
121*cdf0e10cSrcweir              rtl_logfile_trace( frmt, arg1 , arg2 , arg3 ); \
122*cdf0e10cSrcweir              rtl_logfile_trace( "\n" )
123*cdf0e10cSrcweir #else
124*cdf0e10cSrcweir #define RTL_LOGFILE_TRACE( string )  ((void)0)
125*cdf0e10cSrcweir #define RTL_LOGFILE_TRACE1( frmt, arg1 ) ((void)0)
126*cdf0e10cSrcweir #define RTL_LOGFILE_TRACE2( frmt, arg1 , arg2 ) ((void)0)
127*cdf0e10cSrcweir #define RTL_LOGFILE_TRACE3( frmt, arg1 , arg2 , arg3 ) ((void)0)
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir #define RTL_LOGFILE_TRACE_AUTHOR( project, author, string )  ((void)0)
130*cdf0e10cSrcweir #define RTL_LOGFILE_TRACE_AUTHOR1( project, author, frmt, arg1 ) ((void)0)
131*cdf0e10cSrcweir #define RTL_LOGFILE_TRACE_AUTHOR2( project, author, frmt, arg1 , arg2 ) ((void)0)
132*cdf0e10cSrcweir #define RTL_LOGFILE_TRACE_AUTHOR3( project, author, frmt, arg1 , arg2 , arg3 ) ((void)0)
133*cdf0e10cSrcweir #endif // TIMELOG
134*cdf0e10cSrcweir #endif
135