Update ooo320-m1
[ooovba.git] / connectivity / source / inc / java / sql / ConnectionLog.hxx
blob7c3d10df2bef575f9c7002968ca42980331f177d
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: ConnectionLog.hxx,v $
10 * $Revision: 1.4 $
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 #ifndef CONNECTIVITY_CONNECTIONLOG_HXX
32 #define CONNECTIVITY_CONNECTIONLOG_HXX
34 /** === begin UNO includes === **/
35 #include <com/sun/star/logging/LogLevel.hpp>
36 /** === end UNO includes === **/
38 #include <rtl/ustring.hxx>
40 // Strange enough, GCC requires the following forward declarations of the various
41 // convertLogArgToString flavors to be *before* the inclusion of comphelper/logging.hxx
43 namespace com { namespace sun { namespace star { namespace util
45 struct Date;
46 struct Time;
47 struct DateTime;
48 } } } }
50 //........................................................................
51 namespace comphelper { namespace log { namespace convert
53 //........................................................................
55 // helpers for logging more data types than are defined in comphelper/logging.hxx
56 ::rtl::OUString convertLogArgToString( const ::com::sun::star::util::Date& _rDate );
57 ::rtl::OUString convertLogArgToString( const ::com::sun::star::util::Time& _rTime );
58 ::rtl::OUString convertLogArgToString( const ::com::sun::star::util::DateTime& _rDateTime );
60 //........................................................................
61 } } }
62 //........................................................................
64 #include <comphelper/logging.hxx>
66 namespace connectivity
68 namespace LogLevel = ::com::sun::star::logging::LogLevel;
71 //........................................................................
72 namespace connectivity { namespace java { namespace sql {
73 //........................................................................
75 //====================================================================
76 //= ConnectionLog
77 //====================================================================
78 typedef ::comphelper::ResourceBasedEventLogger ConnectionLog_Base;
79 class ConnectionLog : public ConnectionLog_Base
81 public:
82 enum ObjectType
84 CONNECTION = 0,
85 STATEMENT,
86 RESULTSET,
88 ObjectTypeCount = RESULTSET + 1
91 private:
92 const sal_Int32 m_nObjectID;
94 public:
95 /// will construct an instance of ObjectType CONNECTION
96 ConnectionLog( const ::comphelper::ResourceBasedEventLogger& _rDriverLog );
97 /// will create an instance with the same object ID / ObjectType as a given source instance
98 ConnectionLog( const ConnectionLog& _rSourceLog );
99 /// will create an instance of arbitrary ObjectType
100 ConnectionLog( const ConnectionLog& _rSourceLog, ObjectType _eType );
102 sal_Int32 getObjectID() const { return m_nObjectID; }
104 /// logs a given message, without any arguments, or source class/method names
105 bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID )
107 return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID );
110 template< typename ARGTYPE1 >
111 bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1 ) const
113 return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID, _argument1 );
116 template< typename ARGTYPE1, typename ARGTYPE2 >
117 bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2 ) const
119 return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID, _argument1, _argument2 );
122 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3 >
123 bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3 ) const
125 return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID, _argument1, _argument2, _argument3 );
128 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4 >
129 bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4 ) const
131 return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID, _argument1, _argument2, _argument3, _argument4 );
134 template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5 >
135 bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5 ) const
137 return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID, _argument1, _argument2, _argument3, _argument4, _argument5 );
141 //........................................................................
142 } } } // namespace connectivity::java::sql
143 //........................................................................
145 #endif // CONNECTIVITY_CONNECTIONLOG_HXX