merge the formfield patch from ooo-build
[ooovba.git] / bridges / source / remote / urp / urp_log.cxx
blob8dcb7573da80b6c295324c248980952c055a17ed
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: urp_log.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_bridges.hxx"
33 #include <osl/time.h>
34 #include "urp_bridgeimpl.hxx"
35 #include "urp_log.hxx"
37 using namespace ::rtl;
38 using namespace ::osl;
39 namespace bridges_urp
41 #ifdef BRIDGES_URP_PROT
42 Mutex g_logFileMutex;
44 class FileAccess
46 public:
47 FileAccess( urp_BridgeImpl *pBridgeImpl_ ) :
48 pBridgeImpl( pBridgeImpl_ ),
49 guard( g_logFileMutex )
51 if( pBridgeImpl->m_pLogFile )
53 f = pBridgeImpl->m_pLogFile;
55 else
57 f = fopen( pBridgeImpl->m_sLogFileName.getStr() , "a" );
60 ~FileAccess()
62 if( ! pBridgeImpl->m_pLogFile )
64 fclose( f );
67 FILE *getFile()
69 return f;
71 private:
72 urp_BridgeImpl *pBridgeImpl;
73 MutexGuard guard;
74 FILE *f;
77 void urp_logCall( urp_BridgeImpl *pBridgeImpl, sal_Int32 nSize, sal_Int32 nUseData, sal_Bool bSynchron ,
78 const ::rtl::OUString &sMethodName )
80 if( pBridgeImpl->m_sLogFileName.getLength() && getenv( "PROT_REMOTE_ACTIVATE" ) )
82 OString sOperation = OUStringToOString( sMethodName,RTL_TEXTENCODING_ASCII_US );
84 FileAccess access( pBridgeImpl );
85 fprintf( access.getFile() ,
86 "%06u: calling [size=%d(usedata=%d)] [synchron=%d] [name=%s]\n" ,
87 static_cast< unsigned int > (osl_getGlobalTimer()),
88 static_cast< int > (nSize),
89 static_cast< int > (nUseData),
90 bSynchron, sOperation.pData->buffer );
94 void urp_logServingRequest( urp_BridgeImpl *pBridgeImpl,
95 sal_Int32 nSize, sal_Int32 nUseData, sal_Bool bSynchron ,
96 const ::rtl::OUString &sMethodName )
98 if( pBridgeImpl->m_sLogFileName.getLength() && getenv( "PROT_REMOTE_ACTIVATE" ) )
100 OString sOperation = OUStringToOString( sMethodName,RTL_TEXTENCODING_ASCII_US );
102 FileAccess access( pBridgeImpl );
103 fprintf(
104 access.getFile(),
105 "%06u: serving request [size=%d(usedata=%d)] [synchron=%d] [name=%s]\n",
106 static_cast< unsigned int > (osl_getGlobalTimer()),
107 static_cast< int > (nSize),
108 static_cast< int > (nUseData),
109 bSynchron,
110 sOperation.pData->buffer
115 void urp_logGettingReply( urp_BridgeImpl *pBridgeImpl,
116 sal_Int32 nSize, sal_Int32 nUseData,
117 const ::rtl::OUString &sMethodName )
119 if( pBridgeImpl->m_sLogFileName.getLength() && getenv( "PROT_REMOTE_ACTIVATE" ) )
121 OString sOperation = OUStringToOString( sMethodName,RTL_TEXTENCODING_ASCII_US );
122 FileAccess access( pBridgeImpl );
123 fprintf( access.getFile(),
124 "%06u: getting reply [size=%d(usedata=%d)][name=%s]\n" ,
125 static_cast< unsigned int > (osl_getGlobalTimer()),
126 static_cast< int > (nSize),
127 static_cast< int > (nUseData),
128 sOperation.pData->buffer);
132 void urp_logReplying( urp_BridgeImpl *pBridgeImpl,
133 sal_Int32 nSize , sal_Int32 nUseData,
134 const ::rtl::OUString &sMethodName )
136 if( pBridgeImpl->m_sLogFileName.getLength() && getenv( "PROT_REMOTE_ACTIVATE" ) )
138 OString sOperation = OUStringToOString(sMethodName,RTL_TEXTENCODING_ASCII_US);
140 FileAccess access( pBridgeImpl );
141 fprintf( access.getFile(),
142 "%06u: replying [size=%d(usedata=%d)] [name=%s]\n",
143 static_cast< unsigned int > (osl_getGlobalTimer()),
144 static_cast< int > (nSize),
145 static_cast< int > (nUseData),
146 sOperation.pData->buffer);
149 #endif