Use correct object
[LibreOffice.git] / connectivity / source / drivers / jdbc / ConnectionLog.cxx
blob96a82fb61c5f316f31b783b35358f33553b6a9f0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 #include <java/sql/ConnectionLog.hxx>
23 #include <com/sun/star/util/Date.hpp>
24 #include <com/sun/star/util/Time.hpp>
25 #include <com/sun/star/util/DateTime.hpp>
27 #include <stdio.h>
30 namespace connectivity::java::sql {
33 namespace
35 sal_Int32 lcl_getFreeID( ConnectionLog::ObjectType _eType )
37 static oslInterlockedCount s_nCounts[ ConnectionLog::ObjectTypeCount ] = { 0, 0 };
38 return osl_atomic_increment( s_nCounts + _eType );
42 ConnectionLog::ConnectionLog( const ::comphelper::EventLogger& _rDriverLog )
43 :ConnectionLog_Base( _rDriverLog )
44 ,m_nObjectID( lcl_getFreeID( CONNECTION ) )
49 ConnectionLog::ConnectionLog( const ConnectionLog& _rSourceLog )
50 :ConnectionLog_Base( _rSourceLog )
51 ,m_nObjectID( _rSourceLog.m_nObjectID )
56 ConnectionLog::ConnectionLog( const ConnectionLog& _rSourceLog, ConnectionLog::ObjectType _eType )
57 :ConnectionLog_Base( _rSourceLog )
58 ,m_nObjectID( lcl_getFreeID( _eType ) )
63 } // namespace connectivity::java::sql
66 namespace comphelper::log::convert
70 using ::com::sun::star::util::Date;
71 using ::com::sun::star::util::Time;
72 using ::com::sun::star::util::DateTime;
75 OUString convertLogArgToString( const Date& _rDate )
77 char buffer[ 30 ];
78 const size_t buffer_size = sizeof( buffer );
79 snprintf( buffer, buffer_size, "%04i-%02i-%02i",
80 static_cast<int>(_rDate.Year), static_cast<int>(_rDate.Month), static_cast<int>(_rDate.Day) );
81 return OUString::createFromAscii( buffer );
85 OUString convertLogArgToString( const css::util::Time& _rTime )
87 char buffer[ 30 ];
88 const size_t buffer_size = sizeof( buffer );
89 snprintf( buffer, buffer_size, "%02i:%02i:%02i.%09i",
90 static_cast<int>(_rTime.Hours), static_cast<int>(_rTime.Minutes), static_cast<int>(_rTime.Seconds), static_cast<int>(_rTime.NanoSeconds) );
91 return OUString::createFromAscii( buffer );
95 OUString convertLogArgToString( const DateTime& _rDateTime )
97 char buffer[ sizeof("-32768-65535-65535 65535:65535:65535.4294967295") ];
98 // reserve enough space for hypothetical max length
99 const size_t buffer_size = sizeof( buffer );
100 snprintf( buffer, buffer_size, "%04" SAL_PRIdINT32 "-%02" SAL_PRIuUINT32 "-%02" SAL_PRIuUINT32 " %02" SAL_PRIuUINT32 ":%02" SAL_PRIuUINT32 ":%02" SAL_PRIuUINT32 ".%09" SAL_PRIuUINT32,
101 static_cast<sal_Int32>(_rDateTime.Year), static_cast<sal_uInt32>(_rDateTime.Month), static_cast<sal_uInt32>(_rDateTime.Day),
102 static_cast<sal_uInt32>(_rDateTime.Hours), static_cast<sal_uInt32>(_rDateTime.Minutes), static_cast<sal_uInt32>(_rDateTime.Seconds), _rDateTime.NanoSeconds );
103 return OUString::createFromAscii( buffer );
107 } // comphelper::log::convert
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */