xref: /aoo41x/main/sal/inc/rtl/logfile.h (revision 514f4c20)
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 #ifndef _RTL_LOGFILE_H_
24 #define _RTL_LOGFILE_H_
25 
26 #include <sal/types.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 
33 /**	This function allows to log arbitrary messages even in a product-environment.
34 
35 	The logfile is created on first access and closed, when the sal-library gets unloaded.
36 	The file is line buffered. A log file is not created if no log messages are
37 	written.
38 
39 	The first time, rtl_logfile_trace is called, it checks for the bootstrap variable
40 	RTL_LOGFILE. If the variable is not empty, it creates a file with the name
41 	$(RTL_LOGFILE)_$(PID).log, where $(PID) is the process id of the running process.
42 
43 	@param pszformat A format string with fprintf-syntax
44 	@param ...       An arbitrary number of arguments for fprintf, matching the
45 	                 format string.
46 */
47 void SAL_CALL rtl_logfile_trace( const sal_Char* pszFormat, ... );
48 
49 /** Like rtl_logfile_trace, but prefixing every log entry with the current time
50     and thread ID.
51 
52 	@param format
53     a format string with fprintf-like syntax
54 
55 	@param ...
56     an arbitrary number of arguments for fprintf, matching the given format
57     string
58 
59     @since UDK 3.2.0
60 */
61 void SAL_CALL rtl_logfile_longTrace(char const * format, ...);
62 
63 /** Return if a log file is written.
64 
65 	@return true if a log file is written
66 
67     @since UDK 3.2.11
68 */
69 sal_Bool SAL_CALL rtl_logfile_hasLogFile( void );
70 
71 #ifdef __cplusplus
72 }
73 #endif
74 
75 #ifdef TIMELOG
76 #define RTL_LOGFILE_TRACE( string )  \
77              rtl_logfile_longTrace( "| : %s\n", string )
78 #define RTL_LOGFILE_TRACE1( frmt, arg1 ) \
79              rtl_logfile_longTrace( "| : " ); \
80              rtl_logfile_trace( frmt, arg1 ); \
81              rtl_logfile_trace( "\n" )
82 
83 #define RTL_LOGFILE_TRACE2( frmt, arg1 , arg2 ) \
84              rtl_logfile_longTrace( "| : " ); \
85              rtl_logfile_trace( frmt, arg1 , arg2 ); \
86              rtl_logfile_trace( "\n" )
87 #define RTL_LOGFILE_TRACE3( frmt, arg1 , arg2 , arg3 ) \
88              rtl_logfile_longTrace( "| : " ); \
89              rtl_logfile_trace( frmt, arg1 , arg2 , arg3 ); \
90              rtl_logfile_trace( "\n" )
91 
92 //	Now the macros with project and author arguments.  The strings
93 //	are formatted in a way, so that the log file can be parsed by
94 //	post processing scripts.
95 #define RTL_LOGFILE_TRACE_AUTHOR( project, author, string )  \
96              rtl_logfile_longTrace( "| %s (%s) : %s\n", \
97 								project,\
98 								author,\
99                                 string )
100 #define RTL_LOGFILE_TRACE_AUTHOR1( project, author, frmt, arg1 ) \
101              rtl_logfile_longTrace( "| %s (%s) : ", \
102 								project,\
103 								author );\
104              rtl_logfile_trace( frmt, arg1 ); \
105              rtl_logfile_trace( "\n" )
106 
107 #define RTL_LOGFILE_TRACE_AUTHOR2( project, author, frmt, arg1 , arg2 ) \
108              rtl_logfile_longTrace( "| %s (%s) : ", \
109 								project,\
110 								author ); \
111              rtl_logfile_trace( frmt, arg1 , arg2 ); \
112              rtl_logfile_trace( "\n" )
113 #define RTL_LOGFILE_TRACE_AUTHOR3( project, author, frmt, arg1 , arg2 , arg3 ) \
114              rtl_logfile_longTrace( "| %s (%s) : ", \
115 								project,\
116 								author ); \
117              rtl_logfile_trace( frmt, arg1 , arg2 , arg3 ); \
118              rtl_logfile_trace( "\n" )
119 #else
120 #define RTL_LOGFILE_TRACE( string )  ((void)0)
121 #define RTL_LOGFILE_TRACE1( frmt, arg1 ) ((void)0)
122 #define RTL_LOGFILE_TRACE2( frmt, arg1 , arg2 ) ((void)0)
123 #define RTL_LOGFILE_TRACE3( frmt, arg1 , arg2 , arg3 ) ((void)0)
124 
125 #define RTL_LOGFILE_TRACE_AUTHOR( project, author, string )  ((void)0)
126 #define RTL_LOGFILE_TRACE_AUTHOR1( project, author, frmt, arg1 ) ((void)0)
127 #define RTL_LOGFILE_TRACE_AUTHOR2( project, author, frmt, arg1 , arg2 ) ((void)0)
128 #define RTL_LOGFILE_TRACE_AUTHOR3( project, author, frmt, arg1 , arg2 , arg3 ) ((void)0)
129 #endif // TIMELOG
130 #endif
131