From de4dccabe4a4cbe694f113ec351bf343d51f6866 Mon Sep 17 00:00:00 2001 From: shaper Date: Wed, 16 Oct 2002 19:30:15 +0000 Subject: [PATCH] Removed log message caching from the default log provider in the interest of KISS. Someday the default log provider will surely be able to read e-mail, otherwise it will be replaced by someone else's log provider that can. git-svn-id: https://samskivert.googlecode.com/svn/trunk@871 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../samskivert/util/DefaultLogProvider.java | 88 +------------------ 1 file changed, 1 insertion(+), 87 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/DefaultLogProvider.java b/projects/samskivert/src/java/com/samskivert/util/DefaultLogProvider.java index 1342092a..16167381 100644 --- a/projects/samskivert/src/java/com/samskivert/util/DefaultLogProvider.java +++ b/projects/samskivert/src/java/com/samskivert/util/DefaultLogProvider.java @@ -1,5 +1,5 @@ // -// $Id: DefaultLogProvider.java,v 1.16 2002/10/16 19:10:13 shaper Exp $ +// $Id: DefaultLogProvider.java,v 1.17 2002/10/16 19:30:15 shaper Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -22,8 +22,6 @@ package com.samskivert.util; import java.awt.Dimension; -import java.io.PrintStream; - import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -31,8 +29,6 @@ import java.util.Date; import java.util.Hashtable; import java.util.List; -import com.samskivert.io.ExtensiblePrintStream; - /** * If no log provider is registered with the log services, the default * provider will be used. The default provider simply logs messages to @@ -63,45 +59,6 @@ public class DefaultLogProvider implements LogProvider } } - /** - * Sets whether recent log messages should be cached and made - * available via {@link #getRecentMessages}. The default setting is - * false. Note that currently all messages logged after - * caching is turned on will be kept forever (or until caching is - * turned off.) - */ - public synchronized void setCacheMessages (boolean cache) - { - if (cache && _recent == null) { - // create the list of recent messages - _recent = new ArrayList(); - - // swap in our own custom output streams for stdout and stderr - // in order to cache all future output - _oout = System.out; - _oerr = System.err; - System.setOut(new CachingPrintStream(_oout)); - System.setErr(new CachingPrintStream(_oerr)); - - } else if (!cache && _recent != null) { - // clear out the recent message list - _recent = null; - - // restore the original output streams - System.setOut(_oout); - System.setErr(_oerr); - } - } - - /** - * Returns a list of the recent log messages, or null if - * log messages are not currently being cached. - */ - public synchronized List getRecentMessages () - { - return _recent; - } - public synchronized void log ( int level, String moduleName, String message) { @@ -216,40 +173,6 @@ public class DefaultLogProvider implements LogProvider } } - /** - * A print stream that caches all printed text in the {@link #_recent} - * list. - */ - protected class CachingPrintStream extends ExtensiblePrintStream - { - /** - * Constructs a caching print stream that caches all output - * written to the supplied stream. - */ - public CachingPrintStream (PrintStream s) - { - super(s, true); - } - - // documentation inherited - public void handlePrinted (String s) - { - _buf.append(s); - } - - // documentation inherited - public void handleNewLine () - { - // save off the text - _recent.add(_buf.toString()); - // clear out the line buffer - _buf = new StringBuffer(); - } - - /** The working string that gathers each log message line. */ - protected StringBuffer _buf = new StringBuffer(); - } - /** Whether or not to use the vt100 escape codes. */ protected boolean _useVT100 = false; @@ -263,15 +186,6 @@ public class DefaultLogProvider implements LogProvider protected SimpleDateFormat _format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss:SSS"); - /** The cached recent log messages that are made available to any - * external entities that would like access to them if we're actually - * caching messages. */ - protected ArrayList _recent; - - /** The original output streams that we save off if we're caching - * recent log messages. */ - protected PrintStream _oout, _oerr; - /** Contains the dimensions of the terminal window in which we're * running, if it was possible to obtain them. Otherwise, it contains * the default dimensions. This is used to wrap lines. */