1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_CONNECTIONLOG_HXX
21 #define INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_CONNECTIONLOG_HXX
23 #include <com/sun/star/logging/LogLevel.hpp>
25 #include <rtl/ustring.hxx>
27 // Strange enough, GCC requires the following forward declarations of the various
28 // convertLogArgToString flavors to be *before* the inclusion of comphelper/logging.hxx
30 namespace com
{ namespace sun
{ namespace star
{ namespace util
38 namespace comphelper
{ namespace log
{ namespace convert
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
);
51 #include <comphelper/logging.hxx>
53 namespace connectivity
55 namespace LogLevel
= ::com::sun::star::logging::LogLevel
;
59 namespace connectivity
{ namespace java
{ namespace sql
{
61 typedef ::comphelper::ResourceBasedEventLogger ConnectionLog_Base
;
62 class ConnectionLog
: public ConnectionLog_Base
71 ObjectTypeCount
= RESULTSET
+ 1
75 const sal_Int32 m_nObjectID
;
78 /// will construct an instance of ObjectType CONNECTION
79 ConnectionLog( const ::comphelper::ResourceBasedEventLogger
& _rDriverLog
);
80 /// will create an instance with the same object ID / ObjectType as a given source instance
81 ConnectionLog( const ConnectionLog
& _rSourceLog
);
82 /// will create an instance of arbitrary ObjectType
83 ConnectionLog( const ConnectionLog
& _rSourceLog
, ObjectType _eType
);
85 sal_Int32
getObjectID() const { return m_nObjectID
; }
87 /// logs a given message, without any arguments, or source class/method names
88 bool log( const sal_Int32 _nLogLevel
, const sal_Int32 _nMessageResID
)
90 return ConnectionLog_Base::log( _nLogLevel
, _nMessageResID
, m_nObjectID
);
93 template< typename ARGTYPE1
>
94 bool log( const sal_Int32 _nLogLevel
, const sal_Int32 _nMessageResID
, ARGTYPE1 _argument1
) const
96 return ConnectionLog_Base::log( _nLogLevel
, _nMessageResID
, m_nObjectID
, _argument1
);
99 template< typename ARGTYPE1
, typename ARGTYPE2
>
100 bool log( const sal_Int32 _nLogLevel
, const sal_Int32 _nMessageResID
, ARGTYPE1 _argument1
, ARGTYPE2 _argument2
) const
102 return ConnectionLog_Base::log( _nLogLevel
, _nMessageResID
, m_nObjectID
, _argument1
, _argument2
);
105 template< typename ARGTYPE1
, typename ARGTYPE2
, typename ARGTYPE3
>
106 bool log( const sal_Int32 _nLogLevel
, const sal_Int32 _nMessageResID
, ARGTYPE1 _argument1
, ARGTYPE2 _argument2
, ARGTYPE3 _argument3
) const
108 return ConnectionLog_Base::log( _nLogLevel
, _nMessageResID
, m_nObjectID
, _argument1
, _argument2
, _argument3
);
111 template< typename ARGTYPE1
, typename ARGTYPE2
, typename ARGTYPE3
, typename ARGTYPE4
>
112 bool log( const sal_Int32 _nLogLevel
, const sal_Int32 _nMessageResID
, ARGTYPE1 _argument1
, ARGTYPE2 _argument2
, ARGTYPE3 _argument3
, ARGTYPE4 _argument4
) const
114 return ConnectionLog_Base::log( _nLogLevel
, _nMessageResID
, m_nObjectID
, _argument1
, _argument2
, _argument3
, _argument4
);
117 template< typename ARGTYPE1
, typename ARGTYPE2
, typename ARGTYPE3
, typename ARGTYPE4
, typename ARGTYPE5
>
118 bool log( const sal_Int32 _nLogLevel
, const sal_Int32 _nMessageResID
, ARGTYPE1 _argument1
, ARGTYPE2 _argument2
, ARGTYPE3 _argument3
, ARGTYPE4 _argument4
, ARGTYPE5 _argument5
) const
120 return ConnectionLog_Base::log( _nLogLevel
, _nMessageResID
, m_nObjectID
, _argument1
, _argument2
, _argument3
, _argument4
, _argument5
);
125 } } } // namespace connectivity::java::sql
128 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_JAVA_SQL_CONNECTIONLOG_HXX
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */