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 .
25 #include <rtl/ustring.hxx>
26 #include <rtl/string.hxx>
28 namespace connectivity::hsqldb
36 LogFile( JNIEnv
* env
, jstring streamName
, const char* _pAsciiSuffix
);
39 void writeString( const char* _pString
, bool _bEndLine
= true );
40 void create() { getLogFile(); }
47 class OperationLogFile
: public LogFile
50 OperationLogFile( JNIEnv
* env
, jstring streamName
, const char* _pAsciiSuffix
)
51 :LogFile( env
, streamName
, ( OString( _pAsciiSuffix
) += ".op" ).getStr() )
55 void logOperation( const char* _pOp
)
57 writeString( _pOp
, true );
60 void logOperation( const char* _pOp
, jlong _nLongArg
)
62 OString
sLine( _pOp
);
64 sLine
+= OString::number( _nLongArg
);
66 writeString( sLine
.getStr(), true );
69 void logReturn( jlong _nRetVal
)
71 OString
sLine( " -> " );
72 sLine
+= OString::number( _nRetVal
);
73 writeString( sLine
.getStr(), true );
76 void logReturn( jint _nRetVal
)
78 OString
sLine( " -> " );
79 sLine
+= OString::number( _nRetVal
);
80 writeString( sLine
.getStr(), true );
85 writeString( "-------------------------------", true );
86 writeString( "", true );
91 class DataLogFile
: public LogFile
94 DataLogFile( JNIEnv
* env
, jstring streamName
, const char* _pAsciiSuffix
)
95 :LogFile( env
, streamName
, _pAsciiSuffix
)
99 void write( jint value
)
101 fputc( value
, getLogFile() );
102 fflush( getLogFile() );
105 void write( const sal_Int8
* buffer
, sal_Int32 bytesRead
)
107 fwrite( buffer
, sizeof(sal_Int8
), bytesRead
, getLogFile() );
108 fflush( getLogFile() );
111 sal_Int64
seek( sal_Int64 pos
)
113 FILE* pFile
= getLogFile();
114 fseek( pFile
, 0, SEEK_END
);
115 if ( ftell( pFile
) < pos
)
117 sal_Int8
filler( 0 );
118 while ( ftell( pFile
) < pos
)
119 fwrite( &filler
, sizeof( sal_Int8
), 1, pFile
);
122 fseek( pFile
, pos
, SEEK_SET
);
123 return ftell( pFile
);
128 return ftell( getLogFile() );
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */