db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r674354 - in /db/derby/code/trunk/java: drda/org/apache/derby/drda/ drda/org/apache/derby/impl/drda/ drda/org/apache/derby/loc/drda/ testing/org/apache/derbyTesting/functionTests/master/
Date Sun, 06 Jul 2008 22:04:56 GMT
Author: kmarsden
Date: Sun Jul  6 15:04:55 2008
New Revision: 674354

URL: http://svn.apache.org/viewvc?rev=674354&view=rev
Log:
DERBY-3706 NetworkServer console messages should print a time stamp

Contributed by Suran Jayathilaka


Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
    db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/derbyrunjartest.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/maxthreads.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/timeslice.out

Modified: db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java?rev=674354&r1=674353&r2=674354&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java Sun Jul
 6 15:04:55 2008
@@ -663,7 +663,7 @@
         //
         String  successMessage = server.localizeMessage( "DRDA_SecurityInstalled.I", null
);
         
-        server.consoleMessage( successMessage );
+        server.consoleMessage( successMessage, true );
     }
 
     /**

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java?rev=674354&r1=674353&r2=674354&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java Sun Jul 
6 15:04:55 2008
@@ -8030,7 +8030,7 @@
 	protected  void trace(String value)
 	{
 		if (SanityManager.DEBUG && server.debugOutput == true)
-			server.consoleMessage(value);
+			server.consoleMessage(value, true);
 	}
 
 	/***

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=674354&r1=674353&r2=674354&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
(original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
Sun Jul  6 15:04:55 2008
@@ -538,7 +538,7 @@
 	public void consoleError(String msg)
 		throws Exception
 	{
-		consoleMessage(msg);
+		consoleMessage(msg, true);
 		throw new Exception(msg);
 	}
 
@@ -564,7 +564,7 @@
 	 */
 	public void consoleExceptionPrintTrace(Throwable e)
 	{
-		consoleMessage(e.getMessage());
+		consoleMessage(e.getMessage(), true);
 		PrintWriter lw = logWriter;
 		if (lw != null)
 		{
@@ -593,15 +593,20 @@
 	 * Write a message to console output stream
 	 *
 	 * @param msg	message
+     * @param printTimeStamp Whether to prepend a timestamp to the message or not
 	 */
-	public void consoleMessage(String msg)
+	public void consoleMessage(String msg, boolean printTimeStamp)
 	{
 		// print to console if we have one
 		PrintWriter lw = logWriter;
 		if (lw != null)
 		{
 			synchronized(lw) {
-				lw.println(msg);
+                if (printTimeStamp) {
+                    lw.println(getFormattedTimestamp() + " : " + msg);
+                } else {
+                    lw.println(msg);                    
+                }
 			}
 		}
 		// always print to derby.log
@@ -609,7 +614,11 @@
 		if (lw != null)
 			synchronized(lw)
 			{
-				Monitor.logMessage(msg);
+				if (printTimeStamp) {
+                    Monitor.logMessage(getFormattedTimestamp() + " : " + msg);
+                } else {
+                    Monitor.logMessage(msg);
+                }
 			}
 	}
 
@@ -743,18 +752,15 @@
 		default:
 		case SSL_OFF:
 			consolePropertyMessage("DRDA_Ready.I", new String [] 
-				{Integer.toString(portNumber), att_srvclsnm, versionString,
-				 getFormattedTimestamp()});
+				{Integer.toString(portNumber), att_srvclsnm, versionString});
 			break;
 		case SSL_BASIC:
 			consolePropertyMessage("DRDA_SSLReady.I", new String [] 
-				{Integer.toString(portNumber), att_srvclsnm, versionString,
-				 getFormattedTimestamp()});
+				{Integer.toString(portNumber), att_srvclsnm, versionString});
 			break;
 		case SSL_PEER_AUTHENTICATION:
 			consolePropertyMessage("DRDA_SSLClientAuthReady.I", new String [] 
-				{Integer.toString(portNumber), att_srvclsnm, versionString,
-				 getFormattedTimestamp()});
+				{Integer.toString(portNumber), att_srvclsnm, versionString});
 			break;
 		}
 		
@@ -844,7 +850,7 @@
 	    try{
 	       serverSocket.close();
 	    }catch(IOException e){
-			consolePropertyMessage("DRDA_ListenerClose.S");
+			consolePropertyMessage("DRDA_ListenerClose.S", true);
 	    }
 
 
@@ -889,8 +895,7 @@
 		}
 
 		consolePropertyMessage("DRDA_ShutdownSuccess.I", new String [] 
-						        {att_srvclsnm, versionString, 
-								getFormattedTimestamp()});
+						        {att_srvclsnm, versionString});
     }
 	
 	/** 
@@ -1304,7 +1309,7 @@
 	{
 		try {
 		for (int i = 1; i <= NO_USAGE_MSGS; i++)
-			consolePropertyMessage("DRDA_Usage"+i+".I");
+			consolePropertyMessage("DRDA_Usage"+i+".I", false);
 		} catch (Exception e) {}	// ignore exceptions - there shouldn't be any
 	}
 
@@ -1820,13 +1825,14 @@
 	 * Put property message on console
 	 *
 	 * @param msgProp		message property key
-	 *
-	 * @throws Exception if an error occurs
+	 * @param printTimeStamp whether to prepend a timestamp to the message
+     *
+     * @throws Exception if an error occurs
 	 */
-	protected void consolePropertyMessage(String msgProp)
+	protected void consolePropertyMessage(String msgProp, boolean printTimeStamp)
 		throws Exception
 	{
-		consolePropertyMessageWork(msgProp, null);
+		consolePropertyMessageWork(msgProp, null, printTimeStamp);
 	}
 	/**
 	 * Put property message on console
@@ -1839,7 +1845,7 @@
 	protected void consolePropertyMessage(String msgProp, String arg)
 		throws Exception
 	{
-		consolePropertyMessageWork(msgProp, new String [] {arg});
+		consolePropertyMessageWork(msgProp, new String [] {arg}, true);
 	}
 	/**
 	 * Put property message on console
@@ -1852,7 +1858,7 @@
 	protected void consolePropertyMessage(String msgProp, String [] args)
 		throws Exception
 	{
-		consolePropertyMessageWork(msgProp, args);
+		consolePropertyMessageWork(msgProp, args, true);
 	}
 	/**
 	 * Is this the command protocol
@@ -2106,7 +2112,7 @@
         int command = findCommand(args);
         if (command == COMMAND_UNKNOWN)
         {
-            consolePropertyMessage("DRDA_NoCommand.U");
+            consolePropertyMessage("DRDA_NoCommand.U", true);
         }
 
         return command;
@@ -2144,8 +2150,7 @@
 			case COMMAND_SHUTDOWN:
 				shutdown();
 				consolePropertyMessage("DRDA_ShutdownSuccess.I", new String [] 
-								{att_srvclsnm, versionString, 
-								getFormattedTimestamp()});
+								{att_srvclsnm, versionString});
 				break;
 			case COMMAND_TRACE:
 				{
@@ -2174,7 +2179,7 @@
 			case COMMAND_SYSINFO:
 				{
 					String info = sysinfo();
-					consoleMessage(info);
+					consoleMessage(info, false);
 					break;
 				}
 			case COMMAND_MAXTHREADS:
@@ -2193,7 +2198,7 @@
 				break;
 			case COMMAND_RUNTIME_INFO:
 				String reply = runtimeInfo();
-				consoleMessage(reply);
+				consoleMessage(reply, false);
 				break;
 			case COMMAND_TIMESLICE:
 				int timeslice = 0;
@@ -2510,7 +2515,7 @@
 		   clientIs = clientSocket.getInputStream();
 	       clientOs = clientSocket.getOutputStream();
 		} catch (IOException e) {
-			consolePropertyMessage("DRDA_NoInputStream.I");
+			consolePropertyMessage("DRDA_NoInputStream.I", true);
 			throw e;
         }
 	}
@@ -2703,7 +2708,7 @@
 		fillReplyBuffer();
 		readCommandReplyHeader();
 		if (replyBufferPos >= replyBufferCount)
-			consolePropertyMessage("DRDA_InvalidReplyTooShort.S");
+			consolePropertyMessage("DRDA_InvalidReplyTooShort.S", true);
 		int messageType = replyBuffer[replyBufferPos++] & 0xFF;
 		if (messageType == OK)		// O.K.
 			return;
@@ -2714,7 +2719,7 @@
 		else if (messageType == SQLWARNING)
 			wrapSQLWarning(message);
 		else
-			consolePropertyMessage(message);
+			consolePropertyMessage(message, true);
 	}
 
 	
@@ -2763,7 +2768,7 @@
 			clientSocketError(e);
 		}
 		if (replyBufferCount == -1)
-			consolePropertyMessage("DRDA_InvalidReplyTooShort.S");
+			consolePropertyMessage("DRDA_InvalidReplyTooShort.S", true);
 		replyBufferPos = 0;
 	}
 	/**
@@ -2793,7 +2798,7 @@
 	{
 		ensureDataInBuffer(2);
 		if (replyBufferPos + 2 > replyBufferCount)
-			consolePropertyMessage("DRDA_InvalidReplyTooShort.S");
+			consolePropertyMessage("DRDA_InvalidReplyTooShort.S", true);
 	 	return ((replyBuffer[replyBufferPos++] & 0xff) << 8) + 
 			    (replyBuffer[replyBufferPos++] & 0xff);
 	}
@@ -2805,7 +2810,7 @@
 	{
 		ensureDataInBuffer(4);
 		if (replyBufferPos + 4 > replyBufferCount)
-			consolePropertyMessage("DRDA_InvalidReplyTooShort.S");
+			consolePropertyMessage("DRDA_InvalidReplyTooShort.S", true);
 	 	return ((replyBuffer[replyBufferPos++] & 0xff) << 24) + 
 	 	 	((replyBuffer[replyBufferPos++] & 0xff) << 16) + 
 	 		((replyBuffer[replyBufferPos++] & 0xff) << 8) + 
@@ -2825,7 +2830,7 @@
 		if (replyBuffer[replyBufferPos++] == 0)		// O.K.
 			return readLDString();
 		else
-			consolePropertyMessage(msgKey);
+			consolePropertyMessage(msgKey, true);
 		return null;
 			
 	}
@@ -2844,7 +2849,7 @@
 		int strlen = readShort();
 		ensureDataInBuffer(strlen);
 		if (replyBufferPos + strlen > replyBufferCount)
-			consolePropertyMessage("DRDA_InvalidReplyTooShort.S");
+			consolePropertyMessage("DRDA_InvalidReplyTooShort.S", true);
 		String retval= new String(replyBuffer, replyBufferPos, strlen, DEFAULT_ENCODING);
 		replyBufferPos += strlen;
 		return retval;
@@ -2863,7 +2868,7 @@
 		if (replyBuffer[replyBufferPos++] == 0)		// O.K.
 			return readLDBytes();
 		else
-			consolePropertyMessage(msgKey);
+			consolePropertyMessage(msgKey, true);
 		return null;
 			
 	}
@@ -2878,7 +2883,7 @@
 		int len = readShort();
 		ensureDataInBuffer(len);
 		if (replyBufferPos + len > replyBufferCount)
-			consolePropertyMessage("DRDA_InvalidReplyTooShort.S");
+			consolePropertyMessage("DRDA_InvalidReplyTooShort.S", true);
 		byte [] retval =  new byte[len];
 		for (int i = 0; i < len; i++)
 			retval[i] = replyBuffer[replyBufferPos++];
@@ -3133,10 +3138,11 @@
 	 *
 	 * @param messageKey	message key
 	 * @param args			arguments to message
-	 *
-	 * @throws Exception if an error occurs
+	 * @param printTimeStamp whether to prepend a timestamp to the message
+     *
+     * @throws Exception if an error occurs
 	 */
-	private void consolePropertyMessageWork(String messageKey, String [] args)
+	private void consolePropertyMessageWork(String messageKey, String [] args, boolean printTimeStamp)
 		throws Exception
 	{
 		String locMsg = null;
@@ -3149,7 +3155,7 @@
 			locMsg = localizeMessage(messageKey, langUtil, args);
 
 		//display on the console
-		consoleMessage(locMsg);
+		consoleMessage(locMsg, printTimeStamp);
 
 		//if it is a user error display usage
 		if (type == ERRTYPE_USER)

Modified: db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties?rev=674354&r1=674353&r2=674354&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties Sun Jul
 6 15:04:55 2008
@@ -22,14 +22,14 @@
 DRDA_UnexpectedException.S=Unexpected exception:\n {0}
 DRDA_ListenPort.S=Could not listen on port {0} on host {1}:\n {2}
 DRDA_NoInputStream.S=Could not get input stream for client socket.
-DRDA_Ready.I={1} Network Server - {2} started and ready to accept connections on port {0}
at {3} 
-DRDA_SSLReady.I={1} Network Server - {2} started and ready to accept SSL connections on port
{0} at {3} 
-DRDA_SSLClientAuthReady.I={1} Network Server - {2} started and ready to accept SSL connections
with client authentication on port {0} at {3} 
+DRDA_Ready.I={1} Network Server - {2} started and ready to accept connections on port {0}
+DRDA_SSLReady.I={1} Network Server - {2} started and ready to accept SSL connections on port
{0}
+DRDA_SSLClientAuthReady.I={1} Network Server - {2} started and ready to accept SSL connections
with client authentication on port {0} 
 DRDA_UnableToAccept.S=Unable to accept connections.
 DRDA_ConnNumber.I=Connection number: {0}.
 DRDA_ClientSocketError.S=Error on client socket:\n {0}
 DRDA_ListenerClose.S=Unable to close the listener thread.
-DRDA_ShutdownSuccess.I={0} Network Server - {1} shutdown at {2}
+DRDA_ShutdownSuccess.I={0} Network Server - {1} shutdown
 DRDA_ShutdownWarning.I=Derby shutdown warning:\n {0}
 DRDA_ShutdownError.S=Unable to shutdown server on port  {0} on host {1}.
 DRDA_BootSuccess.I=Booting database, {0}, successful.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/derbyrunjartest.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/derbyrunjartest.out?rev=674354&r1=674353&r2=674354&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/derbyrunjartest.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/derbyrunjartest.out
Sun Jul  6 15:04:55 2008
@@ -26,7 +26,7 @@
  	 will be written.
  		If not specified, default is the console. 
 server:
-No command given.
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT : No command given.
 Usage: NetworkServerControl <commands> 
 Commands:
 start [-h <host>] [-p <portnumber>] [-noSecurityManager] [-ssl <sslmode>]

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/maxthreads.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/maxthreads.out?rev=674354&r1=674353&r2=674354&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/maxthreads.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/maxthreads.out
Sun Jul  6 15:04:55 2008
@@ -1,12 +1,12 @@
 Testing maxthreads
 org.apache.derby.drda.NetworkServerControl maxthreads 0 
-Max threads changed to 0.
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT : Max threads changed to 0.
 PASS - max threads value, 0 is correct
 org.apache.derby.drda.NetworkServerControl maxthreads -1 -h xxxFILTERED_HOSTNAMExxx -p 1527

-Max threads changed to 0.
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT : Max threads changed to 0.
 PASS - max threads value, 0 is correct
 org.apache.derby.drda.NetworkServerControl maxthreads -12 
-Invalid value, -12, for maxthreads.
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT : Invalid value, -12, for maxthreads.
 Usage: NetworkServerControl <commands> 
 Commands:
 start [-h <host>] [-p <portnumber>] [-noSecurityManager] [-ssl <sslmode>]
@@ -21,13 +21,13 @@
 tracedirectory <traceDirectory>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
 PASS - max threads value, 0 is correct
 org.apache.derby.drda.NetworkServerControl maxthreads 2147483647 
-Max threads changed to 2147483647.
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT : Max threads changed to 2147483647.
 PASS - max threads value, 2147483647 is correct
 org.apache.derby.drda.NetworkServerControl maxthreads 9000 
-Max threads changed to 9000.
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT : Max threads changed to 9000.
 PASS - max threads value, 9000 is correct
 org.apache.derby.drda.NetworkServerControl maxthreads a 
-Invalid value, a, for maxthreads.
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT : Invalid value, a, for maxthreads.
 Usage: NetworkServerControl <commands> 
 Commands:
 start [-h <host>] [-p <portnumber>] [-noSecurityManager] [-ssl <sslmode>]

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/timeslice.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/timeslice.out?rev=674354&r1=674353&r2=674354&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/timeslice.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/timeslice.out
Sun Jul  6 15:04:55 2008
@@ -1,12 +1,12 @@
 Testing timeslice
 org.apache.derby.drda.NetworkServerControl timeslice 0 
-Time slice changed to 0.
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT : Time slice changed to 0.
 PASS - time slice value, 0 is correct
 org.apache.derby.drda.NetworkServerControl timeslice -1 -h xxxFILTERED_HOSTNAMExxx -p 1527

-Time slice changed to 0.
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT : Time slice changed to 0.
 PASS - time slice value, 0 is correct
 org.apache.derby.drda.NetworkServerControl timeslice -12 
-Invalid value, -12, for timeslice.
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT : Invalid value, -12, for timeslice.
 Usage: NetworkServerControl <commands> 
 Commands:
 start [-h <host>] [-p <portnumber>] [-noSecurityManager] [-ssl <sslmode>]
@@ -21,13 +21,13 @@
 tracedirectory <traceDirectory>[-h <host>][-p <portnumber>] [-ssl <sslmode>]
 PASS - time slice value, 0 is correct
 org.apache.derby.drda.NetworkServerControl timeslice 2147483647 
-Time slice changed to 2147483647.
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT : Time slice changed to 2147483647.
 PASS - time slice value, 2147483647 is correct
 org.apache.derby.drda.NetworkServerControl timeslice 9000 
-Time slice changed to 9000.
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT : Time slice changed to 9000.
 PASS - time slice value, 9000 is correct
 org.apache.derby.drda.NetworkServerControl timeslice a 
-Invalid value, a, for timeslice.
+xxxxxxFILTERED-TIMESTAMPxxxxxGMT : Invalid value, a, for timeslice.
 Usage: NetworkServerControl <commands> 
 Commands:
 start [-h <host>] [-p <portnumber>] [-noSecurityManager] [-ssl <sslmode>]



Mime
View raw message