mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Reworked JLAN Debug interface to be driven off log4j configuration like the rest of alfresco.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32473 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -21,16 +21,20 @@ package org.alfresco.filesys.debug;
|
|||||||
|
|
||||||
import org.springframework.extensions.config.ConfigElement;
|
import org.springframework.extensions.config.ConfigElement;
|
||||||
import org.alfresco.jlan.debug.Debug;
|
import org.alfresco.jlan.debug.Debug;
|
||||||
|
import org.alfresco.jlan.debug.DebugInterface;
|
||||||
import org.alfresco.jlan.debug.DebugInterfaceBase;
|
import org.alfresco.jlan.debug.DebugInterfaceBase;
|
||||||
|
import org.alfresco.jlan.server.config.ServerConfiguration;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alfresco File Server Debug Interface Class
|
* Alfresco File Server Debug Interface Class
|
||||||
*
|
*
|
||||||
|
* Adapts JLAN's debug information out to Alfresco's logging
|
||||||
|
*
|
||||||
* @author gkspencer
|
* @author gkspencer
|
||||||
*/
|
*/
|
||||||
public class FileServerDebugInterface extends DebugInterfaceBase {
|
public class FileServerDebugInterface implements DebugInterface {
|
||||||
|
|
||||||
// Logger to use for all file server debug output
|
// Logger to use for all file server debug output
|
||||||
|
|
||||||
@@ -38,6 +42,7 @@ public class FileServerDebugInterface extends DebugInterfaceBase {
|
|||||||
|
|
||||||
// temporary buffer for debugPrint
|
// temporary buffer for debugPrint
|
||||||
|
|
||||||
|
// MER TODO - Not thread safe - probably needs to be in a thread slot. Would be much better to fix DebugInterface.
|
||||||
private StringBuilder m_printBuf;
|
private StringBuilder m_printBuf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,18 +68,19 @@ public class FileServerDebugInterface extends DebugInterfaceBase {
|
|||||||
* @param str String
|
* @param str String
|
||||||
*/
|
*/
|
||||||
public void debugPrintln(String str, int level) {
|
public void debugPrintln(String str, int level) {
|
||||||
if ( level <= getLogLevel()) {
|
|
||||||
|
|
||||||
// Check if there is any buffered output
|
// Check if there is any buffered output
|
||||||
|
if ( level <= getLogLevel())
|
||||||
if ( m_printBuf.length() > 0) {
|
if ( m_printBuf.length() > 0) {
|
||||||
m_printBuf.append( str);
|
m_printBuf.append( str);
|
||||||
logOutput( m_printBuf.toString(), level);
|
logOutput( m_printBuf.toString(), level);
|
||||||
m_printBuf.setLength( 0);
|
m_printBuf.setLength( 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
logOutput( str, level);
|
logOutput( str, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,29 +93,25 @@ public class FileServerDebugInterface extends DebugInterfaceBase {
|
|||||||
|
|
||||||
// Check if the logging level is enabled
|
// Check if the logging level is enabled
|
||||||
|
|
||||||
if ( level <= getLogLevel()) {
|
switch ( level)
|
||||||
|
{
|
||||||
// Output the exception
|
|
||||||
|
|
||||||
switch ( level) {
|
|
||||||
case Debug.Debug:
|
case Debug.Debug:
|
||||||
logger.debug( ex, ex);
|
logger.debug( "Debug from JLAN", ex);
|
||||||
break;
|
break;
|
||||||
case Debug.Info:
|
case Debug.Info:
|
||||||
logger.info( ex, ex);
|
logger.info( "Info from JLAN", ex);
|
||||||
break;
|
break;
|
||||||
case Debug.Warn:
|
case Debug.Warn:
|
||||||
logger.warn( ex, ex);
|
logger.warn( "Warning from JLAN", ex);
|
||||||
break;
|
break;
|
||||||
case Debug.Fatal:
|
case Debug.Fatal:
|
||||||
logger.fatal( ex, ex);
|
logger.fatal("Fatal from JLAN", ex);
|
||||||
break;
|
break;
|
||||||
case Debug.Error:
|
case Debug.Error:
|
||||||
logger.error( ex, ex);
|
logger.error("Error from JLAN", ex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output to the logger at the appropriate log level
|
* Output to the logger at the appropriate log level
|
||||||
@@ -144,10 +146,16 @@ public class FileServerDebugInterface extends DebugInterfaceBase {
|
|||||||
* @exception Exception
|
* @exception Exception
|
||||||
*/
|
*/
|
||||||
public void initialize(ConfigElement params)
|
public void initialize(ConfigElement params)
|
||||||
throws Exception {
|
throws Exception
|
||||||
|
{
|
||||||
|
|
||||||
// Set the log level from the log4j Log object
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map logger level to JLAN debug level
|
||||||
|
*/
|
||||||
|
public int getLogLevel()
|
||||||
|
{
|
||||||
int logLevel = Debug.Error;
|
int logLevel = Debug.Error;
|
||||||
|
|
||||||
if ( logger.isDebugEnabled())
|
if ( logger.isDebugEnabled())
|
||||||
@@ -161,6 +169,55 @@ public class FileServerDebugInterface extends DebugInterfaceBase {
|
|||||||
else if ( logger.isFatalEnabled())
|
else if ( logger.isFatalEnabled())
|
||||||
logLevel = Debug.Fatal;
|
logLevel = Debug.Fatal;
|
||||||
|
|
||||||
setLogLevel(logLevel);
|
return logLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close()
|
||||||
|
{
|
||||||
|
// Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debugPrint(String str)
|
||||||
|
{
|
||||||
|
debugPrint(str, Debug.Debug);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debugPrintln(String str)
|
||||||
|
{
|
||||||
|
debugPrintln(str, Debug.Debug);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void debugPrintln(Exception ex, int level)
|
||||||
|
{
|
||||||
|
switch ( level)
|
||||||
|
{
|
||||||
|
case Debug.Debug:
|
||||||
|
logger.debug( "Debug from JLAN", ex);
|
||||||
|
break;
|
||||||
|
case Debug.Info:
|
||||||
|
logger.info( "Info from JLAN", ex);
|
||||||
|
break;
|
||||||
|
case Debug.Warn:
|
||||||
|
logger.warn( "Warning from JLAN", ex);
|
||||||
|
break;
|
||||||
|
case Debug.Fatal:
|
||||||
|
logger.fatal("Fatal from JLAN", ex);
|
||||||
|
break;
|
||||||
|
case Debug.Error:
|
||||||
|
logger.error("Error from JLAN", ex);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(ConfigElement params, ServerConfiguration config)
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user