1
0

Eliminate spurious second "-" character when showShortLogname=true.

PR:  Bugzilla #25940
Submitted by: Dennis Lundberg <dennis.lundberg at mdh.se>


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@139011 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Craig R. McClanahan
2004-02-28 23:00:57 +00:00
parent d96e2a0af2
commit 538ee2bd6d

View File

@@ -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.16 2004/02/28 21:46:45 craigmcc Exp $ * @version $Id: SimpleLog.java,v 1.17 2004/02/28 23:00:57 craigmcc Exp $
*/ */
public class SimpleLog implements Log, Serializable { public class SimpleLog implements Log, Serializable {
@@ -152,7 +152,6 @@ public class SimpleLog implements Log, Serializable {
showLogName = getBooleanProperty( systemPrefix + "showlogname", showLogName); showLogName = getBooleanProperty( systemPrefix + "showlogname", showLogName);
showShortName = getBooleanProperty( systemPrefix + "showShortLogname", showShortName); showShortName = getBooleanProperty( systemPrefix + "showShortLogname", showShortName);
showDateTime = getBooleanProperty( systemPrefix + "showdatetime", showDateTime); showDateTime = getBooleanProperty( systemPrefix + "showdatetime", showDateTime);
showLogName = getBooleanProperty( systemPrefix + "showlogname", showLogName);
if(showDateTime) { if(showDateTime) {
dateFormatter = new SimpleDateFormat( dateFormatter = new SimpleDateFormat(
@@ -168,8 +167,8 @@ public class SimpleLog implements Log, Serializable {
protected String logName = null; protected String logName = null;
/** The current log level */ /** The current log level */
protected int currentLogLevel; protected int currentLogLevel;
/** The short name of this simple log instance */
private String prefix=null; private String shortLogName = null;
// ------------------------------------------------------------ Constructor // ------------------------------------------------------------ Constructor
@@ -275,12 +274,13 @@ public class SimpleLog implements Log, Serializable {
// Append the name of the log instance if so configured // Append the name of the log instance if so configured
if( showShortName) { if( showShortName) {
if( prefix==null ) { if( shortLogName==null ) {
// cut all but the last component of the name for both styles // Cut all but the last component of the name for both styles
prefix = logName.substring( logName.lastIndexOf(".") +1) + " - "; shortLogName = logName.substring(logName.lastIndexOf(".") + 1);
prefix = prefix.substring( prefix.lastIndexOf("/") +1) + "-"; shortLogName =
shortLogName.substring(shortLogName.lastIndexOf("/") + 1);
} }
buf.append( prefix ); buf.append(String.valueOf(shortLogName)).append(" - ");
} else if(showLogName) { } else if(showLogName) {
buf.append(String.valueOf(logName)).append(" - "); buf.append(String.valueOf(logName)).append(" - ");
} }