From b465f5307f9f5506beb1edbcc0fb56eed7c29c12 Mon Sep 17 00:00:00 2001 From: Barry Lind Date: Tue, 11 Jun 2002 02:55:16 +0000 Subject: The patch does the following: Allows you to set the loglevel at runtime by adding ?loglevel=X to the connection URL, where 1 = INFO and 2 = DEBUG. Automatically turns on logging by calling DriverManager.setPrintWriter(new PrintWriter(System.out)) if one is not already set. Adds a Driver.info() message that prints out the version number Adds member variables logDebug and logInfo that can be checked before making logging methods calls Adds a build number to the version number string. This build number will need to be manually incremented when we see fit. ---------------------------------------------------------------------- Modified Files: org/postgresql/Connection.java org/postgresql/Driver.java.in org/postgresql/fastpath/Fastpath.java org/postgresql/jdbc1/DatabaseMetaData.java org/postgresql/jdbc2/Connection.java org/postgresql/jdbc2/DatabaseMetaData.java org/postgresql/largeobject/LargeObjectManager.java org/postgresql/util/PSQLException.java org/postgresql/util/Serialize.java ---------------------------------------------------------------------- --- .../jdbc/org/postgresql/util/Serialize.java | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/interfaces/jdbc/org/postgresql/util') diff --git a/src/interfaces/jdbc/org/postgresql/util/Serialize.java b/src/interfaces/jdbc/org/postgresql/util/Serialize.java index 59d9c03206e..80d10bc5410 100644 --- a/src/interfaces/jdbc/org/postgresql/util/Serialize.java +++ b/src/interfaces/jdbc/org/postgresql/util/Serialize.java @@ -1,5 +1,6 @@ package org.postgresql.util; +import org.postgresql.Driver; import java.io.*; import java.lang.*; import java.lang.reflect.*; @@ -128,14 +129,14 @@ public class Serialize try { conn = c; - DriverManager.println("Serialize: initializing instance for type: " + type); + if (Driver.logDebug) Driver.debug("Serialize: initializing instance for type: " + type); tableName = toPostgreSQL(type); className = type; ourClass = Class.forName(className); } catch (ClassNotFoundException cnfe) { - DriverManager.println("Serialize: " + className + " java class not found"); + if (Driver.logDebug) Driver.debug("Serialize: " + className + " java class not found"); throw new PSQLException("postgresql.serial.noclass", type); } @@ -147,14 +148,14 @@ public class Serialize if (rs.next()) { status = true; - DriverManager.println("Serialize: " + tableName + " table found"); + if (Driver.logDebug) Driver.debug("Serialize: " + tableName + " table found"); } rs.close(); } // This should never occur, as org.postgresql has it's own internal checks if (!status) { - DriverManager.println("Serialize: " + tableName + " table not found"); + if (Driver.logDebug) Driver.debug("Serialize: " + tableName + " table not found"); throw new PSQLException("postgresql.serial.table", type); } // Finally cache the fields within the table @@ -186,9 +187,9 @@ public class Serialize { try { - DriverManager.println("Serialize.fetch: " + "attempting to instantiate object of type: " + ourClass.getName() ); + if (Driver.logDebug) Driver.debug("Serialize.fetch: " + "attempting to instantiate object of type: " + ourClass.getName() ); Object obj = ourClass.newInstance(); - DriverManager.println("Serialize.fetch: " + "instantiated object of type: " + ourClass.getName() ); + if (Driver.logDebug) Driver.debug("Serialize.fetch: " + "instantiated object of type: " + ourClass.getName() ); // NB: we use java.lang.reflect here to prevent confusion with // the org.postgresql.Field @@ -219,7 +220,7 @@ public class Serialize sb.append(" where oid="); sb.append(oid); - DriverManager.println("Serialize.fetch: " + sb.toString()); + if (Driver.logDebug) Driver.debug("Serialize.fetch: " + sb.toString()); ResultSet rs = conn.ExecSQL(sb.toString()); if (rs != null) @@ -388,7 +389,7 @@ public class Serialize sb.append(')'); } - DriverManager.println("Serialize.store: " + sb.toString() ); + if (Driver.logDebug) Driver.debug("Serialize.store: " + sb.toString() ); org.postgresql.ResultSet rs = (org.postgresql.ResultSet) conn.ExecSQL(sb.toString()); // fetch the OID for returning @@ -495,13 +496,13 @@ public class Serialize ResultSet rs = con.ExecSQL("select relname from pg_class where relname = '" + tableName + "'"); if ( rs.next() ) { - DriverManager.println("Serialize.create: table " + tableName + " exists, skipping"); + if (Driver.logDebug) Driver.debug("Serialize.create: table " + tableName + " exists, skipping"); rs.close(); return; } // else table not found, so create it - DriverManager.println("Serialize.create: table " + tableName + " not found, creating" ); + if (Driver.logDebug) Driver.debug("Serialize.create: table " + tableName + " not found, creating" ); // No entries returned, so the table doesn't exist StringBuffer sb = new StringBuffer("create table "); @@ -547,7 +548,7 @@ public class Serialize sb.append(")"); // Now create the table - DriverManager.println("Serialize.create: " + sb ); + if (Driver.logDebug) Driver.debug("Serialize.create: " + sb ); con.ExecSQL(sb.toString()); } -- cgit v1.2.3