-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8334305: Remove all code for nsk.share.Log verbose mode #21267
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,22 +29,15 @@ | |
import java.io.PrintStream; | ||
import java.io.PrintWriter; | ||
import java.io.StringReader; | ||
import java.util.Enumeration; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.HashSet; | ||
import java.util.Vector; | ||
|
||
import nsk.share.test.LazyFormatString; | ||
|
||
/** | ||
* This class helps to print test-execution trace messages | ||
* and filter them when execution mode is not verbose. | ||
* <p> | ||
* Verbose mode if defined by providing <i>-verbose</i> command line | ||
* option, handled by <code>ArgumentParser</code>. Use <code>verbose()</code> | ||
* method to determine which mode is used. | ||
* <p> | ||
* <code>Log</code> provides with two main methods to print messages: | ||
* <ul> | ||
|
@@ -60,7 +53,6 @@ | |
* To provide printing messages from different sources into one log | ||
* with distinct prefixes use internal <code>Log.Logger</code> class. | ||
* | ||
* @see #verbose() | ||
* @see #complain(String) | ||
* @see #display(String) | ||
* @see ArgumentParser | ||
|
@@ -72,18 +64,6 @@ public class Log { | |
*/ | ||
private PrintStream out = null; | ||
|
||
/** | ||
* Is log-mode verbose? | ||
* Always enabled. | ||
*/ | ||
private final boolean verbose = true; | ||
|
||
/** | ||
* Should log messages prefixed with timestamps? | ||
* Always enabled. | ||
*/ | ||
private final boolean timestamp = true; | ||
|
||
/** | ||
* Names for trace levels | ||
*/ | ||
|
@@ -188,41 +168,14 @@ public Log(PrintStream stream) { | |
|
||
/** | ||
* Incarnate new Log for the given <code>stream</code>; and | ||
* either for verbose or for non-verbose mode accordingly to | ||
* the given <code>verbose</code> key. | ||
*/ | ||
public Log(PrintStream stream, boolean verbose) { | ||
this(stream); | ||
} | ||
|
||
/** | ||
* Incarnate new Log for the given <code>stream</code>; and | ||
* either for verbose or for non-verbose mode accordingly to | ||
* the given <code>argsHandler</code>. | ||
*/ | ||
public Log(PrintStream stream, ArgumentParser argsParser) { | ||
this(stream, argsParser.verbose()); | ||
traceLevel = argsParser.getTraceLevel(); | ||
} | ||
|
||
///////////////////////////////////////////////////////////////// | ||
|
||
/** | ||
* Return <i>true</i> if log mode is verbose. | ||
*/ | ||
public boolean verbose() { | ||
return verbose; | ||
} | ||
|
||
/** | ||
* Enable or disable verbose mode for printing messages. | ||
*/ | ||
public void enableVerbose(boolean enable) { | ||
if (!enable) { | ||
throw new RuntimeException("The non-verbose logging is not supported."); | ||
} | ||
} | ||
|
||
public int getTraceLevel() { | ||
return traceLevel; | ||
} | ||
|
@@ -266,9 +219,6 @@ public static String printExceptionToString(Object prefix, Throwable exception) | |
@Deprecated | ||
public synchronized void println(String message) { | ||
doPrint(message); | ||
if (!verbose()) { | ||
keepLog(composeLine(message)); | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -282,9 +232,6 @@ public synchronized void println(String message) { | |
*/ | ||
@Deprecated | ||
public synchronized void comment(String message) { | ||
if (!verbose()) { | ||
doPrint(message); | ||
} | ||
Comment on lines
-285
to
-287
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this method ever called? Is there a CR to remove it (and any references to it)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are deprecated methods and are still getting called. The calls need to be replaced with display. I will create a separate CR for this and address because the impact radius of such a change is bigger than this CR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
} | ||
|
||
/** | ||
|
@@ -315,16 +262,9 @@ public void trace(int level, Object message, Throwable exception) { | |
|
||
/** | ||
* Print <code>message</code> to the assigned output stream, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need replace the comma with a period. |
||
* if log mode is verbose. The <code>message</code> will be lost, | ||
* if execution mode is non-verbose, and there is no error messages | ||
* printed. | ||
*/ | ||
public synchronized void display(Object message) { | ||
if (verbose()) { | ||
doPrint(message.toString()); | ||
} else { | ||
keepLog(composeLine(message.toString())); | ||
} | ||
doPrint(message.toString()); | ||
} | ||
|
||
/** | ||
|
@@ -333,15 +273,6 @@ public synchronized void display(Object message) { | |
* into <code>errorsBuffer</code>. | ||
*/ | ||
public synchronized void complain(Object message) { | ||
if (!verbose()) { | ||
PrintStream stream = findOutStream(); | ||
stream.println("#> "); | ||
stream.println("#> WARNING: switching log to verbose mode,"); | ||
stream.println("#> because error is complained"); | ||
stream.println("#> "); | ||
stream.flush(); | ||
enableVerbose(true); | ||
} | ||
String msgStr = message.toString(); | ||
printError(msgStr); | ||
|
||
|
@@ -406,10 +337,9 @@ private void logExceptionForFailureAnalysis(String msg) { | |
///////////////////////////////////////////////////////////////// | ||
|
||
/** | ||
* Redirect log to the given <code>stream</code>, and switch | ||
* log mode to verbose. | ||
* Redirect log to the given <code>stream</code> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need period at end of sentence. |
||
* Prints errors summary to current stream, cancel current stream | ||
* and switches to new stream. Turns on verbose mode for new stream. | ||
* and switches to new stream. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it really do all this? It looks to me like it just switches to the new stream. I'm not sure what is meant by "error summary" and cancelling. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. marked for deprecation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, but unless it is going to be removed by another CR soon, I think the comments should at least reflect what it currently does. |
||
* | ||
* @deprecated This method is obsolete. | ||
*/ | ||
|
@@ -430,20 +360,6 @@ public synchronized void clearLogBuffer() { | |
logBuffer.clear(); | ||
} | ||
|
||
/** | ||
* Print all messages from log buffer which were hidden because | ||
* of non-verbose mode, | ||
*/ | ||
private synchronized void flushLogBuffer() { | ||
if (!logBuffer.isEmpty()) { | ||
PrintStream stream = findOutStream(); | ||
for (int i = 0; i < logBuffer.size(); i++) { | ||
stream.println(logBuffer.elementAt(i)); | ||
} | ||
stream.flush(); | ||
} | ||
} | ||
|
||
/** | ||
* Return <code>out</code> stream if defined or <code>Sytem.err<code> otherwise; | ||
* print a warning message when <code>System.err</code> is used first time. | ||
|
@@ -468,18 +384,15 @@ private synchronized PrintStream findOutStream() { | |
* Compose line to print possible prefixing it with timestamp. | ||
*/ | ||
private String composeLine(String message) { | ||
if (timestamp) { | ||
long time = System.currentTimeMillis(); | ||
long ms = time % 1000; | ||
time /= 1000; | ||
long secs = time % 60; | ||
time /= 60; | ||
long mins = time % 60; | ||
time /= 60; | ||
long hours = time % 24; | ||
return "[" + hours + ":" + mins + ":" + secs + "." + ms + "] " + message; | ||
} | ||
return message; | ||
long time = System.currentTimeMillis(); | ||
long ms = time % 1000; | ||
time /= 1000; | ||
long secs = time % 60; | ||
time /= 60; | ||
long mins = time % 60; | ||
time /= 60; | ||
long hours = time % 24; | ||
return "[" + hours + ":" + mins + ":" + secs + "." + ms + "] " + message; | ||
} | ||
|
||
/** | ||
|
@@ -513,13 +426,6 @@ private synchronized void printError(String message) { | |
} | ||
} | ||
|
||
/** | ||
* Keep the given log <code>message</code> into <code>logBuffer</code>. | ||
*/ | ||
private synchronized void keepLog(String message) { | ||
logBuffer.addElement(message); | ||
} | ||
|
||
/** | ||
* This class can be used as a base for each class that use <code>Log</code> | ||
* for print messages and errors. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing period.