3636import java .util .HashSet ;
3737import java .util .Vector ;
3838
39- import nsk .share .test .LazyFormatString ;
4039
4140/**
42- * This class helps to print test-execution trace messages
43- * and filter them when execution mode is not verbose.
44- * <p>
45- * Verbose mode if defined by providing <i>-verbose</i> command line
46- * option, handled by <code>ArgumentParser</code>. Use <code>verbose()</code>
47- * method to determine which mode is used.
41+ * This class helps to print test-execution trace messages.
4842 * <p>
4943 * <code>Log</code> provides with two main methods to print messages:
5044 * <ul>
6357 * To provide printing messages from different sources into one log
6458 * with distinct prefixes use internal <code>Log.Logger</code> class.
6559 *
66- * @see #verbose()
6760 * @see #complain(String)
6861 * @see #display(String)
6962 * @see ArgumentParser
@@ -78,18 +71,6 @@ public class Log extends FinalizableObject {
7871 @ Deprecated
7972 protected PrintStream out = null ;
8073
81- /**
82- * Is log-mode verbose?
83- * Always enabled.
84- */
85- private final boolean verbose = true ;
86-
87- /**
88- * Should log messages prefixed with timestamps?
89- * Always enabled.
90- */
91- private final boolean timestamp = true ;
92-
9374 /**
9475 * Names for trace levels
9576 */
@@ -207,32 +188,14 @@ public Log(PrintStream stream) {
207188
208189 /**
209190 * Incarnate new Log for the given <code>stream</code>; and
210- * either for verbose or for non-verbose mode accordingly to
211- * the given <code>verbose</code> key.
212- */
213- public Log (PrintStream stream , boolean verbose ) {
214- this (stream );
215- }
216-
217- /**
218- * Incarnate new Log for the given <code>stream</code>; and
219- * either for verbose or for non-verbose mode accordingly to
220191 * the given <code>argsHandler</code>.
221192 */
222193 public Log (PrintStream stream , ArgumentParser argsParser ) {
223- this (stream , argsParser .verbose ());
224194 traceLevel = argsParser .getTraceLevel ();
225195 }
226196
227197 /////////////////////////////////////////////////////////////////
228198
229- /**
230- * Return <i>true</i> if log mode is verbose.
231- */
232- public boolean verbose () {
233- return verbose ;
234- }
235-
236199 /**
237200 * Return <i>true</i> if printing errors summary at exit is enabled.
238201 */
@@ -313,9 +276,6 @@ public static String printExceptionToString(Object prefix, Throwable exception)
313276 @ Deprecated
314277 public synchronized void println (String message ) {
315278 doPrint (message );
316- if (!verbose () && isVerboseOnErrorEnabled ()) {
317- keepLog (composeLine (message ));
318- }
319279 }
320280
321281 /**
@@ -329,9 +289,6 @@ public synchronized void println(String message) {
329289 */
330290 @ Deprecated
331291 public synchronized void comment (String message ) {
332- if (!verbose ()) {
333- doPrint (message );
334- }
335292 }
336293
337294 /**
@@ -361,19 +318,10 @@ public void trace(int level, Object message, Throwable exception) {
361318 }
362319
363320 /**
364- * Print <code>message</code> to the assigned output stream,
365- * if log mode is verbose. The <code>message</code> will be lost,
366- * if execution mode is non-verbose, and there is no error messages
367- * printed.
321+ * Print <code>message</code> to the assigned output stream.
368322 */
369323 public synchronized void display (Object message ) {
370- if (verbose ()) {
371- doPrint (message .toString ());
372- } else if (isVerboseOnErrorEnabled ()) {
373- keepLog (composeLine (message .toString ()));
374- } else {
375- // ignore
376- }
324+ doPrint (message .toString ());
377325 }
378326
379327 /**
@@ -382,15 +330,6 @@ public synchronized void display(Object message) {
382330 * into <code>errorsBuffer</code>.
383331 */
384332 public synchronized void complain (Object message ) {
385- if (!verbose () && isVerboseOnErrorEnabled ()) {
386- PrintStream stream = findOutStream ();
387- stream .println ("#> " );
388- stream .println ("#> WARNING: switching log to verbose mode," );
389- stream .println ("#> because error is complained" );
390- stream .println ("#> " );
391- stream .flush ();
392- enableVerbose (true );
393- }
394333 String msgStr = message .toString ();
395334 printError (msgStr );
396335 if (isErrorsSummaryEnabled ()) {
@@ -458,10 +397,7 @@ private void logExceptionForFailureAnalysis(String msg) {
458397 /////////////////////////////////////////////////////////////////
459398
460399 /**
461- * Redirect log to the given <code>stream</code>, and switch
462- * log mode to verbose.
463- * Prints errors summary to current stream, cancel current stream
464- * and switches to new stream. Turns on verbose mode for new stream.
400+ * Redirect log to the given <code>stream</code>.
465401 *
466402 * @deprecated This method is obsolete.
467403 */
@@ -480,20 +416,6 @@ public synchronized void clearLogBuffer() {
480416 logBuffer .clear ();
481417 }
482418
483- /**
484- * Print all messages from log buffer which were hidden because
485- * of non-verbose mode,
486- */
487- private synchronized void flushLogBuffer () {
488- if (!logBuffer .isEmpty ()) {
489- PrintStream stream = findOutStream ();
490- for (int i = 0 ; i < logBuffer .size (); i ++) {
491- stream .println (logBuffer .elementAt (i ));
492- }
493- stream .flush ();
494- }
495- }
496-
497419 /**
498420 * Return <code>out</code> stream if defined or <code>Sytem.err<code> otherwise;
499421 * print a warning message when <code>System.err</code> is used first time.
@@ -518,18 +440,15 @@ private synchronized PrintStream findOutStream() {
518440 * Compose line to print possible prefixing it with timestamp.
519441 */
520442 private String composeLine (String message ) {
521- if (timestamp ) {
522- long time = System .currentTimeMillis ();
523- long ms = time % 1000 ;
524- time /= 1000 ;
525- long secs = time % 60 ;
526- time /= 60 ;
527- long mins = time % 60 ;
528- time /= 60 ;
529- long hours = time % 24 ;
530- return "[" + hours + ":" + mins + ":" + secs + "." + ms + "] " + message ;
531- }
532- return message ;
443+ long time = System .currentTimeMillis ();
444+ long ms = time % 1000 ;
445+ time /= 1000 ;
446+ long secs = time % 60 ;
447+ time /= 60 ;
448+ long mins = time % 60 ;
449+ time /= 60 ;
450+ long hours = time % 24 ;
451+ return "[" + hours + ":" + mins + ":" + secs + "." + ms + "] " + message ;
533452 }
534453
535454 /**
@@ -563,13 +482,6 @@ private synchronized void printError(String message) {
563482 }
564483 }
565484
566- /**
567- * Keep the given log <code>message</code> into <code>logBuffer</code>.
568- */
569- private synchronized void keepLog (String message ) {
570- logBuffer .addElement (message );
571- }
572-
573485 /**
574486 * Keep the given error <code>message</code> into <code>errorsBuffer</code>.
575487 */
@@ -603,7 +515,7 @@ private synchronized void printErrorsSummary() {
603515 * Print errors summary if mode is verbose, flush and cancel output stream.
604516 */
605517 protected void finalize () {
606- if (verbose () && isErrorsSummaryEnabled ()) {
518+ if (isErrorsSummaryEnabled ()) {
607519 printErrorsSummary ();
608520 }
609521 if (out != null )
0 commit comments