1*514f4c20SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*514f4c20SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*514f4c20SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*514f4c20SAndrew Rist * distributed with this work for additional information 6*514f4c20SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*514f4c20SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*514f4c20SAndrew Rist * "License"); you may not use this file except in compliance 9*514f4c20SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*514f4c20SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*514f4c20SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*514f4c20SAndrew Rist * software distributed under the License is distributed on an 15*514f4c20SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*514f4c20SAndrew Rist * KIND, either express or implied. See the License for the 17*514f4c20SAndrew Rist * specific language governing permissions and limitations 18*514f4c20SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*514f4c20SAndrew Rist *************************************************************/ 21*514f4c20SAndrew Rist 22*514f4c20SAndrew Rist 23cdf0e10cSrcweir #ifndef _RTL_LOGFILE_H_ 24cdf0e10cSrcweir #define _RTL_LOGFILE_H_ 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <sal/types.h> 27cdf0e10cSrcweir 28cdf0e10cSrcweir #ifdef __cplusplus 29cdf0e10cSrcweir extern "C" { 30cdf0e10cSrcweir #endif 31cdf0e10cSrcweir 32cdf0e10cSrcweir 33cdf0e10cSrcweir /** This function allows to log arbitrary messages even in a product-environment. 34cdf0e10cSrcweir 35cdf0e10cSrcweir The logfile is created on first access and closed, when the sal-library gets unloaded. 36cdf0e10cSrcweir The file is line buffered. A log file is not created if no log messages are 37cdf0e10cSrcweir written. 38cdf0e10cSrcweir 39cdf0e10cSrcweir The first time, rtl_logfile_trace is called, it checks for the bootstrap variable 40cdf0e10cSrcweir RTL_LOGFILE. If the variable is not empty, it creates a file with the name 41cdf0e10cSrcweir $(RTL_LOGFILE)_$(PID).log, where $(PID) is the process id of the running process. 42cdf0e10cSrcweir 43cdf0e10cSrcweir @param pszformat A format string with fprintf-syntax 44cdf0e10cSrcweir @param ... An arbitrary number of arguments for fprintf, matching the 45cdf0e10cSrcweir format string. 46cdf0e10cSrcweir */ 47cdf0e10cSrcweir void SAL_CALL rtl_logfile_trace( const sal_Char* pszFormat, ... ); 48cdf0e10cSrcweir 49cdf0e10cSrcweir /** Like rtl_logfile_trace, but prefixing every log entry with the current time 50cdf0e10cSrcweir and thread ID. 51cdf0e10cSrcweir 52cdf0e10cSrcweir @param format 53cdf0e10cSrcweir a format string with fprintf-like syntax 54cdf0e10cSrcweir 55cdf0e10cSrcweir @param ... 56cdf0e10cSrcweir an arbitrary number of arguments for fprintf, matching the given format 57cdf0e10cSrcweir string 58cdf0e10cSrcweir 59cdf0e10cSrcweir @since UDK 3.2.0 60cdf0e10cSrcweir */ 61cdf0e10cSrcweir void SAL_CALL rtl_logfile_longTrace(char const * format, ...); 62cdf0e10cSrcweir 63cdf0e10cSrcweir /** Return if a log file is written. 64cdf0e10cSrcweir 65cdf0e10cSrcweir @return true if a log file is written 66cdf0e10cSrcweir 67cdf0e10cSrcweir @since UDK 3.2.11 68cdf0e10cSrcweir */ 69cdf0e10cSrcweir sal_Bool SAL_CALL rtl_logfile_hasLogFile( void ); 70cdf0e10cSrcweir 71cdf0e10cSrcweir #ifdef __cplusplus 72cdf0e10cSrcweir } 73cdf0e10cSrcweir #endif 74cdf0e10cSrcweir 75cdf0e10cSrcweir #ifdef TIMELOG 76cdf0e10cSrcweir #define RTL_LOGFILE_TRACE( string ) \ 77cdf0e10cSrcweir rtl_logfile_longTrace( "| : %s\n", string ) 78cdf0e10cSrcweir #define RTL_LOGFILE_TRACE1( frmt, arg1 ) \ 79cdf0e10cSrcweir rtl_logfile_longTrace( "| : " ); \ 80cdf0e10cSrcweir rtl_logfile_trace( frmt, arg1 ); \ 81cdf0e10cSrcweir rtl_logfile_trace( "\n" ) 82cdf0e10cSrcweir 83cdf0e10cSrcweir #define RTL_LOGFILE_TRACE2( frmt, arg1 , arg2 ) \ 84cdf0e10cSrcweir rtl_logfile_longTrace( "| : " ); \ 85cdf0e10cSrcweir rtl_logfile_trace( frmt, arg1 , arg2 ); \ 86cdf0e10cSrcweir rtl_logfile_trace( "\n" ) 87cdf0e10cSrcweir #define RTL_LOGFILE_TRACE3( frmt, arg1 , arg2 , arg3 ) \ 88cdf0e10cSrcweir rtl_logfile_longTrace( "| : " ); \ 89cdf0e10cSrcweir rtl_logfile_trace( frmt, arg1 , arg2 , arg3 ); \ 90cdf0e10cSrcweir rtl_logfile_trace( "\n" ) 91cdf0e10cSrcweir 92cdf0e10cSrcweir // Now the macros with project and author arguments. The strings 93cdf0e10cSrcweir // are formatted in a way, so that the log file can be parsed by 94cdf0e10cSrcweir // post processing scripts. 95cdf0e10cSrcweir #define RTL_LOGFILE_TRACE_AUTHOR( project, author, string ) \ 96cdf0e10cSrcweir rtl_logfile_longTrace( "| %s (%s) : %s\n", \ 97cdf0e10cSrcweir project,\ 98cdf0e10cSrcweir author,\ 99cdf0e10cSrcweir string ) 100cdf0e10cSrcweir #define RTL_LOGFILE_TRACE_AUTHOR1( project, author, frmt, arg1 ) \ 101cdf0e10cSrcweir rtl_logfile_longTrace( "| %s (%s) : ", \ 102cdf0e10cSrcweir project,\ 103cdf0e10cSrcweir author );\ 104cdf0e10cSrcweir rtl_logfile_trace( frmt, arg1 ); \ 105cdf0e10cSrcweir rtl_logfile_trace( "\n" ) 106cdf0e10cSrcweir 107cdf0e10cSrcweir #define RTL_LOGFILE_TRACE_AUTHOR2( project, author, frmt, arg1 , arg2 ) \ 108cdf0e10cSrcweir rtl_logfile_longTrace( "| %s (%s) : ", \ 109cdf0e10cSrcweir project,\ 110cdf0e10cSrcweir author ); \ 111cdf0e10cSrcweir rtl_logfile_trace( frmt, arg1 , arg2 ); \ 112cdf0e10cSrcweir rtl_logfile_trace( "\n" ) 113cdf0e10cSrcweir #define RTL_LOGFILE_TRACE_AUTHOR3( project, author, frmt, arg1 , arg2 , arg3 ) \ 114cdf0e10cSrcweir rtl_logfile_longTrace( "| %s (%s) : ", \ 115cdf0e10cSrcweir project,\ 116cdf0e10cSrcweir author ); \ 117cdf0e10cSrcweir rtl_logfile_trace( frmt, arg1 , arg2 , arg3 ); \ 118cdf0e10cSrcweir rtl_logfile_trace( "\n" ) 119cdf0e10cSrcweir #else 120cdf0e10cSrcweir #define RTL_LOGFILE_TRACE( string ) ((void)0) 121cdf0e10cSrcweir #define RTL_LOGFILE_TRACE1( frmt, arg1 ) ((void)0) 122cdf0e10cSrcweir #define RTL_LOGFILE_TRACE2( frmt, arg1 , arg2 ) ((void)0) 123cdf0e10cSrcweir #define RTL_LOGFILE_TRACE3( frmt, arg1 , arg2 , arg3 ) ((void)0) 124cdf0e10cSrcweir 125cdf0e10cSrcweir #define RTL_LOGFILE_TRACE_AUTHOR( project, author, string ) ((void)0) 126cdf0e10cSrcweir #define RTL_LOGFILE_TRACE_AUTHOR1( project, author, frmt, arg1 ) ((void)0) 127cdf0e10cSrcweir #define RTL_LOGFILE_TRACE_AUTHOR2( project, author, frmt, arg1 , arg2 ) ((void)0) 128cdf0e10cSrcweir #define RTL_LOGFILE_TRACE_AUTHOR3( project, author, frmt, arg1 , arg2 , arg3 ) ((void)0) 129cdf0e10cSrcweir #endif // TIMELOG 130cdf0e10cSrcweir #endif 131