1*caf5cd79SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*caf5cd79SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*caf5cd79SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*caf5cd79SAndrew Rist  * distributed with this work for additional information
6*caf5cd79SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*caf5cd79SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*caf5cd79SAndrew Rist  * "License"); you may not use this file except in compliance
9*caf5cd79SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*caf5cd79SAndrew Rist  *
11*caf5cd79SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*caf5cd79SAndrew Rist  *
13*caf5cd79SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*caf5cd79SAndrew Rist  * software distributed under the License is distributed on an
15*caf5cd79SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*caf5cd79SAndrew Rist  * KIND, either express or implied.  See the License for the
17*caf5cd79SAndrew Rist  * specific language governing permissions and limitations
18*caf5cd79SAndrew Rist  * under the License.
19*caf5cd79SAndrew Rist  *
20*caf5cd79SAndrew Rist  *************************************************************/
21*caf5cd79SAndrew Rist 
22*caf5cd79SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef CONNECTIVITY_CONNECTIONLOG_HXX
25cdf0e10cSrcweir #define CONNECTIVITY_CONNECTIONLOG_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir /** === begin UNO includes === **/
28cdf0e10cSrcweir #include <com/sun/star/logging/LogLevel.hpp>
29cdf0e10cSrcweir /** === end UNO includes === **/
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <rtl/ustring.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir // Strange enough, GCC requires the following forward declarations of the various
34cdf0e10cSrcweir // convertLogArgToString flavors to be *before* the inclusion of comphelper/logging.hxx
35cdf0e10cSrcweir 
36cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace util
37cdf0e10cSrcweir {
38cdf0e10cSrcweir     struct Date;
39cdf0e10cSrcweir     struct Time;
40cdf0e10cSrcweir     struct DateTime;
41cdf0e10cSrcweir } } } }
42cdf0e10cSrcweir 
43cdf0e10cSrcweir //........................................................................
44cdf0e10cSrcweir namespace comphelper { namespace log { namespace convert
45cdf0e10cSrcweir {
46cdf0e10cSrcweir //........................................................................
47cdf0e10cSrcweir 
48cdf0e10cSrcweir     // helpers for logging more data types than are defined in comphelper/logging.hxx
49cdf0e10cSrcweir     ::rtl::OUString convertLogArgToString( const ::com::sun::star::util::Date& _rDate );
50cdf0e10cSrcweir     ::rtl::OUString convertLogArgToString( const ::com::sun::star::util::Time& _rTime );
51cdf0e10cSrcweir     ::rtl::OUString convertLogArgToString( const ::com::sun::star::util::DateTime& _rDateTime );
52cdf0e10cSrcweir 
53cdf0e10cSrcweir //........................................................................
54cdf0e10cSrcweir } } }
55cdf0e10cSrcweir //........................................................................
56cdf0e10cSrcweir 
57cdf0e10cSrcweir #include <comphelper/logging.hxx>
58cdf0e10cSrcweir 
59cdf0e10cSrcweir namespace connectivity
60cdf0e10cSrcweir {
61cdf0e10cSrcweir     namespace LogLevel = ::com::sun::star::logging::LogLevel;
62cdf0e10cSrcweir }
63cdf0e10cSrcweir 
64cdf0e10cSrcweir //........................................................................
65cdf0e10cSrcweir namespace connectivity { namespace java { namespace sql {
66cdf0e10cSrcweir //........................................................................
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 	//====================================================================
69cdf0e10cSrcweir 	//= ConnectionLog
70cdf0e10cSrcweir 	//====================================================================
71cdf0e10cSrcweir     typedef ::comphelper::ResourceBasedEventLogger  ConnectionLog_Base;
72cdf0e10cSrcweir     class ConnectionLog : public ConnectionLog_Base
73cdf0e10cSrcweir 	{
74cdf0e10cSrcweir     public:
75cdf0e10cSrcweir         enum ObjectType
76cdf0e10cSrcweir         {
77cdf0e10cSrcweir             CONNECTION = 0,
78cdf0e10cSrcweir             STATEMENT,
79cdf0e10cSrcweir             RESULTSET,
80cdf0e10cSrcweir 
81cdf0e10cSrcweir             ObjectTypeCount = RESULTSET + 1
82cdf0e10cSrcweir         };
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     private:
85cdf0e10cSrcweir         const   sal_Int32   m_nObjectID;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir     public:
88cdf0e10cSrcweir         /// will construct an instance of ObjectType CONNECTION
89cdf0e10cSrcweir         ConnectionLog( const ::comphelper::ResourceBasedEventLogger& _rDriverLog );
90cdf0e10cSrcweir         /// will create an instance with the same object ID / ObjectType as a given source instance
91cdf0e10cSrcweir         ConnectionLog( const ConnectionLog& _rSourceLog );
92cdf0e10cSrcweir         /// will create an instance of arbitrary ObjectType
93cdf0e10cSrcweir         ConnectionLog( const ConnectionLog& _rSourceLog, ObjectType _eType );
94cdf0e10cSrcweir 
getObjectID() const95cdf0e10cSrcweir         sal_Int32   getObjectID() const { return m_nObjectID; }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir         /// logs a given message, without any arguments, or source class/method names
log(const sal_Int32 _nLogLevel,const sal_Int32 _nMessageResID)98cdf0e10cSrcweir         bool        log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID )
99cdf0e10cSrcweir         {
100cdf0e10cSrcweir             return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID );
101cdf0e10cSrcweir         }
102cdf0e10cSrcweir 
103cdf0e10cSrcweir         template< typename ARGTYPE1 >
log(const sal_Int32 _nLogLevel,const sal_Int32 _nMessageResID,ARGTYPE1 _argument1) const104cdf0e10cSrcweir         bool        log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1 ) const
105cdf0e10cSrcweir         {
106cdf0e10cSrcweir             return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID, _argument1 );
107cdf0e10cSrcweir         }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir         template< typename ARGTYPE1, typename ARGTYPE2 >
log(const sal_Int32 _nLogLevel,const sal_Int32 _nMessageResID,ARGTYPE1 _argument1,ARGTYPE2 _argument2) const110cdf0e10cSrcweir         bool        log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2 ) const
111cdf0e10cSrcweir         {
112cdf0e10cSrcweir             return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID, _argument1, _argument2 );
113cdf0e10cSrcweir         }
114cdf0e10cSrcweir 
115cdf0e10cSrcweir         template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3 >
log(const sal_Int32 _nLogLevel,const sal_Int32 _nMessageResID,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3) const116cdf0e10cSrcweir         bool        log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3 ) const
117cdf0e10cSrcweir         {
118cdf0e10cSrcweir             return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID, _argument1, _argument2, _argument3 );
119cdf0e10cSrcweir         }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir         template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4 >
log(const sal_Int32 _nLogLevel,const sal_Int32 _nMessageResID,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3,ARGTYPE4 _argument4) const122cdf0e10cSrcweir         bool        log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4 ) const
123cdf0e10cSrcweir         {
124cdf0e10cSrcweir             return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID, _argument1, _argument2, _argument3, _argument4 );
125cdf0e10cSrcweir         }
126cdf0e10cSrcweir 
127cdf0e10cSrcweir         template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5 >
log(const sal_Int32 _nLogLevel,const sal_Int32 _nMessageResID,ARGTYPE1 _argument1,ARGTYPE2 _argument2,ARGTYPE3 _argument3,ARGTYPE4 _argument4,ARGTYPE5 _argument5) const128cdf0e10cSrcweir         bool        log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5 ) const
129cdf0e10cSrcweir         {
130cdf0e10cSrcweir             return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID, _argument1, _argument2, _argument3, _argument4, _argument5 );
131cdf0e10cSrcweir         }
132cdf0e10cSrcweir 	};
133cdf0e10cSrcweir 
134cdf0e10cSrcweir //........................................................................
135cdf0e10cSrcweir } } } // namespace connectivity::java::sql
136cdf0e10cSrcweir //........................................................................
137cdf0e10cSrcweir 
138cdf0e10cSrcweir #endif // CONNECTIVITY_CONNECTIONLOG_HXX
139