My Project
UDK 3.2.7 C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
logfile.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * Copyright 2000, 2010 Oracle and/or its affiliates.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * This file is part of OpenOffice.org.
11  *
12  * OpenOffice.org is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 3
14  * only, as published by the Free Software Foundation.
15  *
16  * OpenOffice.org is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License version 3 for more details
20  * (a copy is included in the LICENSE file that accompanied this code).
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * version 3 along with OpenOffice.org. If not, see
24  * <http://www.openoffice.org/license.html>
25  * for a copy of the LGPLv3 License.
26  *
27  ************************************************************************/
28 #ifndef _RTL_LOGFILE_HXX_
29 #define _RTL_LOGFILE_HXX_
30 
31 #include <rtl/logfile.h>
32 #include <rtl/string.hxx>
33 
34 namespace rtl
35 {
101  class Logfile
102  {
103  public:
104  inline Logfile( const sal_Char *name );
113  inline Logfile( const sal_Char *project, const sal_Char *author, const sal_Char *name );
114  inline ~Logfile();
115  inline const sal_Char *getName();
116  private:
117  ::rtl::OString m_sName;
118  };
119 
120  inline Logfile::Logfile( const sal_Char *name )
121  : m_sName( name )
122  {
123  rtl_logfile_longTrace( "{ %s\n", name );
124  }
125 
126  inline Logfile::Logfile( const sal_Char *project, const sal_Char *author, const sal_Char *name )
127  : m_sName( project)
128  {
129  m_sName += " (";
130  m_sName += author;
131  m_sName += ") ";
132  m_sName += name;
133  rtl_logfile_longTrace( "{ %s\n", m_sName.pData->buffer );
134  }
135 
137  {
138  rtl_logfile_longTrace( "} %s\n", m_sName.pData->buffer );
139  }
140 
141  inline const sal_Char * Logfile::getName()
142  {
143  return m_sName.getStr();
144  }
145 }
146 
147 #ifdef TIMELOG
148 #define RTL_LOGFILE_CONTEXT( instance, name ) ::rtl::Logfile instance( name )
149 #define RTL_LOGFILE_CONTEXT_AUTHOR( instance, project, author, name ) ::rtl::Logfile instance(project, author, name )
150 #define RTL_LOGFILE_CONTEXT_TRACE( instance, message ) \
151  rtl_logfile_longTrace( "| %s : %s\n", \
152  instance.getName(), \
153  message )
154 #define RTL_LOGFILE_CONTEXT_TRACE1( instance , frmt, arg1 ) \
155  rtl_logfile_longTrace( "| %s : ", \
156  instance.getName() ); \
157  rtl_logfile_trace( frmt , arg1 ); \
158  rtl_logfile_trace( "\n" )
159 #define RTL_LOGFILE_CONTEXT_TRACE2( instance , frmt, arg1 , arg2 ) \
160  rtl_logfile_longTrace( "| %s : ", \
161  instance.getName() ); \
162  rtl_logfile_trace( frmt , arg1 , arg2 ); \
163  rtl_logfile_trace( "\n" )
164 #define RTL_LOGFILE_CONTEXT_TRACE3( instance , frmt, arg1 , arg2 , arg3 ) \
165  rtl_logfile_longTrace( "| %s : ", \
166  instance.getName() ); \
167  rtl_logfile_trace( frmt , arg1 , arg2 , arg3 ); \
168  rtl_logfile_trace( "\n" )
169 
170 #else
171 #define RTL_LOGFILE_CONTEXT( instance, name ) ((void)0)
172 #define RTL_LOGFILE_CONTEXT_AUTHOR( instance, project, author, name ) ((void)0)
173 #define RTL_LOGFILE_CONTEXT_TRACE( instance, message ) ((void)0)
174 #define RTL_LOGFILE_CONTEXT_TRACE1( instance, frmt, arg1 ) ((void)0)
175 #define RTL_LOGFILE_CONTEXT_TRACE2( instance, frmt, arg1, arg2 ) ((void)0)
176 #define RTL_LOGFILE_CONTEXT_TRACE3( instance, frmt, arg1, arg2 , arg3 ) ((void)0)
177 #endif
178 
179 // Normal RTL_LOGFILE_* entries will not make it into release versions,
180 // TIMELOG is disabled a few versions prior relase build.
181 //
182 // We need some logs also in these builds, eg. for making performance regression tests.
183 //
184 // POLICY: Don't use RTL_LOGFILE_PRODUCT_* for your personal logging information.
185 // Be aware that these logs make it into the product shipped to customers.
186 // If you have good reasons for doing this, please contact product management.
187 
188 #define RTL_LOGFILE_PRODUCT_TRACE( string ) \
189  rtl_logfile_longTrace( "| : %s\n", string )
190 #define RTL_LOGFILE_PRODUCT_TRACE1( frmt, arg1 ) \
191  rtl_logfile_longTrace( "| : " ); \
192  rtl_logfile_trace( frmt, arg1 ); \
193  rtl_logfile_trace( "\n" )
194 #define RTL_LOGFILE_PRODUCT_CONTEXT( instance, name ) \
195  ::rtl::Logfile instance( name )
196 #define RTL_LOGFILE_PRODUCT_CONTEXT_TRACE1( instance, frmt, arg1 ) \
197  rtl_logfile_longTrace( "| %s : ", \
198  instance.getName() ); \
199  rtl_logfile_trace( frmt, arg1 ); \
200  rtl_logfile_trace( "\n" )
201 #define RTL_LOGFILE_HASLOGFILE() \
202  rtl_logfile_hasLogFile()
203 
204 
205 #endif
206 
207 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */