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  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 #ifndef _RTL_LOGFILE_HXX_
20 #define _RTL_LOGFILE_HXX_
21 
22 #include <rtl/logfile.h>
23 #include <rtl/string.hxx>
24 
25 namespace rtl
26 {
92  class Logfile
93  {
94  public:
95  inline Logfile( const sal_Char *name );
104  inline Logfile( const sal_Char *project, const sal_Char *author, const sal_Char *name );
105  inline ~Logfile();
106  inline const sal_Char *getName();
107  private:
108  ::rtl::OString m_sName;
109  };
110 
111  inline Logfile::Logfile( const sal_Char *name )
112  : m_sName( name )
113  {
114  rtl_logfile_longTrace( "{ %s\n", name );
115  }
116 
117  inline Logfile::Logfile( const sal_Char *project, const sal_Char *author, const sal_Char *name )
118  : m_sName( project)
119  {
120  m_sName += " (";
121  m_sName += author;
122  m_sName += ") ";
123  m_sName += name;
124  rtl_logfile_longTrace( "{ %s\n", m_sName.pData->buffer );
125  }
126 
128  {
129  rtl_logfile_longTrace( "} %s\n", m_sName.pData->buffer );
130  }
131 
132  inline const sal_Char * Logfile::getName()
133  {
134  return m_sName.getStr();
135  }
136 }
137 
138 #ifdef TIMELOG
139 #define RTL_LOGFILE_CONTEXT( instance, name ) ::rtl::Logfile instance( name )
140 #define RTL_LOGFILE_CONTEXT_AUTHOR( instance, project, author, name ) ::rtl::Logfile instance(project, author, name )
141 #define RTL_LOGFILE_CONTEXT_TRACE( instance, message ) \
142  rtl_logfile_longTrace( "| %s : %s\n", \
143  instance.getName(), \
144  message )
145 #define RTL_LOGFILE_CONTEXT_TRACE1( instance , frmt, arg1 ) \
146  rtl_logfile_longTrace( "| %s : ", \
147  instance.getName() ); \
148  rtl_logfile_trace( frmt , arg1 ); \
149  rtl_logfile_trace( "\n" )
150 #define RTL_LOGFILE_CONTEXT_TRACE2( instance , frmt, arg1 , arg2 ) \
151  rtl_logfile_longTrace( "| %s : ", \
152  instance.getName() ); \
153  rtl_logfile_trace( frmt , arg1 , arg2 ); \
154  rtl_logfile_trace( "\n" )
155 #define RTL_LOGFILE_CONTEXT_TRACE3( instance , frmt, arg1 , arg2 , arg3 ) \
156  rtl_logfile_longTrace( "| %s : ", \
157  instance.getName() ); \
158  rtl_logfile_trace( frmt , arg1 , arg2 , arg3 ); \
159  rtl_logfile_trace( "\n" )
160 
161 #else
162 #define RTL_LOGFILE_CONTEXT( instance, name ) ((void)0)
163 #define RTL_LOGFILE_CONTEXT_AUTHOR( instance, project, author, name ) ((void)0)
164 #define RTL_LOGFILE_CONTEXT_TRACE( instance, message ) ((void)0)
165 #define RTL_LOGFILE_CONTEXT_TRACE1( instance, frmt, arg1 ) ((void)arg1,(void)0)
166 #define RTL_LOGFILE_CONTEXT_TRACE2( instance, frmt, arg1, arg2 ) ((void)arg1,(void)arg2,(void)0)
167 #define RTL_LOGFILE_CONTEXT_TRACE3( instance, frmt, arg1, arg2 , arg3 ) ((void)arg1,(void)arg2,(void)arg3,(void)0)
168 #endif
169 
170 // Normal RTL_LOGFILE_* entries will not make it into release versions,
171 // TIMELOG is disabled a few versions prior relase build.
172 //
173 // We need some logs also in these builds, eg. for making performance regression tests.
174 //
175 // POLICY: Don't use RTL_LOGFILE_PRODUCT_* for your personal logging information.
176 // Be aware that these logs make it into the product shipped to customers.
177 // If you have good reasons for doing this, please contact product management.
178 
179 #define RTL_LOGFILE_PRODUCT_TRACE( string ) \
180  rtl_logfile_longTrace( "| : %s\n", string )
181 #define RTL_LOGFILE_PRODUCT_TRACE1( frmt, arg1 ) \
182  rtl_logfile_longTrace( "| : " ); \
183  rtl_logfile_trace( frmt, arg1 ); \
184  rtl_logfile_trace( "\n" )
185 #define RTL_LOGFILE_PRODUCT_CONTEXT( instance, name ) \
186  ::rtl::Logfile instance( name )
187 #define RTL_LOGFILE_PRODUCT_CONTEXT_TRACE1( instance, frmt, arg1 ) \
188  rtl_logfile_longTrace( "| %s : ", \
189  instance.getName() ); \
190  rtl_logfile_trace( frmt, arg1 ); \
191  rtl_logfile_trace( "\n" )
192 #define RTL_LOGFILE_HASLOGFILE() \
193  rtl_logfile_hasLogFile()
194 
195 
196 #endif
197 
198 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */