1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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
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
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
52 a format string with fprintf-like syntax
55 an arbitrary number of arguments for fprintf, matching the given format
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
68 SAL_DLLPUBLIC sal_Bool SAL_CALL
rtl_logfile_hasLogFile( void );
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", \
99 #define RTL_LOGFILE_TRACE_AUTHOR1( project, author, frmt, arg1 ) \
100 rtl_logfile_longTrace( "| %s (%s) : ", \
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) : ", \
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) : ", \
116 rtl_logfile_trace( frmt, arg1 , arg2 , arg3 ); \
117 rtl_logfile_trace( "\n" )
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)
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */