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_DRIVERS_HSQLDB_ACCESSLOG_HXX
21 #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_HSQLDB_ACCESSLOG_HXX
26 #include <rtl/ustring.hxx>
27 #include <rtl/string.hxx>
29 namespace connectivity
{ namespace hsqldb
37 LogFile( JNIEnv
* env
, jstring streamName
, const sal_Char
* _pAsciiSuffix
);
40 void writeString( const sal_Char
* _pString
, bool _bEndLine
= true );
41 void create() { getLogFile(); }
48 class OperationLogFile
: public LogFile
51 OperationLogFile( JNIEnv
* env
, jstring streamName
, const sal_Char
* _pAsciiSuffix
)
52 :LogFile( env
, streamName
, ( OString( _pAsciiSuffix
) += ".op" ).getStr() )
56 void logOperation( const sal_Char
* _pOp
)
58 writeString( _pOp
, true );
61 void logOperation( const sal_Char
* _pOp
, jlong _nLongArg
)
63 OString
sLine( _pOp
);
65 sLine
+= OString::number( _nLongArg
);
67 writeString( sLine
.getStr(), true );
70 void logReturn( jlong _nRetVal
)
72 OString
sLine( " -> " );
73 sLine
+= OString::number( _nRetVal
);
74 writeString( sLine
.getStr(), true );
77 void logReturn( jint _nRetVal
)
79 OString
sLine( " -> " );
80 sLine
+= OString::number( _nRetVal
);
81 writeString( sLine
.getStr(), true );
86 writeString( "-------------------------------", true );
87 writeString( "", true );
92 class DataLogFile
: public LogFile
95 DataLogFile( JNIEnv
* env
, jstring streamName
, const sal_Char
* _pAsciiSuffix
)
96 :LogFile( env
, streamName
, _pAsciiSuffix
)
100 void write( jint value
)
102 fputc( value
, getLogFile() );
103 fflush( getLogFile() );
106 void write( const sal_Int8
* buffer
, sal_Int32 bytesRead
)
108 fwrite( buffer
, sizeof(sal_Int8
), bytesRead
, getLogFile() );
109 fflush( getLogFile() );
112 sal_Int64
seek( sal_Int64 pos
)
114 FILE* pFile
= getLogFile();
115 fseek( pFile
, 0, SEEK_END
);
116 if ( ftell( pFile
) < pos
)
118 sal_Int8
filler( 0 );
119 while ( ftell( pFile
) < pos
)
120 fwrite( &filler
, sizeof( sal_Int8
), 1, pFile
);
123 fseek( pFile
, pos
, SEEK_SET
);
124 return ftell( pFile
);
129 return ftell( getLogFile() );
136 #endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_HSQLDB_ACCESSLOG_HXX
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */