1
0

svn:keywords correction

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@155426 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dirk Verbeeck
2005-02-26 13:10:49 +00:00
parent d746ff0810
commit b56a58e5de
29 changed files with 297 additions and 297 deletions

View File

@@ -57,7 +57,7 @@ package org.apache.commons.logging;
*
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
* @author Rod Waldhoff
* @version $Id: Log.java,v 1.19 2004/06/06 21:16:04 rdonkin Exp $
* @version $Id$
*/
public interface Log {

View File

@@ -23,7 +23,7 @@ package org.apache.commons.logging;
* factory methods.</p>
*
* @author Craig R. McClanahan
* @version $Revision: 1.6 $ $Date: 2004/02/28 21:46:45 $
* @version $Revision$ $Date$
*/
public class LogConfigurationException extends RuntimeException {

View File

@@ -42,7 +42,7 @@ import java.util.Properties;
* @author Craig R. McClanahan
* @author Costin Manolache
* @author Richard A. Sitze
* @version $Revision: 1.28 $ $Date$
* @version $Revision$ $Date$
*/
public abstract class LogFactory {

View File

@@ -52,7 +52,7 @@ import org.apache.commons.logging.impl.NoOpLog;
* implementation performs exactly the same algorithm as this class did
*
* @author Rod Waldhoff
* @version $Id: LogSource.java,v 1.21 2004/02/28 21:46:45 craigmcc Exp $
* @version $Id$
*/
public class LogSource {

View File

@@ -46,7 +46,7 @@ import org.apache.commons.logging.Log;
* However, serializable is not recommended.
* </p>
* @author <a href="mailto:neeme@apache.org">Neeme Praks</a>
* @version $Revision: 1.10 $ $Date$
* @version $Revision$ $Date$
*/
public class AvalonLogger implements Log, Serializable {

View File

@@ -12,272 +12,272 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.logging.impl;
import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.LogRecord;
import java.util.StringTokenizer;
import java.io.PrintWriter;
import java.io.StringWriter;
import org.apache.commons.logging.Log;
/**
* <p>Implementation of the <code>org.apache.commons.logging.Log</code>
* interface that wraps the standard JDK logging mechanisms that are
* available in SourceForge's Lumberjack for JDKs prior to 1.4.</p>
*
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
* @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
* @author <a href="mailto:vince256@comcast.net">Vince Eagen</a>
* @version $Revision: 1.6 $ $Date: 2004/06/06 21:13:43 $
*/
public class Jdk13LumberjackLogger implements Log, Serializable {
// ----------------------------------------------------- Instance Variables
/**
* The underlying Logger implementation we are using.
*/
protected transient Logger logger = null;
protected String name = null;
private String sourceClassName = "unknown";
private String sourceMethodName = "unknown";
private boolean classAndMethodFound = false;
// ----------------------------------------------------------- Constructors
/**
* Construct a named instance of this Logger.
*
* @param name Name of the logger to be constructed
*/
public Jdk13LumberjackLogger(String name) {
this.name = name;
logger = getLogger();
}
// --------------------------------------------------------- Public Methods
private void log( Level level, String msg, Throwable ex ) {
if( getLogger().isLoggable(level) ) {
LogRecord record = new LogRecord(level, msg);
if( !classAndMethodFound ) {
getClassAndMethod();
}
record.setSourceClassName(sourceClassName);
record.setSourceMethodName(sourceMethodName);
if( ex != null ) {
record.setThrown(ex);
}
getLogger().log(record);
}
}
/**
* <p>Gets the class and method by looking at the stack trace for the
* first entry that is not this class.</p>
*/
private void getClassAndMethod() {
try {
Throwable throwable = new Throwable();
throwable.fillInStackTrace();
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter( stringWriter );
throwable.printStackTrace( printWriter );
String traceString = stringWriter.getBuffer().toString();
StringTokenizer tokenizer =
new StringTokenizer( traceString, "\n" );
tokenizer.nextToken();
String line = tokenizer.nextToken();
while ( line.indexOf( this.getClass().getName() ) == -1 ) {
line = tokenizer.nextToken();
}
while ( line.indexOf( this.getClass().getName() ) >= 0 ) {
line = tokenizer.nextToken();
}
int start = line.indexOf( "at " ) + 3;
int end = line.indexOf( '(' );
String temp = line.substring( start, end );
int lastPeriod = temp.lastIndexOf( '.' );
sourceClassName = temp.substring( 0, lastPeriod );
sourceMethodName = temp.substring( lastPeriod + 1 );
} catch ( Exception ex ) {
// ignore - leave class and methodname unknown
}
classAndMethodFound = true;
}
/**
* Log a message with debug log level.
*/
public void debug(Object message) {
log(Level.FINE, String.valueOf(message), null);
}
/**
* Log a message and exception with debug log level.
*/
public void debug(Object message, Throwable exception) {
log(Level.FINE, String.valueOf(message), exception);
}
/**
* Log a message with error log level.
*/
public void error(Object message) {
log(Level.SEVERE, String.valueOf(message), null);
}
/**
* Log a message and exception with error log level.
*/
public void error(Object message, Throwable exception) {
log(Level.SEVERE, String.valueOf(message), exception);
}
/**
* Log a message with fatal log level.
*/
public void fatal(Object message) {
log(Level.SEVERE, String.valueOf(message), null);
}
/**
* Log a message and exception with fatal log level.
*/
public void fatal(Object message, Throwable exception) {
log(Level.SEVERE, String.valueOf(message), exception);
}
/**
* Return the native Logger instance we are using.
*/
public Logger getLogger() {
if (logger == null) {
logger = Logger.getLogger(name);
}
return (logger);
}
/**
* Log a message with info log level.
*/
public void info(Object message) {
log(Level.INFO, String.valueOf(message), null);
}
/**
* Log a message and exception with info log level.
*/
public void info(Object message, Throwable exception) {
log(Level.INFO, String.valueOf(message), exception);
}
/**
* Is debug logging currently enabled?
*/
public boolean isDebugEnabled() {
return (getLogger().isLoggable(Level.FINE));
}
/**
* Is error logging currently enabled?
*/
public boolean isErrorEnabled() {
return (getLogger().isLoggable(Level.SEVERE));
}
/**
* Is fatal logging currently enabled?
*/
public boolean isFatalEnabled() {
return (getLogger().isLoggable(Level.SEVERE));
}
/**
* Is info logging currently enabled?
*/
public boolean isInfoEnabled() {
return (getLogger().isLoggable(Level.INFO));
}
/**
* Is trace logging currently enabled?
*/
public boolean isTraceEnabled() {
return (getLogger().isLoggable(Level.FINEST));
}
/**
* Is warn logging currently enabled?
*/
public boolean isWarnEnabled() {
return (getLogger().isLoggable(Level.WARNING));
}
/**
* Log a message with trace log level.
*/
public void trace(Object message) {
log(Level.FINEST, String.valueOf(message), null);
}
/**
* Log a message and exception with trace log level.
*/
public void trace(Object message, Throwable exception) {
log(Level.FINEST, String.valueOf(message), exception);
}
/**
* Log a message with warn log level.
*/
public void warn(Object message) {
log(Level.WARNING, String.valueOf(message), null);
}
/**
* Log a message and exception with warn log level.
*/
public void warn(Object message, Throwable exception) {
log(Level.WARNING, String.valueOf(message), exception);
}
}
*/
package org.apache.commons.logging.impl;
import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.LogRecord;
import java.util.StringTokenizer;
import java.io.PrintWriter;
import java.io.StringWriter;
import org.apache.commons.logging.Log;
/**
* <p>Implementation of the <code>org.apache.commons.logging.Log</code>
* interface that wraps the standard JDK logging mechanisms that are
* available in SourceForge's Lumberjack for JDKs prior to 1.4.</p>
*
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
* @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
* @author <a href="mailto:vince256@comcast.net">Vince Eagen</a>
* @version $Revision$ $Date$
*/
public class Jdk13LumberjackLogger implements Log, Serializable {
// ----------------------------------------------------- Instance Variables
/**
* The underlying Logger implementation we are using.
*/
protected transient Logger logger = null;
protected String name = null;
private String sourceClassName = "unknown";
private String sourceMethodName = "unknown";
private boolean classAndMethodFound = false;
// ----------------------------------------------------------- Constructors
/**
* Construct a named instance of this Logger.
*
* @param name Name of the logger to be constructed
*/
public Jdk13LumberjackLogger(String name) {
this.name = name;
logger = getLogger();
}
// --------------------------------------------------------- Public Methods
private void log( Level level, String msg, Throwable ex ) {
if( getLogger().isLoggable(level) ) {
LogRecord record = new LogRecord(level, msg);
if( !classAndMethodFound ) {
getClassAndMethod();
}
record.setSourceClassName(sourceClassName);
record.setSourceMethodName(sourceMethodName);
if( ex != null ) {
record.setThrown(ex);
}
getLogger().log(record);
}
}
/**
* <p>Gets the class and method by looking at the stack trace for the
* first entry that is not this class.</p>
*/
private void getClassAndMethod() {
try {
Throwable throwable = new Throwable();
throwable.fillInStackTrace();
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter( stringWriter );
throwable.printStackTrace( printWriter );
String traceString = stringWriter.getBuffer().toString();
StringTokenizer tokenizer =
new StringTokenizer( traceString, "\n" );
tokenizer.nextToken();
String line = tokenizer.nextToken();
while ( line.indexOf( this.getClass().getName() ) == -1 ) {
line = tokenizer.nextToken();
}
while ( line.indexOf( this.getClass().getName() ) >= 0 ) {
line = tokenizer.nextToken();
}
int start = line.indexOf( "at " ) + 3;
int end = line.indexOf( '(' );
String temp = line.substring( start, end );
int lastPeriod = temp.lastIndexOf( '.' );
sourceClassName = temp.substring( 0, lastPeriod );
sourceMethodName = temp.substring( lastPeriod + 1 );
} catch ( Exception ex ) {
// ignore - leave class and methodname unknown
}
classAndMethodFound = true;
}
/**
* Log a message with debug log level.
*/
public void debug(Object message) {
log(Level.FINE, String.valueOf(message), null);
}
/**
* Log a message and exception with debug log level.
*/
public void debug(Object message, Throwable exception) {
log(Level.FINE, String.valueOf(message), exception);
}
/**
* Log a message with error log level.
*/
public void error(Object message) {
log(Level.SEVERE, String.valueOf(message), null);
}
/**
* Log a message and exception with error log level.
*/
public void error(Object message, Throwable exception) {
log(Level.SEVERE, String.valueOf(message), exception);
}
/**
* Log a message with fatal log level.
*/
public void fatal(Object message) {
log(Level.SEVERE, String.valueOf(message), null);
}
/**
* Log a message and exception with fatal log level.
*/
public void fatal(Object message, Throwable exception) {
log(Level.SEVERE, String.valueOf(message), exception);
}
/**
* Return the native Logger instance we are using.
*/
public Logger getLogger() {
if (logger == null) {
logger = Logger.getLogger(name);
}
return (logger);
}
/**
* Log a message with info log level.
*/
public void info(Object message) {
log(Level.INFO, String.valueOf(message), null);
}
/**
* Log a message and exception with info log level.
*/
public void info(Object message, Throwable exception) {
log(Level.INFO, String.valueOf(message), exception);
}
/**
* Is debug logging currently enabled?
*/
public boolean isDebugEnabled() {
return (getLogger().isLoggable(Level.FINE));
}
/**
* Is error logging currently enabled?
*/
public boolean isErrorEnabled() {
return (getLogger().isLoggable(Level.SEVERE));
}
/**
* Is fatal logging currently enabled?
*/
public boolean isFatalEnabled() {
return (getLogger().isLoggable(Level.SEVERE));
}
/**
* Is info logging currently enabled?
*/
public boolean isInfoEnabled() {
return (getLogger().isLoggable(Level.INFO));
}
/**
* Is trace logging currently enabled?
*/
public boolean isTraceEnabled() {
return (getLogger().isLoggable(Level.FINEST));
}
/**
* Is warn logging currently enabled?
*/
public boolean isWarnEnabled() {
return (getLogger().isLoggable(Level.WARNING));
}
/**
* Log a message with trace log level.
*/
public void trace(Object message) {
log(Level.FINEST, String.valueOf(message), null);
}
/**
* Log a message and exception with trace log level.
*/
public void trace(Object message, Throwable exception) {
log(Level.FINEST, String.valueOf(message), exception);
}
/**
* Log a message with warn log level.
*/
public void warn(Object message) {
log(Level.WARNING, String.valueOf(message), null);
}
/**
* Log a message and exception with warn log level.
*/
public void warn(Object message, Throwable exception) {
log(Level.WARNING, String.valueOf(message), exception);
}
}

View File

@@ -33,7 +33,7 @@ import org.apache.commons.logging.Log;
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
* @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
* @version $Revision: 1.13 $ $Date: 2004/06/06 21:10:21 $
* @version $Revision$ $Date$
*/
public class Jdk14Logger implements Log, Serializable {

View File

@@ -32,7 +32,7 @@ import org.apache.log4j.Level;
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
* @author Rod Waldhoff
* @author Robert Burrell Donkin
* @version $Id: Log4JLogger.java,v 1.11 2004/05/19 21:01:23 rdonkin Exp $
* @version $Id$
*/
public class Log4JLogger implements Log, Serializable {

View File

@@ -63,7 +63,7 @@ import org.apache.commons.logging.LogFactory;
* @author Rod Waldhoff
* @author Craig R. McClanahan
* @author Richard A. Sitze
* @version $Revision: 1.36 $ $Date: 2004/10/31 17:53:48 $
* @version $Revision$ $Date$
*/
public class LogFactoryImpl extends LogFactory {

View File

@@ -34,7 +34,7 @@ import org.apache.commons.logging.Log;
*
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
* @author Robert Burrell Donkin
* @version $Id: LogKitLogger.java,v 1.9 2004/06/01 19:56:46 rdonkin Exp $
* @version $Id$
*/
public class LogKitLogger implements Log, Serializable {

View File

@@ -28,7 +28,7 @@ import org.apache.commons.logging.Log;
*
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
* @author Rod Waldhoff
* @version $Id: NoOpLog.java,v 1.8 2004/06/06 21:13:12 rdonkin Exp $
* @version $Id$
*/
public class NoOpLog implements Log, Serializable {

View File

@@ -70,7 +70,7 @@ import org.apache.commons.logging.LogConfigurationException;
* @author Rod Waldhoff
* @author Robert Burrell Donkin
*
* @version $Id: SimpleLog.java,v 1.21 2004/06/06 20:47:56 rdonkin Exp $
* @version $Id$
*/
public class SimpleLog implements Log, Serializable {

View File

@@ -23,7 +23,7 @@ import junit.framework.*;
/**
*
* @author Sean C. Sullivan
* @version $Revision: $
* @version $Revision$
*
*/
public abstract class AbstractLogTest extends TestCase {

View File

@@ -22,7 +22,7 @@ import junit.framework.TestSuite;
/**
* testcase to emulate container and application isolated from container
* @author baliuka
* @version $Id: LoadTest.java,v 1.5 2004/02/28 21:46:45 craigmcc Exp $
* @version $Id$
*/
public class LoadTest extends TestCase{
//TODO: need some way to add service provider packages

View File

@@ -29,7 +29,7 @@ import junit.framework.*;
* coded by James Strachan. </p>
*
* @author Robert Burrell Donkin
* @version $Revision: 1.7 $
* @version $Revision$
*/
public class TestAll extends TestCase {

View File

@@ -65,7 +65,7 @@ import java.util.List;
* only the wrapper class itself.</p>
*
* @author Craig R. McClanahan
* @version $Revision: 1.5 $ $Date: 2004/02/28 21:46:45 $
* @version $Revision$ $Date$
*/
public class Wrapper {

View File

@@ -25,7 +25,7 @@ import junit.framework.TestSuite;
/**
* @author <a href="mailto:neeme@apache.org">Neeme Praks</a>
* @version $Revision: 1.4 $ $Date: 2004/02/28 21:46:45 $
* @version $Revision$ $Date$
*/
public class AvalonLoggerTest extends AbstractLogTest {

View File

@@ -35,7 +35,7 @@ import junit.framework.TestSuite;
* logger configured per the configuration properties.</p>
*
* @author Craig R. McClanahan
* @version $Revision: 1.9 $ $Date: 2004/02/28 21:46:45 $
* @version $Revision$ $Date$
*/
public class CustomConfigTestCase extends DefaultConfigTestCase {

View File

@@ -36,7 +36,7 @@ import org.apache.commons.logging.LogFactory;
* should be automatically configured.</p>
*
* @author Craig R. McClanahan
* @version $Revision: 1.8 $ $Date: 2004/02/28 21:46:45 $
* @version $Revision$ $Date$
*/
public class DefaultConfigTestCase extends TestCase {

View File

@@ -27,7 +27,7 @@ import java.util.logging.LogRecord;
* <p>Test implementation of <code>java.util.logging.Handler</code>.</p>
*
* @author Craig R. McClanahan
* @version $Revision: 1.4 $ $Date: 2004/02/28 21:46:45 $
* @version $Revision$ $Date$
*/
public class TestHandler extends Handler {

View File

@@ -37,7 +37,7 @@ import org.apache.log4j.spi.LoggingEvent;
* logger configured per the configuration properties.</p>
*
* @author Craig R. McClanahan
* @version $Revision: 1.9 $ $Date: 2004/05/19 20:59:56 $
* @version $Revision$ $Date$
*/
public class CustomConfigTestCase extends DefaultConfigTestCase {

View File

@@ -36,7 +36,7 @@ import org.apache.commons.logging.LogFactory;
* should be automatically configured).</p>
*
* @author Craig R. McClanahan
* @version $Revision: 1.7 $ $Date: 2004/02/28 21:46:46 $
* @version $Revision$ $Date$
*/
public class DefaultConfigTestCase extends TestCase {

View File

@@ -28,7 +28,7 @@ import org.apache.log4j.spi.LoggingEvent;
* <p>Test implementation of <code>org.apache.log4j.Appender</code>.</p>
*
* @author Craig R. McClanahan
* @version $Revision: 1.4 $ $Date: 2004/02/28 21:46:46 $
* @version $Revision$ $Date$
*/
public class TestAppender extends AppenderSkeleton {

View File

@@ -32,7 +32,7 @@ import org.apache.commons.logging.impl.SimpleLog;
* properties.</p>
*
* @author Craig R. McClanahan
* @version $Revision: 1.6 $ $Date: 2004/05/30 10:32:25 $
* @version $Revision$ $Date$
*/
public class CustomConfigTestCase extends DefaultConfigTestCase {

View File

@@ -36,7 +36,7 @@ import org.apache.commons.logging.impl.SimpleLog;
* other than selecting the SimpleLog implementation.</p>
*
* @author Craig R. McClanahan
* @version $Revision: 1.5 $ $Date: 2004/05/29 10:43:35 $
* @version $Revision$ $Date$
*/
public class DefaultConfigTestCase extends TestCase {