Branch data 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 : :
21 : : #include "java/sql/ConnectionLog.hxx"
22 : :
23 : : #include <com/sun/star/util/Date.hpp>
24 : : #include <com/sun/star/util/Time.hpp>
25 : : #include <com/sun/star/util/DateTime.hpp>
26 : :
27 : : #include <stdio.h>
28 : :
29 : : //........................................................................
30 : : namespace connectivity { namespace java { namespace sql {
31 : : //........................................................................
32 : :
33 : : /** === begin UNO using === **/
34 : : using ::com::sun::star::uno::Reference;
35 : : using ::com::sun::star::uno::XComponentContext;
36 : : /** === end UNO using === **/
37 : :
38 : : //--------------------------------------------------------------------
39 : : namespace
40 : : {
41 : 0 : sal_Int32 lcl_getFreeID( ConnectionLog::ObjectType _eType )
42 : : {
43 : : static oslInterlockedCount s_nCounts[ ConnectionLog::ObjectTypeCount ] = { 0, 0 };
44 : 0 : return osl_incrementInterlockedCount( s_nCounts + _eType );
45 : : }
46 : : }
47 : :
48 : : //====================================================================
49 : : //= ConnectionLog
50 : : //====================================================================
51 : : //--------------------------------------------------------------------
52 : 0 : ConnectionLog::ConnectionLog( const ::comphelper::ResourceBasedEventLogger& _rDriverLog )
53 : : :ConnectionLog_Base( _rDriverLog )
54 : 0 : ,m_nObjectID( lcl_getFreeID( CONNECTION ) )
55 : : {
56 : 0 : }
57 : :
58 : : //--------------------------------------------------------------------
59 : 0 : ConnectionLog::ConnectionLog( const ConnectionLog& _rSourceLog )
60 : : :ConnectionLog_Base( _rSourceLog )
61 : 0 : ,m_nObjectID( _rSourceLog.m_nObjectID )
62 : : {
63 : 0 : }
64 : :
65 : : //--------------------------------------------------------------------
66 : 0 : ConnectionLog::ConnectionLog( const ConnectionLog& _rSourceLog, ConnectionLog::ObjectType _eType )
67 : : :ConnectionLog_Base( _rSourceLog )
68 : 0 : ,m_nObjectID( lcl_getFreeID( _eType ) )
69 : : {
70 : 0 : }
71 : :
72 : : //........................................................................
73 : : } } } // namespace connectivity::java::sql
74 : : //........................................................................
75 : :
76 : : //........................................................................
77 : : namespace comphelper { namespace log { namespace convert
78 : : {
79 : : //........................................................................
80 : :
81 : : /** === begin UNO using === **/
82 : : using ::com::sun::star::uno::Reference;
83 : : using ::com::sun::star::uno::XComponentContext;
84 : : using ::com::sun::star::util::Date;
85 : : using ::com::sun::star::util::Time;
86 : : using ::com::sun::star::util::DateTime;
87 : : /** === end UNO using === **/
88 : :
89 : : //--------------------------------------------------------------------
90 : 0 : ::rtl::OUString convertLogArgToString( const Date& _rDate )
91 : : {
92 : : char buffer[ 30 ];
93 : 0 : const size_t buffer_size = sizeof( buffer );
94 : : snprintf( buffer, buffer_size, "%04i-%02i-%02i",
95 : 0 : (int)_rDate.Year, (int)_rDate.Month, (int)_rDate.Day );
96 : 0 : return ::rtl::OUString::createFromAscii( buffer );
97 : : }
98 : :
99 : : //--------------------------------------------------------------------
100 : 0 : ::rtl::OUString convertLogArgToString( const Time& _rTime )
101 : : {
102 : : char buffer[ 30 ];
103 : 0 : const size_t buffer_size = sizeof( buffer );
104 : : snprintf( buffer, buffer_size, "%02i:%02i:%02i.%02i",
105 : 0 : (int)_rTime.Hours, (int)_rTime.Minutes, (int)_rTime.Seconds, (int)_rTime.HundredthSeconds );
106 : 0 : return ::rtl::OUString::createFromAscii( buffer );
107 : : }
108 : :
109 : : //--------------------------------------------------------------------
110 : 0 : ::rtl::OUString convertLogArgToString( const DateTime& _rDateTime )
111 : : {
112 : : char buffer[ 30 ];
113 : 0 : const size_t buffer_size = sizeof( buffer );
114 : : snprintf( buffer, buffer_size, "%04i-%02i-%02i %02i:%02i:%02i.%02i",
115 : : (int)_rDateTime.Year, (int)_rDateTime.Month, (int)_rDateTime.Day,
116 : 0 : (int)_rDateTime.Hours, (int)_rDateTime.Minutes, (int)_rDateTime.Seconds, (int)_rDateTime.HundredthSeconds );
117 : 0 : return ::rtl::OUString::createFromAscii( buffer );
118 : : }
119 : :
120 : : //........................................................................
121 : : } } } // comphelper::log::convert
122 : : //........................................................................
123 : :
124 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|