1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_connectivity.hxx" 30 31 #include "java/sql/ConnectionLog.hxx" 32 33 /** === begin UNO includes === **/ 34 #include <com/sun/star/util/Date.hpp> 35 #include <com/sun/star/util/Time.hpp> 36 #include <com/sun/star/util/DateTime.hpp> 37 /** === end UNO includes === **/ 38 39 #include <stdio.h> 40 41 //........................................................................ 42 namespace connectivity { namespace java { namespace sql { 43 //........................................................................ 44 45 /** === begin UNO using === **/ 46 using ::com::sun::star::uno::Reference; 47 using ::com::sun::star::uno::XComponentContext; 48 /** === end UNO using === **/ 49 50 //-------------------------------------------------------------------- 51 namespace 52 { 53 sal_Int32 lcl_getFreeID( ConnectionLog::ObjectType _eType ) 54 { 55 static oslInterlockedCount s_nCounts[ ConnectionLog::ObjectTypeCount ] = { 0, 0 }; 56 return osl_incrementInterlockedCount( s_nCounts + _eType ); 57 } 58 } 59 60 //==================================================================== 61 //= ConnectionLog 62 //==================================================================== 63 //-------------------------------------------------------------------- 64 ConnectionLog::ConnectionLog( const ::comphelper::ResourceBasedEventLogger& _rDriverLog ) 65 :ConnectionLog_Base( _rDriverLog ) 66 ,m_nObjectID( lcl_getFreeID( CONNECTION ) ) 67 { 68 } 69 70 //-------------------------------------------------------------------- 71 ConnectionLog::ConnectionLog( const ConnectionLog& _rSourceLog ) 72 :ConnectionLog_Base( _rSourceLog ) 73 ,m_nObjectID( _rSourceLog.m_nObjectID ) 74 { 75 } 76 77 //-------------------------------------------------------------------- 78 ConnectionLog::ConnectionLog( const ConnectionLog& _rSourceLog, ConnectionLog::ObjectType _eType ) 79 :ConnectionLog_Base( _rSourceLog ) 80 ,m_nObjectID( lcl_getFreeID( _eType ) ) 81 { 82 } 83 84 //........................................................................ 85 } } } // namespace connectivity::java::sql 86 //........................................................................ 87 88 //........................................................................ 89 namespace comphelper { namespace log { namespace convert 90 { 91 //........................................................................ 92 93 /** === begin UNO using === **/ 94 using ::com::sun::star::uno::Reference; 95 using ::com::sun::star::uno::XComponentContext; 96 using ::com::sun::star::util::Date; 97 using ::com::sun::star::util::Time; 98 using ::com::sun::star::util::DateTime; 99 /** === end UNO using === **/ 100 101 //-------------------------------------------------------------------- 102 ::rtl::OUString convertLogArgToString( const Date& _rDate ) 103 { 104 char buffer[ 30 ]; 105 const size_t buffer_size = sizeof( buffer ); 106 snprintf( buffer, buffer_size, "%04i-%02i-%02i", 107 (int)_rDate.Year, (int)_rDate.Month, (int)_rDate.Day ); 108 return ::rtl::OUString::createFromAscii( buffer ); 109 } 110 111 //-------------------------------------------------------------------- 112 ::rtl::OUString convertLogArgToString( const Time& _rTime ) 113 { 114 char buffer[ 30 ]; 115 const size_t buffer_size = sizeof( buffer ); 116 snprintf( buffer, buffer_size, "%02i:%02i:%02i.%02i", 117 (int)_rTime.Hours, (int)_rTime.Minutes, (int)_rTime.Seconds, (int)_rTime.HundredthSeconds ); 118 return ::rtl::OUString::createFromAscii( buffer ); 119 } 120 121 //-------------------------------------------------------------------- 122 ::rtl::OUString convertLogArgToString( const DateTime& _rDateTime ) 123 { 124 char buffer[ 30 ]; 125 const size_t buffer_size = sizeof( buffer ); 126 snprintf( buffer, buffer_size, "%04i-%02i-%02i %02i:%02i:%02i.%02i", 127 (int)_rDateTime.Year, (int)_rDateTime.Month, (int)_rDateTime.Day, 128 (int)_rDateTime.Hours, (int)_rDateTime.Minutes, (int)_rDateTime.Seconds, (int)_rDateTime.HundredthSeconds ); 129 return ::rtl::OUString::createFromAscii( buffer ); 130 } 131 132 //........................................................................ 133 } } } // comphelper::log::convert 134 //........................................................................ 135