bump product version to 4.2.0.1
[LibreOffice.git] / include / rtl / logfile.h
blobf9bd101304db96f78b143c35216b5c988b901d71
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_RTL_LOGFILE_H
20 #define INCLUDED_RTL_LOGFILE_H
22 #include <sal/config.h>
24 #include <sal/saldllapi.h>
25 #include <sal/types.h>
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
32 /** This function allows to log arbitrary messages even in a product-environment.
34 The logfile is created on first access and closed, when the sal-library gets unloaded.
35 The file is line buffered. A log file is not created if no log messages are
36 written.
38 The first time, rtl_logfile_trace is called, it checks for the bootstrap variable
39 RTL_LOGFILE. If the variable is not empty, it creates a file with the name
40 $(RTL_LOGFILE)_$(PID).log, where $(PID) is the process id of the running process.
42 @param pszFormat A format string with fprintf-syntax
43 @param ... An arbitrary number of arguments for fprintf, matching the
44 format string.
46 SAL_DLLPUBLIC void SAL_CALL rtl_logfile_trace( const sal_Char* pszFormat, ... );
48 /** Like rtl_logfile_trace, but prefixing every log entry with the current time
49 and thread ID.
51 @param format
52 a format string with fprintf-like syntax
54 @param ...
55 an arbitrary number of arguments for fprintf, matching the given format
56 string
58 @since UDK 3.2.0
60 SAL_DLLPUBLIC void SAL_CALL rtl_logfile_longTrace(char const * format, ...);
62 /** Return if a log file is written.
64 @return true if a log file is written
66 @since UDK 3.2.11
68 SAL_DLLPUBLIC sal_Bool SAL_CALL rtl_logfile_hasLogFile( void );
70 #ifdef __cplusplus
72 #endif
74 #ifdef TIMELOG
75 #define RTL_LOGFILE_TRACE( string ) \
76 rtl_logfile_longTrace( "| : %s\n", string )
77 #define RTL_LOGFILE_TRACE1( frmt, arg1 ) \
78 rtl_logfile_longTrace( "| : " ); \
79 rtl_logfile_trace( frmt, arg1 ); \
80 rtl_logfile_trace( "\n" )
82 #define RTL_LOGFILE_TRACE2( frmt, arg1 , arg2 ) \
83 rtl_logfile_longTrace( "| : " ); \
84 rtl_logfile_trace( frmt, arg1 , arg2 ); \
85 rtl_logfile_trace( "\n" )
86 #define RTL_LOGFILE_TRACE3( frmt, arg1 , arg2 , arg3 ) \
87 rtl_logfile_longTrace( "| : " ); \
88 rtl_logfile_trace( frmt, arg1 , arg2 , arg3 ); \
89 rtl_logfile_trace( "\n" )
91 // Now the macros with project and author arguments. The strings
92 // are formatted in a way, so that the log file can be parsed by
93 // post processing scripts.
94 #define RTL_LOGFILE_TRACE_AUTHOR( project, author, string ) \
95 rtl_logfile_longTrace( "| %s (%s) : %s\n", \
96 project,\
97 author,\
98 string )
99 #define RTL_LOGFILE_TRACE_AUTHOR1( project, author, frmt, arg1 ) \
100 rtl_logfile_longTrace( "| %s (%s) : ", \
101 project,\
102 author );\
103 rtl_logfile_trace( frmt, arg1 ); \
104 rtl_logfile_trace( "\n" )
106 #define RTL_LOGFILE_TRACE_AUTHOR2( project, author, frmt, arg1 , arg2 ) \
107 rtl_logfile_longTrace( "| %s (%s) : ", \
108 project,\
109 author ); \
110 rtl_logfile_trace( frmt, arg1 , arg2 ); \
111 rtl_logfile_trace( "\n" )
112 #define RTL_LOGFILE_TRACE_AUTHOR3( project, author, frmt, arg1 , arg2 , arg3 ) \
113 rtl_logfile_longTrace( "| %s (%s) : ", \
114 project,\
115 author ); \
116 rtl_logfile_trace( frmt, arg1 , arg2 , arg3 ); \
117 rtl_logfile_trace( "\n" )
118 #else
119 #define RTL_LOGFILE_TRACE( string ) ((void)0)
120 #define RTL_LOGFILE_TRACE1( frmt, arg1 ) ((void)0)
121 #define RTL_LOGFILE_TRACE2( frmt, arg1 , arg2 ) ((void)0)
122 #define RTL_LOGFILE_TRACE3( frmt, arg1 , arg2 , arg3 ) ((void)0)
124 #define RTL_LOGFILE_TRACE_AUTHOR( project, author, string ) ((void)0)
125 #define RTL_LOGFILE_TRACE_AUTHOR1( project, author, frmt, arg1 ) ((void)0)
126 #define RTL_LOGFILE_TRACE_AUTHOR2( project, author, frmt, arg1 , arg2 ) ((void)0)
127 #define RTL_LOGFILE_TRACE_AUTHOR3( project, author, frmt, arg1 , arg2 , arg3 ) ((void)0)
128 #endif // TIMELOG
129 #endif
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */