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