1*9b5730f6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9b5730f6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9b5730f6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9b5730f6SAndrew Rist * distributed with this work for additional information 6*9b5730f6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9b5730f6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9b5730f6SAndrew Rist * "License"); you may not use this file except in compliance 9*9b5730f6SAndrew Rist * with the License. You may obtain a copy of the License at 10*9b5730f6SAndrew Rist * 11*9b5730f6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*9b5730f6SAndrew Rist * 13*9b5730f6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9b5730f6SAndrew Rist * software distributed under the License is distributed on an 15*9b5730f6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9b5730f6SAndrew Rist * KIND, either express or implied. See the License for the 17*9b5730f6SAndrew Rist * specific language governing permissions and limitations 18*9b5730f6SAndrew Rist * under the License. 19*9b5730f6SAndrew Rist * 20*9b5730f6SAndrew Rist *************************************************************/ 21*9b5730f6SAndrew Rist 22*9b5730f6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_connectivity.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "java/sql/ConnectionLog.hxx" 28cdf0e10cSrcweir 29cdf0e10cSrcweir /** === begin UNO includes === **/ 30cdf0e10cSrcweir #include <com/sun/star/util/Date.hpp> 31cdf0e10cSrcweir #include <com/sun/star/util/Time.hpp> 32cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp> 33cdf0e10cSrcweir /** === end UNO includes === **/ 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include <stdio.h> 36cdf0e10cSrcweir 37cdf0e10cSrcweir //........................................................................ 38cdf0e10cSrcweir namespace connectivity { namespace java { namespace sql { 39cdf0e10cSrcweir //........................................................................ 40cdf0e10cSrcweir 41cdf0e10cSrcweir /** === begin UNO using === **/ 42cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 43cdf0e10cSrcweir using ::com::sun::star::uno::XComponentContext; 44cdf0e10cSrcweir /** === end UNO using === **/ 45cdf0e10cSrcweir 46cdf0e10cSrcweir //-------------------------------------------------------------------- 47cdf0e10cSrcweir namespace 48cdf0e10cSrcweir { lcl_getFreeID(ConnectionLog::ObjectType _eType)49cdf0e10cSrcweir sal_Int32 lcl_getFreeID( ConnectionLog::ObjectType _eType ) 50cdf0e10cSrcweir { 51cdf0e10cSrcweir static oslInterlockedCount s_nCounts[ ConnectionLog::ObjectTypeCount ] = { 0, 0 }; 52cdf0e10cSrcweir return osl_incrementInterlockedCount( s_nCounts + _eType ); 53cdf0e10cSrcweir } 54cdf0e10cSrcweir } 55cdf0e10cSrcweir 56cdf0e10cSrcweir //==================================================================== 57cdf0e10cSrcweir //= ConnectionLog 58cdf0e10cSrcweir //==================================================================== 59cdf0e10cSrcweir //-------------------------------------------------------------------- ConnectionLog(const::comphelper::ResourceBasedEventLogger & _rDriverLog)60cdf0e10cSrcweir ConnectionLog::ConnectionLog( const ::comphelper::ResourceBasedEventLogger& _rDriverLog ) 61cdf0e10cSrcweir :ConnectionLog_Base( _rDriverLog ) 62cdf0e10cSrcweir ,m_nObjectID( lcl_getFreeID( CONNECTION ) ) 63cdf0e10cSrcweir { 64cdf0e10cSrcweir } 65cdf0e10cSrcweir 66cdf0e10cSrcweir //-------------------------------------------------------------------- ConnectionLog(const ConnectionLog & _rSourceLog)67cdf0e10cSrcweir ConnectionLog::ConnectionLog( const ConnectionLog& _rSourceLog ) 68cdf0e10cSrcweir :ConnectionLog_Base( _rSourceLog ) 69cdf0e10cSrcweir ,m_nObjectID( _rSourceLog.m_nObjectID ) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir } 72cdf0e10cSrcweir 73cdf0e10cSrcweir //-------------------------------------------------------------------- ConnectionLog(const ConnectionLog & _rSourceLog,ConnectionLog::ObjectType _eType)74cdf0e10cSrcweir ConnectionLog::ConnectionLog( const ConnectionLog& _rSourceLog, ConnectionLog::ObjectType _eType ) 75cdf0e10cSrcweir :ConnectionLog_Base( _rSourceLog ) 76cdf0e10cSrcweir ,m_nObjectID( lcl_getFreeID( _eType ) ) 77cdf0e10cSrcweir { 78cdf0e10cSrcweir } 79cdf0e10cSrcweir 80cdf0e10cSrcweir //........................................................................ 81cdf0e10cSrcweir } } } // namespace connectivity::java::sql 82cdf0e10cSrcweir //........................................................................ 83cdf0e10cSrcweir 84cdf0e10cSrcweir //........................................................................ 85cdf0e10cSrcweir namespace comphelper { namespace log { namespace convert 86cdf0e10cSrcweir { 87cdf0e10cSrcweir //........................................................................ 88cdf0e10cSrcweir 89cdf0e10cSrcweir /** === begin UNO using === **/ 90cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 91cdf0e10cSrcweir using ::com::sun::star::uno::XComponentContext; 92cdf0e10cSrcweir using ::com::sun::star::util::Date; 93cdf0e10cSrcweir using ::com::sun::star::util::Time; 94cdf0e10cSrcweir using ::com::sun::star::util::DateTime; 95cdf0e10cSrcweir /** === end UNO using === **/ 96cdf0e10cSrcweir 97cdf0e10cSrcweir //-------------------------------------------------------------------- convertLogArgToString(const Date & _rDate)98cdf0e10cSrcweir ::rtl::OUString convertLogArgToString( const Date& _rDate ) 99cdf0e10cSrcweir { 100cdf0e10cSrcweir char buffer[ 30 ]; 101cdf0e10cSrcweir const size_t buffer_size = sizeof( buffer ); 102cdf0e10cSrcweir snprintf( buffer, buffer_size, "%04i-%02i-%02i", 103cdf0e10cSrcweir (int)_rDate.Year, (int)_rDate.Month, (int)_rDate.Day ); 104cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( buffer ); 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir //-------------------------------------------------------------------- convertLogArgToString(const Time & _rTime)108cdf0e10cSrcweir ::rtl::OUString convertLogArgToString( const Time& _rTime ) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir char buffer[ 30 ]; 111cdf0e10cSrcweir const size_t buffer_size = sizeof( buffer ); 112cdf0e10cSrcweir snprintf( buffer, buffer_size, "%02i:%02i:%02i.%02i", 113cdf0e10cSrcweir (int)_rTime.Hours, (int)_rTime.Minutes, (int)_rTime.Seconds, (int)_rTime.HundredthSeconds ); 114cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( buffer ); 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir //-------------------------------------------------------------------- convertLogArgToString(const DateTime & _rDateTime)118cdf0e10cSrcweir ::rtl::OUString convertLogArgToString( const DateTime& _rDateTime ) 119cdf0e10cSrcweir { 120cdf0e10cSrcweir char buffer[ 30 ]; 121cdf0e10cSrcweir const size_t buffer_size = sizeof( buffer ); 122cdf0e10cSrcweir snprintf( buffer, buffer_size, "%04i-%02i-%02i %02i:%02i:%02i.%02i", 123cdf0e10cSrcweir (int)_rDateTime.Year, (int)_rDateTime.Month, (int)_rDateTime.Day, 124cdf0e10cSrcweir (int)_rDateTime.Hours, (int)_rDateTime.Minutes, (int)_rDateTime.Seconds, (int)_rDateTime.HundredthSeconds ); 125cdf0e10cSrcweir return ::rtl::OUString::createFromAscii( buffer ); 126cdf0e10cSrcweir } 127cdf0e10cSrcweir 128cdf0e10cSrcweir //........................................................................ 129cdf0e10cSrcweir } } } // comphelper::log::convert 130cdf0e10cSrcweir //........................................................................ 131