mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Added log level mapping to the DebugInterface implementation used by the JLAN code.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14597 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -7,7 +7,8 @@ package org.alfresco.filesys.debug;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import org.alfresco.config.ConfigElement;
|
import org.alfresco.config.ConfigElement;
|
||||||
import org.alfresco.jlan.debug.DebugInterface;
|
import org.alfresco.jlan.debug.Debug;
|
||||||
|
import org.alfresco.jlan.debug.DebugInterfaceBase;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
@@ -16,7 +17,7 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
*
|
*
|
||||||
* @author gkspencer
|
* @author gkspencer
|
||||||
*/
|
*/
|
||||||
public class FileServerDebugInterface implements DebugInterface {
|
public class FileServerDebugInterface extends DebugInterfaceBase {
|
||||||
|
|
||||||
// Logger to use for all file server debug output
|
// Logger to use for all file server debug output
|
||||||
|
|
||||||
@@ -33,39 +34,59 @@ public class FileServerDebugInterface implements DebugInterface {
|
|||||||
m_printBuf = new StringBuilder(120);
|
m_printBuf = new StringBuilder(120);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Close the debug output.
|
|
||||||
*/
|
|
||||||
public void close() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output a debug string.
|
* Output a debug string.
|
||||||
*
|
*
|
||||||
* @param str java.lang.String
|
* @param str String
|
||||||
*/
|
*/
|
||||||
public void debugPrint(String str) {
|
public void debugPrint(String str, int level) {
|
||||||
if ( logger.isDebugEnabled())
|
if ( level <= getLogLevel())
|
||||||
m_printBuf.append( str);
|
m_printBuf.append( str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output a debug string, and a newline.
|
* Output a debug string, and a newline.
|
||||||
*
|
*
|
||||||
* @param str java.lang.String
|
* @param str String
|
||||||
*/
|
*/
|
||||||
public void debugPrintln(String str) {
|
public void debugPrintln(String str, int level) {
|
||||||
if ( logger.isDebugEnabled()) {
|
if ( level <= getLogLevel()) {
|
||||||
|
|
||||||
// Check if there is any buffered output
|
// Check if there is any buffered output
|
||||||
|
|
||||||
if ( m_printBuf.length() > 0) {
|
if ( m_printBuf.length() > 0) {
|
||||||
m_printBuf.append( str);
|
m_printBuf.append( str);
|
||||||
logger.debug( m_printBuf.toString());
|
logOutput( m_printBuf.toString(), level);
|
||||||
m_printBuf.setLength( 0);
|
m_printBuf.setLength( 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
logOutput( str, level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output to the logger at the appropriate log level
|
||||||
|
*
|
||||||
|
* @param str String
|
||||||
|
* @param level int
|
||||||
|
*/
|
||||||
|
protected void logOutput(String str, int level) {
|
||||||
|
switch ( level) {
|
||||||
|
case Debug.Debug:
|
||||||
logger.debug( str);
|
logger.debug( str);
|
||||||
|
break;
|
||||||
|
case Debug.Info:
|
||||||
|
logger.info( str);
|
||||||
|
break;
|
||||||
|
case Debug.Warn:
|
||||||
|
logger.warn( str);
|
||||||
|
break;
|
||||||
|
case Debug.Fatal:
|
||||||
|
logger.fatal( str);
|
||||||
|
break;
|
||||||
|
case Debug.Error:
|
||||||
|
logger.error( str);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,6 +99,21 @@ public class FileServerDebugInterface implements DebugInterface {
|
|||||||
public void initialize(ConfigElement params)
|
public void initialize(ConfigElement params)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
// Nothing to do
|
// Set the log level from the log4j Log object
|
||||||
|
|
||||||
|
int logLevel = Debug.Error;
|
||||||
|
|
||||||
|
if ( logger.isDebugEnabled())
|
||||||
|
logLevel = Debug.Debug;
|
||||||
|
else if ( logger.isInfoEnabled())
|
||||||
|
logLevel = Debug.Info;
|
||||||
|
else if ( logger.isWarnEnabled())
|
||||||
|
logLevel = Debug.Warn;
|
||||||
|
else if ( logger.isErrorEnabled())
|
||||||
|
logLevel = Debug.Error;
|
||||||
|
else if ( logger.isFatalEnabled())
|
||||||
|
logLevel = Debug.Fatal;
|
||||||
|
|
||||||
|
setLogLevel(logLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user