diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2020-02-24 22:08:04 +0100 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-02-27 07:32:53 +0100 |
commit | b11293297e581b87fba7e995d350ba59ecb820f2 (patch) | |
tree | fcc57953397596b49dbf1d4229a26640c7276630 /connectivity | |
parent | 64cfe0c8ae0d69981f381255acbabfe38ac61fb5 (diff) |
Postgresql: replace specific log mechanism by generic SAL_INFO/SAL_WARN
Change-Id: I601ff29cede5ef5f594fd00c8bea810080cb8388
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89383
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'connectivity')
12 files changed, 64 insertions, 277 deletions
diff --git a/connectivity/source/drivers/postgresql/pq_connection.cxx b/connectivity/source/drivers/postgresql/pq_connection.cxx index 93f9c5fcf013..fd1b9fd1297d 100644 --- a/connectivity/source/drivers/postgresql/pq_connection.cxx +++ b/connectivity/source/drivers/postgresql/pq_connection.cxx @@ -125,39 +125,6 @@ static css::uno::Sequence<OUString> ConnectionGetSupportedServiceNames() return Sequence< OUString > { "com.sun.star.sdbc.Connection" }; } -static LogLevel readLogLevelFromConfiguration() -{ - LogLevel nLogLevel = LogLevel::NONE; - OUString fileName; - osl_getModuleURLFromFunctionAddress( - reinterpret_cast<oslGenericFunction>(readLogLevelFromConfiguration), &fileName.pData ); - fileName = fileName.copy( 0, fileName.lastIndexOf( '/' )+1 ) + -#ifdef MACOSX - "../Resources/" -#endif - "postgresql-sdbc.ini"; - rtl::Bootstrap bootstrapHandle( fileName ); - - OUString str; - if( bootstrapHandle.getFrom( "PQ_LOGLEVEL", str ) ) - { - if ( str == "NONE" ) - nLogLevel = LogLevel::NONE; - else if ( str == "ERROR" ) - nLogLevel = LogLevel::Error; - else if ( str == "SQL" ) - nLogLevel = LogLevel::Sql; - else if ( str == "INFO" ) - nLogLevel = LogLevel::Info; - else - { - fprintf( stderr, "unknown loglevel %s\n", - OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() ); - } - } - return nLogLevel; -} - Connection::Connection( const rtl::Reference< comphelper::RefCountedMutex > &refMutex, const css::uno::Reference< css::uno::XComponentContext > & ctx ) @@ -165,21 +132,6 @@ Connection::Connection( m_ctx( ctx ) , m_xMutex( refMutex ) { - m_settings.m_nLogLevel = readLogLevelFromConfiguration(); - - if (m_settings.m_nLogLevel != LogLevel::NONE) - { - m_settings.logFile = fopen( "sdbc-pqsql.log", "a" ); - if( m_settings.logFile ) - { - setvbuf( m_settings.logFile, nullptr, _IONBF, 0 ); - log(&m_settings, m_settings.m_nLogLevel , "set this loglevel"); - } - else - { - fprintf( stderr, "Couldn't open sdbc-pqsql.log file\n" ); - } - } } Connection::~Connection() @@ -189,11 +141,6 @@ Connection::~Connection() PQfinish( m_settings.pConnection ); m_settings.pConnection = nullptr; } - if( m_settings.logFile ) - { - fclose( m_settings.logFile ); - m_settings.logFile = nullptr; - } } typedef std::vector< css::uno::Reference< css::sdbc::XCloseable > > CloseableVector; @@ -208,7 +155,7 @@ void Connection::close() // silently ignore, if the connection has been closed already if( m_settings.pConnection ) { - log(&m_settings, LogLevel::Info, "closing connection"); + SAL_INFO("connectivity.postgresql", "closing connection"); PQfinish( m_settings.pConnection ); m_settings.pConnection = nullptr; } @@ -576,10 +523,7 @@ void Connection::initialize( const Sequence< Any >& aArguments ) m_settings.catalog = OUString( p, strlen(p), RTL_TEXTENCODING_UTF8); m_settings.tc = tc; - if (isLog(&m_settings, LogLevel::Info)) - { - log(&m_settings, LogLevel::Info, "connection to '" + url + "' successfully opened"); - } + SAL_INFO("connectivity.postgresql", "connection to '" << url << "' successfully opened"); } void Connection::disposing() @@ -596,10 +540,7 @@ void Connection::checkClosed() Reference< XNameAccess > Connection::getTables() { - if (isLog(&m_settings, LogLevel::Info)) - { - log(&m_settings, LogLevel::Info, "Connection::getTables() got called"); - } + SAL_INFO("connectivity.postgresql", "Connection::getTables() got called"); MutexGuard guard( m_xMutex->GetMutex() ); if( !m_settings.tables.is() ) m_settings.tables = Tables::create( m_xMutex, this, &m_settings , &m_settings.pTablesImpl); @@ -611,10 +552,7 @@ Reference< XNameAccess > Connection::getTables() Reference< XNameAccess > Connection::getViews() { - if (isLog(&m_settings, LogLevel::Info)) - { - log(&m_settings, LogLevel::Info, "Connection::getViews() got called"); - } + SAL_INFO("connectivity.postgresql", "Connection::getViews() got called"); MutexGuard guard( m_xMutex->GetMutex() ); if( !m_settings.views.is() ) m_settings.views = Views::create( m_xMutex, this, &m_settings, &(m_settings.pViewsImpl) ); @@ -627,10 +565,7 @@ Reference< XNameAccess > Connection::getViews() Reference< XNameAccess > Connection::getUsers() { - if (isLog(&m_settings, LogLevel::Info)) - { - log(&m_settings, LogLevel::Info, "Connection::getUsers() got called"); - } + SAL_INFO("connectivity.postgresql", "Connection::getUsers() got called"); MutexGuard guard( m_xMutex->GetMutex() ); if( !m_settings.users.is() ) @@ -646,49 +581,7 @@ static Reference< XInterface > ConnectionCreateInstance( return * new Connection( ref, ctx ); } - -bool isLog(ConnectionSettings const *settings, LogLevel nLevel) -{ - return static_cast<int>(settings->m_nLogLevel) >= static_cast<int>(nLevel) - && settings->logFile; -} - -void log(ConnectionSettings *settings, LogLevel nLevel, const OUString &logString) -{ - log( settings, nLevel, OUStringToOString( logString, ConnectionSettings::encoding ).getStr() ); -} -void log(ConnectionSettings *settings, LogLevel nLevel, const char *str) -{ - if (isLog(settings, nLevel)) - { - static const o3tl::enumarray<LogLevel, const char*> strLevel = {"NONE", "ERROR", "SQL", "INFO"}; - - time_t t = ::time( nullptr ); - char *pString; -#ifdef _WIN32 - pString = asctime( localtime( &t ) ); -#else - struct tm timestruc; - char timestr[50]; - memset( timestr, 0 , 50); - pString = timestr; - ::localtime_r( &t , ×truc ); - asctime_r( ×truc, timestr ); -#endif - for( int i = 0 ; pString[i] ; i ++ ) - { - if( pString[i] <= 13 ) - { - pString[i] = 0; - break; - } - } - fprintf(settings->logFile, "%s [%s]: %s\n", pString, strLevel[nLevel], str); - } -} - - -} +} // end namespace static const struct cppu::ImplementationEntry g_entries[] = diff --git a/connectivity/source/drivers/postgresql/pq_connection.hxx b/connectivity/source/drivers/postgresql/pq_connection.hxx index 9b3a9e2bfe57..b05639179e7d 100644 --- a/connectivity/source/drivers/postgresql/pq_connection.hxx +++ b/connectivity/source/drivers/postgresql/pq_connection.hxx @@ -90,9 +90,7 @@ struct ConnectionSettings maxNameLen(0), maxIndexKeys(0), pTablesImpl(nullptr), - pViewsImpl(nullptr), - logFile( nullptr ), - m_nLogLevel(LogLevel::Info) + pViewsImpl(nullptr) {} static const rtl_TextEncoding encoding = RTL_TEXTENCODING_UTF8; PGconn *pConnection; @@ -106,8 +104,6 @@ struct ConnectionSettings Views *pViewsImpl; // needed to implement renaming of tables / views OUString user; OUString catalog; - FILE *logFile; - LogLevel m_nLogLevel; }; diff --git a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx index 98b15bfd64bc..4794d21e8c7b 100644 --- a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx +++ b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx @@ -65,6 +65,7 @@ ************************************************************************/ #include <algorithm> +#include <sal/log.hxx> #include "pq_databasemetadata.hxx" #include "pq_driver.hxx" #include "pq_sequenceresultset.hxx" @@ -1111,12 +1112,8 @@ css::uno::Reference< XResultSet > DatabaseMetaData::getTables( MutexGuard guard( m_xMutex->GetMutex() ); - if (isLog(m_pSettings, LogLevel::Info)) - { - log(m_pSettings, LogLevel::Info, - ("DatabaseMetaData::getTables got called with " + schemaPattern + "." - + tableNamePattern)); - } + SAL_INFO("connectivity.postgresql", "DatabaseMetaData::getTables() got called with " << schemaPattern << "." << tableNamePattern); + // ignore catalog, as a single pq connection does not support multiple catalogs // LEM TODO: this does not give the right column names, not the right number of columns, etc. @@ -1239,10 +1236,8 @@ css::uno::Reference< XResultSet > DatabaseMetaData::getSchemas( ) { MutexGuard guard( m_xMutex->GetMutex() ); - if (isLog(m_pSettings, LogLevel::Info)) - { - log(m_pSettings, LogLevel::Info, "DatabaseMetaData::getSchemas() got called"); - } + SAL_INFO("connectivity.postgresql", "DatabaseMetaData::getSchemas() got called"); + // <b>TABLE_SCHEM</b> string =&gt; schema name Reference< XStatement > statement = m_origin->createStatement(); Reference< XResultSet > rs = statement->executeQuery( @@ -1442,12 +1437,8 @@ css::uno::Reference< XResultSet > DatabaseMetaData::getColumns( // continue ! MutexGuard guard( m_xMutex->GetMutex() ); - if (isLog(m_pSettings, LogLevel::Info)) - { - log(m_pSettings, LogLevel::Info, - ("DatabaseMetaData::getColumns got called with " + schemaPattern + "." - + tableNamePattern + "." + columnNamePattern)); - } + SAL_INFO("connectivity.postgresql", "DatabaseMetaData::getColumns() got called with " + << schemaPattern << "." << tableNamePattern << "." << columnNamePattern); // ignore catalog, as a single pq connection // does not support multiple catalogs anyway @@ -1618,12 +1609,8 @@ css::uno::Reference< XResultSet > DatabaseMetaData::getColumnPrivileges( { MutexGuard guard( m_xMutex->GetMutex() ); - if (isLog(m_pSettings, LogLevel::Info)) - { - log(m_pSettings, LogLevel::Info, - ("DatabaseMetaData::getColumnPrivileges got called with " + schema + "." + table + "." - + columnNamePattern)); - } + SAL_INFO("connectivity.postgresql", "DatabaseMetaData::getColumnPrivileges() got called with " + << schema << "." << table << "." << columnNamePattern); Reference< XParameters > parameters( m_getColumnPrivs_stmt, UNO_QUERY_THROW ); parameters->setString( 1 , schema ); @@ -1642,12 +1629,8 @@ css::uno::Reference< XResultSet > DatabaseMetaData::getTablePrivileges( { MutexGuard guard( m_xMutex->GetMutex() ); - if (isLog(m_pSettings, LogLevel::Info)) - { - log(m_pSettings, LogLevel::Info, - ("DatabaseMetaData::getTablePrivileges got called with " + schemaPattern + "." - + tableNamePattern)); - } + SAL_INFO("connectivity.postgresql", "DatabaseMetaData::getTablePrivileges() got called with " + << schemaPattern << "." << tableNamePattern); Reference< XParameters > parameters( m_getTablePrivs_stmt, UNO_QUERY_THROW ); parameters->setString( 1 , schemaPattern ); @@ -1697,11 +1680,8 @@ css::uno::Reference< XResultSet > DatabaseMetaData::getPrimaryKeys( // 5. KEY_SEQ short => sequence number within primary key // 6. PK_NAME string => primary key name (may be NULL ) - if (isLog(m_pSettings, LogLevel::Info)) - { - log(m_pSettings, LogLevel::Info, - "DatabaseMetaData::getPrimaryKeys got called with " + schema + "." + table); - } + SAL_INFO("connectivity.postgresql", "DatabaseMetaData::getPrimaryKeys() got called with " + << schema << "." << table); Reference< XPreparedStatement > statement = m_origin->prepareStatement( "SELECT nmsp.nspname, " @@ -2282,10 +2262,7 @@ css::uno::Reference< XResultSet > DatabaseMetaData::getTypeInfo( ) // Note: Indexes start at 0 (in the API doc, they start at 1) MutexGuard guard( m_xMutex->GetMutex() ); - if (isLog(m_pSettings, LogLevel::Info)) - { - log(m_pSettings, LogLevel::Info, "DatabaseMetaData::getTypeInfo() got called"); - } + SAL_INFO("connectivity.postgresql", "DatabaseMetaData::getTypeInfo() got called"); Reference< XStatement > statement = m_origin->createStatement(); Reference< XResultSet > rs = statement->executeQuery( diff --git a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx index 887f36d4c909..2e352320353f 100644 --- a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx +++ b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx @@ -34,6 +34,7 @@ * ************************************************************************/ +#include <sal/log.hxx> #include "pq_preparedstatement.hxx" #include "pq_tools.hxx" #include "pq_statics.hxx" @@ -266,7 +267,7 @@ void PreparedStatement::raiseSQLException( const char * errorMsg ) buf.appendAscii( m_executedStatement.getStr() ); buf.append( "')" ); OUString error = buf.makeStringAndClear(); - log(m_pSettings, LogLevel::Error, error); + SAL_WARN("connectivity.postgresql", error); throw SQLException( error, *this, OUString(), 1, Any() ); } diff --git a/connectivity/source/drivers/postgresql/pq_statement.cxx b/connectivity/source/drivers/postgresql/pq_statement.cxx index 43760281a606..6c2deef8fe0f 100644 --- a/connectivity/source/drivers/postgresql/pq_statement.cxx +++ b/connectivity/source/drivers/postgresql/pq_statement.cxx @@ -34,6 +34,7 @@ * ************************************************************************/ +#include <sal/log.hxx> #include "pq_statement.hxx" #include "pq_fakedupdateableresultset.hxx" #include "pq_updateableresultset.hxx" @@ -213,7 +214,7 @@ void Statement::raiseSQLException( OUString error = "pq_driver: " + OUString( errorMsg, strlen(errorMsg), ConnectionSettings::encoding ) + " (caused by statement '" + sql + "')"; - log(m_pSettings, LogLevel::Error, error); + SAL_WARN("connectivity.postgresql", error); throw SQLException( error, *this, OUString(), 1, Any() ); } @@ -237,7 +238,6 @@ sal_Int32 Statement::executeUpdate( const OUString& sql ) /// @throws SQLException static void raiseSQLException( - ConnectionSettings *pSettings, const Reference< XInterface> & owner, const OString & sql, const char * errorMsg, @@ -257,7 +257,7 @@ static void raiseSQLException( buf.append( OStringToOUString( sql, ConnectionSettings::encoding ) ); buf.append( "')" ); OUString error = buf.makeStringAndClear(); - log(pSettings, LogLevel::Error, error); + SAL_WARN("connectivity.postgresql", error); throw SQLException( error, owner, OUString(), 1, Any() ); } @@ -268,8 +268,7 @@ static std::vector< OUString > lookupKeys( const Reference< css::container::XNameAccess > &tables, const OUString & table, OUString *pSchema, - OUString *pTable, - ConnectionSettings *pSettings) + OUString *pTable) { std::vector< OUString > ret; Reference< XKeysSupplier > keySupplier; @@ -304,13 +303,7 @@ static std::vector< OUString > lookupKeys( // is ambiguous, as I don't know postgresql searchpath, // I can't continue here, as I may write to a different table keySupplier.clear(); - if (isLog(pSettings, LogLevel::Info)) - { - OString buf = "Can't offer updateable result set because table " - + OUStringToOString(name, ConnectionSettings::encoding) - + " is duplicated, add schema to resolve ambiguity"; - log(pSettings, LogLevel::Info, buf.getStr()); - } + SAL_INFO("connectivity.postgresql", "Can't offer updateable result set because table " << name << " is duplicated, add schema to resolve ambiguity"); break; } keySupplier.set( set, UNO_QUERY ); @@ -320,12 +313,7 @@ static std::vector< OUString > lookupKeys( } else { - if (isLog(pSettings, LogLevel::Info)) - { - OString buf = "Can't offer updateable result set ( table " - + OUStringToOString(table, ConnectionSettings::encoding) + " is unknown)"; - log(pSettings, LogLevel::Info, buf.getStr()); - } + SAL_INFO("connectivity.postgresql", "Can't offer updateable result set ( table " << table << " is unknown)"); } if( keySupplier.is() ) @@ -364,13 +352,7 @@ static std::vector< OUString > lookupKeys( } if( ret.empty() ) { - if (isLog(pSettings, LogLevel::Info)) - { - OString buf = "Can't offer updateable result set ( table " - + OUStringToOString(table, ConnectionSettings::encoding) - + " does not have a primary key)"; - log(pSettings, LogLevel::Info, buf.getStr()); - } + SAL_INFO("connectivity.postgresql", "Can't offer updateable result set ( table " << table << " does not have a primary key)"); } } return ret; @@ -385,7 +367,7 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data ) duration = osl_getGlobalTimer() - duration; if( ! result ) raiseSQLException( - pSettings, data->owner, cmd, PQerrorMessage( pSettings->pConnection ) ); + data->owner, cmd, PQerrorMessage( pSettings->pConnection ) ); ExecStatusType state = PQresultStatus( result ); *(data->pLastOidInserted) = 0; @@ -407,27 +389,17 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data ) // otherwise the table name is empty *(data->pLastTableInserted) = extractTableFromInsert( OStringToOUString( cmd, ConnectionSettings::encoding ) ); - if( isLog( pSettings, LogLevel::Sql ) ) + + OString strMain = "executed command '" + cmd + "' successfully ('" + OString::number(*( data->pMultipleResultUpdateCount )) + + "), duration=" + OString::number(duration) + "ms"; + + OString strOption; + if( *(data->pLastOidInserted) ) { - OStringBuffer buf( 128 ); - buf.append( "executed command '" ); - buf.append( cmd.getStr() ); - buf.append( "' successfully (" ); - buf.append( *( data->pMultipleResultUpdateCount ) ); - buf.append( ")" ); - buf.append( ", duration=" ); - buf.append( duration ); - buf.append( "ms" ); - if( *(data->pLastOidInserted) ) - { - buf.append( ", usedOid=" ); - buf.append( *(data->pLastOidInserted) ); - buf.append( ", diagnosedTable=" ); - buf.append( - OUStringToOString( *data->pLastTableInserted, ConnectionSettings::encoding ) ); - } - log(pSettings, LogLevel::Sql, buf.makeStringAndClear().getStr()); + strOption += ", usedOid=" + OString::number( *(data->pLastOidInserted) ) + ", diagnosedTable=" + + OUStringToOString(*data->pLastTableInserted, ConnectionSettings::encoding); } + SAL_INFO("connectivity.postgresql", strMain + strOption); PQclear( result ); break; } @@ -454,8 +426,7 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data ) pSettings->tables : data->tableSupplier->getTables() , sourceTable, &schema, - &table, - pSettings); + &table); // check, whether the columns are in the result set (required !) int i; @@ -505,16 +476,11 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data ) } else { - OString buf = "can't support updateable result for selects with multiple tables (" - + cmd + ")"; - log(pSettings, LogLevel::Sql, buf.getStr() ); + SAL_WARN("connectivity.postgresql", "can't support updateable result for selects with multiple tables (" << cmd << ")"); } if( ! (*(data->pLastResultset)).is() ) { - if (isLog( pSettings, LogLevel::Error)) - { - log(pSettings, LogLevel::Error, aReason.getStr()); - } + SAL_WARN("connectivity.postgresql", aReason); // TODO: How to react here correctly ? // remove this piece of code @@ -540,13 +506,7 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data ) data->ppSettings,result, schema, table ) ); *(data->pMultipleResultAvailable) = true; ret = true; - if (isLog(pSettings, LogLevel::Sql)) - { - OString buf = "executed query '" + cmd + "' successfully, duration=" - + OString::number(duration) + "ms, returnedRows=" + OString::number(returnedRows) - + "."; - log(pSettings, LogLevel::Sql, buf.getStr()); - } + SAL_INFO("connectivity.postgresql", "executed query '" << cmd << "' successfully, duration=" << duration << "ms, returnedRows=" << returnedRows << "."); break; } case PGRES_EMPTY_QUERY: @@ -557,7 +517,7 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data ) case PGRES_FATAL_ERROR: default: raiseSQLException( - pSettings, data->owner, cmd, PQresultErrorMessage( result ) , PQresStatus( state ) ); + data->owner, cmd, PQresultErrorMessage( result ) , PQresStatus( state ) ); } return ret; diff --git a/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx b/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx index 409aca958f2b..880adc647c7e 100644 --- a/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx +++ b/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx @@ -34,6 +34,7 @@ * ************************************************************************/ +#include <sal/log.hxx> #include <rtl/ustrbuf.hxx> #include <cppuhelper/queryinterface.hxx> @@ -183,10 +184,8 @@ OUString UpdateableResultSet::buildWhereClause() void UpdateableResultSet::insertRow( ) { MutexGuard guard( m_xMutex->GetMutex() ); - if (isLog(*m_ppSettings, LogLevel::Info)) - { - log(*m_ppSettings, LogLevel::Info, "UpdateableResultSet::insertRow got called"); - } + SAL_INFO("connectivity.postgresql", "UpdateableResultSet::insertRow() got called"); + if( ! m_insertRow ) throw SQLException( "pq_resultset.insertRow: moveToInsertRow has not been called !", @@ -277,10 +276,8 @@ void UpdateableResultSet::insertRow( ) void UpdateableResultSet::updateRow( ) { MutexGuard guard( m_xMutex->GetMutex() ); - if (isLog(*m_ppSettings, LogLevel::Info)) - { - log(*m_ppSettings, LogLevel::Info, "UpdateableResultSet::updateRow got called"); - } + SAL_INFO("connectivity.postgresql", "UpdateableResultSet::updateRow() got called"); + if( m_insertRow ) throw SQLException( "pq_resultset.updateRow: moveToCurrentRow has not been called !", @@ -326,10 +323,8 @@ void UpdateableResultSet::updateRow( ) void UpdateableResultSet::deleteRow( ) { - if (isLog(*m_ppSettings, LogLevel::Info)) - { - log(*m_ppSettings, LogLevel::Info, "UpdateableResultSet::deleteRow got called"); - } + SAL_INFO("connectivity.postgresql", "UpdateableResultSet::deleteRow() got called"); + if( m_insertRow ) throw SQLException( "pq_resultset.deleteRow: deleteRow cannot be called when on insert row !", diff --git a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx index 8b716cb61c4c..4edb1aabc068 100644 --- a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx +++ b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx @@ -35,6 +35,7 @@ ************************************************************************/ #include <rtl/ustrbuf.hxx> +#include <sal/log.hxx> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> #include <com/sun/star/sdbc/SQLException.hpp> @@ -275,14 +276,7 @@ void Columns::refresh() { try { - if (isLog(m_pSettings, LogLevel::Info)) - { - OString buf = "sdbcx.Columns get refreshed for table " + - OUStringToOString( m_schemaName, ConnectionSettings::encoding ) + - "." + - OUStringToOString( m_tableName, ConnectionSettings::encoding ); - log( m_pSettings, LogLevel::Info, buf.getStr() ); - } + SAL_INFO("connectivity.postgresql", "sdbcx.Columns get refreshed for table " << m_schemaName << "." << m_tableName); osl::MutexGuard guard( m_xMutex->GetMutex() ); Statics &st = getStatics(); diff --git a/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx index 40b410920fc8..12acb6f321d6 100644 --- a/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx +++ b/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx @@ -34,6 +34,7 @@ * ************************************************************************/ +#include <sal/log.hxx> #include <vector> #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> @@ -98,12 +99,7 @@ void IndexColumns::refresh() { try { - if (isLog(m_pSettings, LogLevel::Info)) - { - OString buf = "sdbcx.IndexColumns get refreshed for index " + - OUStringToOString( m_indexName, ConnectionSettings::encoding ); - log( m_pSettings, LogLevel::Info, buf.getStr() ); - } + SAL_INFO("connectivity.postgresql", "sdbcx.IndexColumns get refreshed for index " << m_indexName); osl::MutexGuard guard( m_xMutex->GetMutex() ); diff --git a/connectivity/source/drivers/postgresql/pq_xindexes.cxx b/connectivity/source/drivers/postgresql/pq_xindexes.cxx index f03295a4925d..2f6df914f0a2 100644 --- a/connectivity/source/drivers/postgresql/pq_xindexes.cxx +++ b/connectivity/source/drivers/postgresql/pq_xindexes.cxx @@ -34,6 +34,7 @@ * ************************************************************************/ +#include <sal/log.hxx> #include <rtl/ustrbuf.hxx> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> @@ -91,14 +92,7 @@ void Indexes::refresh() { try { - if (isLog(m_pSettings, LogLevel::Info)) - { - OString buf = "sdbcx.Indexes get refreshed for table " + - OUStringToOString( m_schemaName, ConnectionSettings::encoding ) + - "." + - OUStringToOString( m_tableName, ConnectionSettings::encoding ); - log( m_pSettings, LogLevel::Info, buf.getStr() ); - } + SAL_INFO("connectivity.postgresql", "sdbcx.Indexes get refreshed for table " << m_schemaName << "." << m_tableName); osl::MutexGuard guard( m_xMutex->GetMutex() ); Statics & st = getStatics(); diff --git a/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx b/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx index 561b5421e074..890b57fa7420 100644 --- a/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx +++ b/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx @@ -34,6 +34,7 @@ * ************************************************************************/ +#include <sal/log.hxx> #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> #include <com/sun/star/sdbc/SQLException.hpp> #include <com/sun/star/sdbc/XRow.hpp> @@ -86,14 +87,7 @@ void KeyColumns::refresh() { try { - if (isLog(m_pSettings, LogLevel::Info)) - { - OString buf = "sdbcx.KeyColumns get refreshed for table " + - OUStringToOString( m_schemaName, ConnectionSettings::encoding ) + - "." + - OUStringToOString( m_tableName, ConnectionSettings::encoding ); - log( m_pSettings, LogLevel::Info, buf.getStr() ); - } + SAL_INFO("connectivity.postgresql", "sdbcx.KeyColumns get refreshed for table " << m_schemaName << "." << m_tableName); osl::MutexGuard guard( m_xMutex->GetMutex() ); diff --git a/connectivity/source/drivers/postgresql/pq_xkeys.cxx b/connectivity/source/drivers/postgresql/pq_xkeys.cxx index 892252a5252f..2297b557e6af 100644 --- a/connectivity/source/drivers/postgresql/pq_xkeys.cxx +++ b/connectivity/source/drivers/postgresql/pq_xkeys.cxx @@ -34,6 +34,7 @@ * ************************************************************************/ +#include <sal/log.hxx> #include <rtl/ustrbuf.hxx> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> @@ -110,13 +111,7 @@ void Keys::refresh() { try { - if (isLog(m_pSettings, LogLevel::Info)) - { - OString buf( "sdbcx.Keys get refreshed for table " + - OUStringToOString( m_schemaName, ConnectionSettings::encoding ) + - "." + OUStringToOString( m_tableName, ConnectionSettings::encoding )); - log( m_pSettings, LogLevel::Info, buf.getStr() ); - } + SAL_INFO("connectivity.postgresql", "sdbcx.Keys get refreshed for table " << m_schemaName << "." << m_tableName); osl::MutexGuard guard( m_xMutex->GetMutex() ); Statics & st = getStatics(); diff --git a/connectivity/source/drivers/postgresql/pq_xuser.cxx b/connectivity/source/drivers/postgresql/pq_xuser.cxx index 6040b2fbcadf..bc06c541064e 100644 --- a/connectivity/source/drivers/postgresql/pq_xuser.cxx +++ b/connectivity/source/drivers/postgresql/pq_xuser.cxx @@ -34,6 +34,7 @@ * ************************************************************************/ +#include <sal/log.hxx> #include <rtl/ustrbuf.hxx> #include <cppuhelper/typeprovider.hxx> @@ -119,16 +120,7 @@ void User::changePassword( sal_Int32 User::getPrivileges( const OUString& objName, sal_Int32 objType ) { - if (isLog(m_pSettings, LogLevel::Info)) - { - Statics & st = getStatics(); - - OUStringBuffer buf( 128 ); - buf.append( "User::getPrivileges[" ).append( extractStringProperty( this, st.NAME ) ) - .append( "] got called for " ).append( objName ).append( "(type=" ) - .append( OUString::number(objType) ).append(")"); - log(m_pSettings, LogLevel::Info, buf.makeStringAndClear()); - } + SAL_INFO("connectivity.postgresql", "User::getPrivileges[\"Name\"] got called for " << objName << "(type=" << objType << ")"); // all privileges return 0xffffffff; } |