Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_CONNECTIONLOG_HXX
21 : #define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_CONNECTIONLOG_HXX
22 :
23 : #include <com/sun/star/logging/LogLevel.hpp>
24 :
25 : #include <rtl/ustring.hxx>
26 :
27 : // Strange enough, GCC requires the following forward declarations of the various
28 : // convertLogArgToString flavors to be *before* the inclusion of comphelper/logging.hxx
29 :
30 : namespace com { namespace sun { namespace star { namespace util
31 : {
32 : struct Date;
33 : struct Time;
34 : struct DateTime;
35 : } } } }
36 :
37 :
38 : namespace comphelper { namespace log { namespace convert
39 : {
40 :
41 :
42 : // helpers for logging more data types than are defined in comphelper/logging.hxx
43 : OUString convertLogArgToString( const ::com::sun::star::util::Date& _rDate );
44 : OUString convertLogArgToString( const ::com::sun::star::util::Time& _rTime );
45 : OUString convertLogArgToString( const ::com::sun::star::util::DateTime& _rDateTime );
46 :
47 :
48 : } } }
49 :
50 :
51 : #include <comphelper/logging.hxx>
52 :
53 : namespace connectivity
54 : {
55 : namespace LogLevel = ::com::sun::star::logging::LogLevel;
56 : }
57 :
58 :
59 : namespace connectivity { namespace java { namespace sql {
60 :
61 :
62 :
63 : //= ConnectionLog
64 :
65 : typedef ::comphelper::ResourceBasedEventLogger ConnectionLog_Base;
66 48 : class ConnectionLog : public ConnectionLog_Base
67 : {
68 : public:
69 : enum ObjectType
70 : {
71 : CONNECTION = 0,
72 : STATEMENT,
73 : RESULTSET,
74 :
75 : ObjectTypeCount = RESULTSET + 1
76 : };
77 :
78 : private:
79 : const sal_Int32 m_nObjectID;
80 :
81 : public:
82 : /// will construct an instance of ObjectType CONNECTION
83 : ConnectionLog( const ::comphelper::ResourceBasedEventLogger& _rDriverLog );
84 : /// will create an instance with the same object ID / ObjectType as a given source instance
85 : ConnectionLog( const ConnectionLog& _rSourceLog );
86 : /// will create an instance of arbitrary ObjectType
87 : ConnectionLog( const ConnectionLog& _rSourceLog, ObjectType _eType );
88 :
89 6 : sal_Int32 getObjectID() const { return m_nObjectID; }
90 :
91 : /// logs a given message, without any arguments, or source class/method names
92 18 : bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID )
93 : {
94 18 : return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID );
95 : }
96 :
97 : template< typename ARGTYPE1 >
98 86 : bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1 ) const
99 : {
100 86 : return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID, _argument1 );
101 : }
102 :
103 : template< typename ARGTYPE1, typename ARGTYPE2 >
104 22 : bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2 ) const
105 : {
106 22 : return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID, _argument1, _argument2 );
107 : }
108 :
109 : template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3 >
110 0 : bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3 ) const
111 : {
112 0 : return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID, _argument1, _argument2, _argument3 );
113 : }
114 :
115 : template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4 >
116 0 : bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4 ) const
117 : {
118 0 : return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID, _argument1, _argument2, _argument3, _argument4 );
119 : }
120 :
121 : template< typename ARGTYPE1, typename ARGTYPE2, typename ARGTYPE3, typename ARGTYPE4, typename ARGTYPE5 >
122 0 : bool log( const sal_Int32 _nLogLevel, const sal_Int32 _nMessageResID, ARGTYPE1 _argument1, ARGTYPE2 _argument2, ARGTYPE3 _argument3, ARGTYPE4 _argument4, ARGTYPE5 _argument5 ) const
123 : {
124 0 : return ConnectionLog_Base::log( _nLogLevel, _nMessageResID, m_nObjectID, _argument1, _argument2, _argument3, _argument4, _argument5 );
125 : }
126 : };
127 :
128 :
129 : } } } // namespace connectivity::java::sql
130 :
131 :
132 : #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_CONNECTIONLOG_HXX
133 :
134 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|