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,15 @@ 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 () );
194+ this (stream );
224195 traceLevel = argsParser .getTraceLevel ();
225196 }
226197
227198 /////////////////////////////////////////////////////////////////
228199
229- /**
230- * Return <i>true</i> if log mode is verbose.
231- */
232- public boolean verbose () {
233- return verbose ;
234- }
235-
236200 /**
237201 * Return <i>true</i> if printing errors summary at exit is enabled.
238202 */
@@ -313,9 +277,6 @@ public static String printExceptionToString(Object prefix, Throwable exception)
313277 @ Deprecated
314278 public synchronized void println (String message ) {
315279 doPrint (message );
316- if (!verbose () && isVerboseOnErrorEnabled ()) {
317- keepLog (composeLine (message ));
318- }
319280 }
320281
321282 /**
@@ -329,9 +290,6 @@ public synchronized void println(String message) {
329290 */
330291 @ Deprecated
331292 public synchronized void comment (String message ) {
332- if (!verbose ()) {
333- doPrint (message );
334- }
335293 }
336294
337295 /**
@@ -361,19 +319,10 @@ public void trace(int level, Object message, Throwable exception) {
361319 }
362320
363321 /**
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.
322+ * Print <code>message</code> to the assigned output stream.
368323 */
369324 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- }
325+ doPrint (message .toString ());
377326 }
378327
379328 /**
@@ -382,15 +331,6 @@ public synchronized void display(Object message) {
382331 * into <code>errorsBuffer</code>.
383332 */
384333 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- }
394334 String msgStr = message .toString ();
395335 printError (msgStr );
396336 if (isErrorsSummaryEnabled ()) {
@@ -458,10 +398,7 @@ private void logExceptionForFailureAnalysis(String msg) {
458398 /////////////////////////////////////////////////////////////////
459399
460400 /**
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.
401+ * Redirect log to the given <code>stream</code>.
465402 *
466403 * @deprecated This method is obsolete.
467404 */
@@ -480,20 +417,6 @@ public synchronized void clearLogBuffer() {
480417 logBuffer .clear ();
481418 }
482419
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-
497420 /**
498421 * Return <code>out</code> stream if defined or <code>Sytem.err<code> otherwise;
499422 * print a warning message when <code>System.err</code> is used first time.
@@ -518,18 +441,15 @@ private synchronized PrintStream findOutStream() {
518441 * Compose line to print possible prefixing it with timestamp.
519442 */
520443 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 ;
444+ long time = System .currentTimeMillis ();
445+ long ms = time % 1000 ;
446+ time /= 1000 ;
447+ long secs = time % 60 ;
448+ time /= 60 ;
449+ long mins = time % 60 ;
450+ time /= 60 ;
451+ long hours = time % 24 ;
452+ return "[" + hours + ":" + mins + ":" + secs + "." + ms + "] " + message ;
533453 }
534454
535455 /**
@@ -563,13 +483,6 @@ private synchronized void printError(String message) {
563483 }
564484 }
565485
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-
573486 /**
574487 * Keep the given error <code>message</code> into <code>errorsBuffer</code>.
575488 */
@@ -603,7 +516,7 @@ private synchronized void printErrorsSummary() {
603516 * Print errors summary if mode is verbose, flush and cancel output stream.
604517 */
605518 protected void finalize () {
606- if (verbose () && isErrorsSummaryEnabled ()) {
519+ if (isErrorsSummaryEnabled ()) {
607520 printErrorsSummary ();
608521 }
609522 if (out != null )
0 commit comments