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
27 #include <rtl/ustring.hxx>
28 #include <rtl/string.hxx>
30 namespace connectivity
{ namespace hsqldb
38 LogFile( JNIEnv
* env
, jstring streamName
, const sal_Char
* _pAsciiSuffix
);
41 void writeString( const sal_Char
* _pString
, bool _bEndLine
= true );
42 void create() { getLogFile(); }
49 class OperationLogFile
: public LogFile
52 OperationLogFile( JNIEnv
* env
, jstring streamName
, const sal_Char
* _pAsciiSuffix
)
53 :LogFile( env
, streamName
, ( OString( _pAsciiSuffix
) += ".op" ).getStr() )
57 void logOperation( const sal_Char
* _pOp
)
59 writeString( _pOp
, true );
62 void logOperation( const sal_Char
* _pOp
, jlong _nLongArg
)
64 OString
sLine( _pOp
);
66 sLine
+= OString::number( _nLongArg
);
68 writeString( sLine
.getStr(), true );
71 void logReturn( jlong _nRetVal
)
73 OString
sLine( " -> " );
74 sLine
+= OString::number( _nRetVal
);
75 writeString( sLine
.getStr(), true );
78 void logReturn( jint _nRetVal
)
80 OString
sLine( " -> " );
81 sLine
+= OString::number( _nRetVal
);
82 writeString( sLine
.getStr(), true );
87 writeString( "-------------------------------", true );
88 writeString( "", true );
93 class DataLogFile
: public LogFile
96 DataLogFile( JNIEnv
* env
, jstring streamName
, const sal_Char
* _pAsciiSuffix
)
97 :LogFile( env
, streamName
, _pAsciiSuffix
)
101 void write( jint value
)
103 fputc( value
, getLogFile() );
104 fflush( getLogFile() );
107 void write( const sal_Int8
* buffer
, sal_Int32 bytesRead
)
109 fwrite( buffer
, sizeof(sal_Int8
), bytesRead
, getLogFile() );
110 fflush( getLogFile() );
113 sal_Int64
seek( sal_Int64 pos
)
115 FILE* pFile
= getLogFile();
116 fseek( pFile
, 0, SEEK_END
);
117 if ( ftell( pFile
) < pos
)
119 sal_Int8
filler( 0 );
120 while ( ftell( pFile
) < pos
)
121 fwrite( &filler
, sizeof( sal_Int8
), 1, pFile
);
124 fseek( pFile
, pos
, SEEK_SET
);
125 return ftell( pFile
);
130 return ftell( getLogFile() );
137 #endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_HSQLDB_ACCESSLOG_HXX
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */