Changeset: e222a8b0c2ce for monetdb-java URL: https://dev.monetdb.org/hg/monetdb-java/rev/e222a8b0c2ce Removed Files: src/test/java/org/monetdb/jdbc/LoggingTests.java Modified Files: ChangeLog src/main/java/org/monetdb/client/JMonetDB.java src/main/java/org/monetdb/jdbc/MonetConnection.java src/main/java/org/monetdb/mcl/net/MapiSocket.java src/main/java/org/monetdb/merovingian/Control.java Branch: default Log Message:
Remove all file-logging Fixes #12 At the Connection level, the 'debug' and 'logfile' options are now ignored. The logging-related fields and methods of MapiSocket have been removed, even the public ones. Maybe in the future we will reintroduce logging using the java.util.logging API, at levels FINER and FINEST like Postgres does. diffs (truncated from 410 to 300 lines): diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ # ChangeLog file for monetdb-java # This file is updated with Maddlog +* Thu Oct 15 2026 Joeri van Ruth [email protected] +- The 'debug' and 'logfile' connect options are now ignored. The related + fields and methods of class MapiSocket have been removed. + * Thu Oct 15 2026 Martin van Dinther <[email protected]> - Corrected method DatabaseMetaData.getFunctionColumns() for result column COLUMN_TYPE. For functions that return a table, the returned output diff --git a/src/main/java/org/monetdb/client/JMonetDB.java b/src/main/java/org/monetdb/client/JMonetDB.java --- a/src/main/java/org/monetdb/client/JMonetDB.java +++ b/src/main/java/org/monetdb/client/JMonetDB.java @@ -126,8 +126,8 @@ public final class JMonetDB { // FIXME: Control needs to respect Xhash if (copts.getOption("Xdebug").isPresent()) { - final String fname = copts.getOption("Xdebug").getArgument(); - ctl.setDebug(fname); + System.err.println("Xdebug is no longer supported."); + System.exit(1); } final String[] commands = copts.getOption("command").getArguments(); diff --git a/src/main/java/org/monetdb/jdbc/MonetConnection.java b/src/main/java/org/monetdb/jdbc/MonetConnection.java --- a/src/main/java/org/monetdb/jdbc/MonetConnection.java +++ b/src/main/java/org/monetdb/jdbc/MonetConnection.java @@ -163,31 +163,6 @@ public class MonetConnection } server = new MapiSocket(); - // we're debugging here... uhm, should be off in real life - if (validated.isDebug()) { - try { - String fname = validated.getLogfile(); - if (fname == null) - fname = "monet_" + System.currentTimeMillis() + ".log"; - - File f = new File(fname); - - int ext = fname.lastIndexOf('.'); - if (ext < 0) - ext = fname.length(); - final String pre = fname.substring(0, ext); - final String suf = fname.substring(ext); - - for (int i = 1; !f.createNewFile(); i++) { - f = new File(pre + "-" + i + suf); - } - - server.debug(f.getAbsolutePath()); // enable logging on the MapiSocket level - } catch (IOException ex) { - throw new SQLNonTransientConnectionException("Opening logfile failed: " + ex.getMessage(), "08M01"); - } - } - SqlOptionsCallback callback = null; switch (validated.getLanguage()) { case "sql": diff --git a/src/main/java/org/monetdb/mcl/net/MapiSocket.java b/src/main/java/org/monetdb/mcl/net/MapiSocket.java --- a/src/main/java/org/monetdb/mcl/net/MapiSocket.java +++ b/src/main/java/org/monetdb/mcl/net/MapiSocket.java @@ -239,15 +239,6 @@ public final class MapiSocket { } /** - * Enables/disables debug mode with logging to file - * - * @param debug Value to set - */ - public void setDebug(final boolean debug) { - target.setDebug(debug); - } - - /** * Connects to the given host and port, logging in as the given * user. If followRedirect is false, a RedirectionException is * thrown when a redirect is encountered. @@ -300,11 +291,7 @@ public final class MapiSocket { */ public List<String> connect(Target target, OptionsCallback callback) throws MCLException, MCLParseException, IOException { // Get rid of any earlier connection state, including the existing target. - // (But preserve the logging) - Writer tmpLog = this.log; - this.log = null; close(); - this.log = tmpLog; this.target = target; Target.Validated validated; @@ -701,19 +688,6 @@ public final class MapiSocket { } /** - * Enables logging to a file what is read and written from and to - * the server. Logging can be enabled at any time. However, it is - * encouraged to start debugging before actually connecting the - * socket. - * - * @param filename the name of the file to write to - * @throws IOException if the file could not be opened for writing - */ - public void debug(final String filename) throws IOException { - debug(new FileWriter(filename)); - } - - /** * Enables logging to a stream what is read and written from and to * the server. Logging can be enabled at any time. However, it is * encouraged to start debugging before actually connecting the @@ -728,19 +702,6 @@ public final class MapiSocket { // } /** - * Enables logging to a stream what is read and written from and to - * the server. Logging can be enabled at any time. However, it is - * encouraged to start debugging before actually connecting the - * socket. - * - * @param out to write the log to - */ - public void debug(final Writer out) { - log = out; - setDebug(true); - } - - /** * Get the log Writer. * * @return the log writer @@ -750,25 +711,6 @@ public final class MapiSocket { } /** - * Writes a logline tagged with a timestamp using the given type and message - * and optionally flushes afterwards. - * - * Used for debugging purposes only and represents a message data that is - * connected to reading (RD or RX) or writing (TD or TX) to the socket. - * R=Receive, T=Transmit, D=Data, X=?? - * - * @param type message type: either RD, RX, TD or TX - * @param message the message to log - * @param flush whether we need to flush buffered data to the logfile. - * @throws IOException if an IO error occurs while writing to the logfile - */ - private final void log(final String type, final String message, final boolean flush) throws IOException { - log.write(type + System.currentTimeMillis() + ": " + message + "\n"); - if (flush) - log.flush(); - } - - /** * For internal use * * @param b to enable/disable insert 'fake' newline and prompt @@ -778,10 +720,6 @@ public final class MapiSocket { return fromMonet.setInsertFakePrompts(b); } - public boolean isDebug() { - return target.isDebug(); - } - public boolean canClientInfo() { return supportsClientInfo; } @@ -818,16 +756,6 @@ public final class MapiSocket { // write the block (as final) then flush. writeBlock(true); out.flush(); - - // it's a bit nasty if an exception is thrown from the log, - // but ignoring it can be nasty as well, so it is decided to - // let it go so there is feedback about something going wrong - // it's a bit nasty if an exception is thrown from the log, - // but ignoring it can be nasty as well, so it is decided to - // let it go so there is feedback about something going wrong - if (isDebug()) { - log.flush(); - } } /** @@ -859,15 +787,6 @@ public final class MapiSocket { // write the actual block out.write(block, 0, writePos); - if (isDebug()) { - if (last) { - log("TD ", "write final block: " + writePos + " bytes", false); - } else { - log("TD ", "write block: " + writePos + " bytes", false); - } - log("TX ", new String(block, 0, writePos, StandardCharsets.UTF_8), true); - } - writePos = 0; } @@ -984,16 +903,10 @@ public final class MapiSocket { // if we have read something before, we should have been // able to read the whole, so make this fatal if (off > 0) { - if (isDebug()) { - log("RD ", "the following incomplete block was received:", false); - log("RX ", new String(b, 0, off, StandardCharsets.UTF_8), true); - } throw new IOException("Read from " + con.getInetAddress().getHostName() + ":" + con.getPort() + ": Incomplete block read from stream"); } - if (isDebug()) - log("RD ", "server closed the connection (EOF)", true); return false; } len -= s; @@ -1043,14 +956,6 @@ public final class MapiSocket { readPos = 0; - if (isDebug()) { - if (wasEndBlock) { - log("RD ", "read final block: " + blockLen + " bytes", false); - } else { - log("RD ", "read new block: " + blockLen + " bytes", false); - } - } - // sanity check to avoid bad servers make us do an ugly // stack trace if (blockLen > block.length) @@ -1059,9 +964,6 @@ public final class MapiSocket { if (!_read(block, blockLen)) return -1; - if (isDebug()) - log("RX ", new String(block, 0, blockLen, StandardCharsets.UTF_8), true); - // if this is the last block, make it end with a newline and prompt if (wasEndBlock) { // insert 'fake' newline and prompt @@ -1074,9 +976,6 @@ public final class MapiSocket { block[blockLen++] = b; } block[blockLen++] = '\n'; - if (isDebug()) { - log("RD ", "inserting prompt", true); - } } } @@ -1090,9 +989,6 @@ public final class MapiSocket { return -1; } - if (isDebug()) - log("RX ", new String(block, readPos, 1, StandardCharsets.UTF_8), true); - return block[readPos++] & 0xFF; } @@ -1229,12 +1125,6 @@ public final class MapiSocket { con = null; } catch (IOException e) { /* ignore it */ } } - if (isDebug() && log != null && log instanceof FileWriter) { - try { - log.close(); - log = null; - } catch (IOException e) { /* ignore it */ } - } } /** diff --git a/src/main/java/org/monetdb/merovingian/Control.java b/src/main/java/org/monetdb/merovingian/Control.java --- a/src/main/java/org/monetdb/merovingian/Control.java +++ b/src/main/java/org/monetdb/merovingian/Control.java @@ -53,8 +53,6 @@ public class Control { private final int port; /** The passphrase to use when connecting */ private final String passphrase; - /** The file we should write MapiSocket debuglog to */ - private String debug; private int soTimeout = -1; /* -1 means not initialized */ @@ -84,18 +82,6 @@ public class Control { soTimeout = timeout; } - /** - * Instructs to write a MCL protocol debug log to the given file. - * This affects any newly performed command, and can be changed - * in between commands. Passing null to this method disables the - * debug log. _______________________________________________ checkin-list mailing list -- [email protected] To unsubscribe send an email to [email protected]
