Factor the actual writing out of log() into a new write() method so that
subclasses can easily specialize this function, without having to specialize the creation of the message to be written. PR: Bugzilla #27135 Submitted by: Aaron Hamid <arh14 at cornell.edu> git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@139016 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -64,7 +64,7 @@ import org.apache.commons.logging.LogConfigurationException;
|
|||||||
* @author Rod Waldhoff
|
* @author Rod Waldhoff
|
||||||
* @author Robert Burrell Donkin
|
* @author Robert Burrell Donkin
|
||||||
*
|
*
|
||||||
* @version $Id: SimpleLog.java,v 1.17 2004/02/28 23:00:57 craigmcc Exp $
|
* @version $Id: SimpleLog.java,v 1.18 2004/03/01 02:12:48 craigmcc Exp $
|
||||||
*/
|
*/
|
||||||
public class SimpleLog implements Log, Serializable {
|
public class SimpleLog implements Log, Serializable {
|
||||||
|
|
||||||
@@ -250,7 +250,11 @@ public class SimpleLog implements Log, Serializable {
|
|||||||
/**
|
/**
|
||||||
* <p> Do the actual logging.
|
* <p> Do the actual logging.
|
||||||
* This method assembles the message
|
* This method assembles the message
|
||||||
* and then prints to <code>System.err</code>.</p>
|
* and then calls <code>write()</code> to cause it to be written.</p>
|
||||||
|
*
|
||||||
|
* @param type One of the LOG_LEVE_XXX constants defining the log level
|
||||||
|
* @param message The message itself (typically a String)
|
||||||
|
* @param t The exception whose stack trace should be logged
|
||||||
*/
|
*/
|
||||||
protected void log(int type, Object message, Throwable t) {
|
protected void log(int type, Object message, Throwable t) {
|
||||||
// Use a string buffer for better performance
|
// Use a string buffer for better performance
|
||||||
@@ -301,8 +305,24 @@ public class SimpleLog implements Log, Serializable {
|
|||||||
buf.append(sw.toString());
|
buf.append(sw.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print to System.err
|
// Print to the appropriate destination
|
||||||
System.err.println(buf.toString());
|
write(buf);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Write the content of the message accumulated in the specified
|
||||||
|
* <code>StringBuffer</code> to the appropriate output destination. The
|
||||||
|
* default implementation writes to <code>System.err</code>.</p>
|
||||||
|
*
|
||||||
|
* @param buffer A <code>StringBuffer</code> containing the accumulated
|
||||||
|
* text to be logged
|
||||||
|
*/
|
||||||
|
protected void write(StringBuffer buffer) {
|
||||||
|
|
||||||
|
System.err.println(buffer.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user