|
UDK 3.2.7 C/C++ API Reference
|
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 00002 /* 00003 * This file is part of the LibreOffice project. 00004 * 00005 * This Source Code Form is subject to the terms of the Mozilla Public 00006 * License, v. 2.0. If a copy of the MPL was not distributed with this 00007 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 00008 * 00009 * This file incorporates work covered by the following license notice: 00010 * 00011 * Licensed to the Apache Software Foundation (ASF) under one or more 00012 * contributor license agreements. See the NOTICE file distributed 00013 * with this work for additional information regarding copyright 00014 * ownership. The ASF licenses this file to you under the Apache 00015 * License, Version 2.0 (the "License"); you may not use this file 00016 * except in compliance with the License. You may obtain a copy of 00017 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 00018 */ 00019 #ifndef _RTL_LOGFILE_HXX_ 00020 #define _RTL_LOGFILE_HXX_ 00021 00022 #include <rtl/logfile.h> 00023 #include <rtl/string.hxx> 00024 00025 namespace rtl 00026 { 00092 class Logfile 00093 { 00094 public: 00095 inline Logfile( const sal_Char *name ); 00104 inline Logfile( const sal_Char *project, const sal_Char *author, const sal_Char *name ); 00105 inline ~Logfile(); 00106 inline const sal_Char *getName(); 00107 private: 00108 ::rtl::OString m_sName; 00109 }; 00110 00111 inline Logfile::Logfile( const sal_Char *name ) 00112 : m_sName( name ) 00113 { 00114 rtl_logfile_longTrace( "{ %s\n", name ); 00115 } 00116 00117 inline Logfile::Logfile( const sal_Char *project, const sal_Char *author, const sal_Char *name ) 00118 : m_sName( project) 00119 { 00120 m_sName += " ("; 00121 m_sName += author; 00122 m_sName += ") "; 00123 m_sName += name; 00124 rtl_logfile_longTrace( "{ %s\n", m_sName.pData->buffer ); 00125 } 00126 00127 inline Logfile::~Logfile() 00128 { 00129 rtl_logfile_longTrace( "} %s\n", m_sName.pData->buffer ); 00130 } 00131 00132 inline const sal_Char * Logfile::getName() 00133 { 00134 return m_sName.getStr(); 00135 } 00136 } 00137 00138 #ifdef TIMELOG 00139 #define RTL_LOGFILE_CONTEXT( instance, name ) ::rtl::Logfile instance( name ) 00140 #define RTL_LOGFILE_CONTEXT_AUTHOR( instance, project, author, name ) ::rtl::Logfile instance(project, author, name ) 00141 #define RTL_LOGFILE_CONTEXT_TRACE( instance, message ) \ 00142 rtl_logfile_longTrace( "| %s : %s\n", \ 00143 instance.getName(), \ 00144 message ) 00145 #define RTL_LOGFILE_CONTEXT_TRACE1( instance , frmt, arg1 ) \ 00146 rtl_logfile_longTrace( "| %s : ", \ 00147 instance.getName() ); \ 00148 rtl_logfile_trace( frmt , arg1 ); \ 00149 rtl_logfile_trace( "\n" ) 00150 #define RTL_LOGFILE_CONTEXT_TRACE2( instance , frmt, arg1 , arg2 ) \ 00151 rtl_logfile_longTrace( "| %s : ", \ 00152 instance.getName() ); \ 00153 rtl_logfile_trace( frmt , arg1 , arg2 ); \ 00154 rtl_logfile_trace( "\n" ) 00155 #define RTL_LOGFILE_CONTEXT_TRACE3( instance , frmt, arg1 , arg2 , arg3 ) \ 00156 rtl_logfile_longTrace( "| %s : ", \ 00157 instance.getName() ); \ 00158 rtl_logfile_trace( frmt , arg1 , arg2 , arg3 ); \ 00159 rtl_logfile_trace( "\n" ) 00160 00161 #else 00162 #define RTL_LOGFILE_CONTEXT( instance, name ) ((void)0) 00163 #define RTL_LOGFILE_CONTEXT_AUTHOR( instance, project, author, name ) ((void)0) 00164 #define RTL_LOGFILE_CONTEXT_TRACE( instance, message ) ((void)0) 00165 #define RTL_LOGFILE_CONTEXT_TRACE1( instance, frmt, arg1 ) ((void)arg1,(void)0) 00166 #define RTL_LOGFILE_CONTEXT_TRACE2( instance, frmt, arg1, arg2 ) ((void)arg1,(void)arg2,(void)0) 00167 #define RTL_LOGFILE_CONTEXT_TRACE3( instance, frmt, arg1, arg2 , arg3 ) ((void)arg1,(void)arg2,(void)arg3,(void)0) 00168 #endif 00169 00170 // Normal RTL_LOGFILE_* entries will not make it into release versions, 00171 // TIMELOG is disabled a few versions prior relase build. 00172 // 00173 // We need some logs also in these builds, eg. for making performance regression tests. 00174 // 00175 // POLICY: Don't use RTL_LOGFILE_PRODUCT_* for your personal logging information. 00176 // Be aware that these logs make it into the product shipped to customers. 00177 // If you have good reasons for doing this, please contact product management. 00178 00179 #define RTL_LOGFILE_PRODUCT_TRACE( string ) \ 00180 rtl_logfile_longTrace( "| : %s\n", string ) 00181 #define RTL_LOGFILE_PRODUCT_TRACE1( frmt, arg1 ) \ 00182 rtl_logfile_longTrace( "| : " ); \ 00183 rtl_logfile_trace( frmt, arg1 ); \ 00184 rtl_logfile_trace( "\n" ) 00185 #define RTL_LOGFILE_PRODUCT_CONTEXT( instance, name ) \ 00186 ::rtl::Logfile instance( name ) 00187 #define RTL_LOGFILE_PRODUCT_CONTEXT_TRACE1( instance, frmt, arg1 ) \ 00188 rtl_logfile_longTrace( "| %s : ", \ 00189 instance.getName() ); \ 00190 rtl_logfile_trace( frmt, arg1 ); \ 00191 rtl_logfile_trace( "\n" ) 00192 #define RTL_LOGFILE_HASLOGFILE() \ 00193 rtl_logfile_hasLogFile() 00194 00195 00196 #endif 00197 00198 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1.7.3