Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an improvement to log-mediator #24

Merged
merged 3 commits into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,9 @@ public SynapseEnvironment createSynapseEnvironment() {
//we initialize xpath extensions here since synapse environment is available
initXpathExtensions();

((Axis2SynapseEnvironment) synapseEnvironment)
.setSynapseDebugMode(serverConfigurationInformation.isSynapseDebug());

return synapseEnvironment;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public class ServerConfigurationInformation {
private String ipAddress;
/* Deployment mode*/
private String deploymentMode;
/* Synapse Debug mode */
private boolean synapseDebug;

public ServerConfigurationInformation() {
initServerHostAndIP();
Expand Down Expand Up @@ -231,8 +233,17 @@ private void initServerHostAndIP() {
}
}

public boolean isSynapseDebug() {
return synapseDebug;
}

public void setSynapseDebug(boolean synapseDebug) {
this.synapseDebug = synapseDebug;
}

public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("[ Synapse Debug Mode: ").append(synapseDebug).append(" ]");
sb.append("[ Server Name : ").append(serverName).append(" ]");
sb.append("[ Synapse Home : ").append(synapseHome).append(" ]");
sb.append("[ Synapse XML : ").append(synapseXMLLocation).append(" ]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ public static ServerConfigurationInformation createServerConfigurationInformatio
information.setSynapseHome(args[2]);
information.setSynapseXMLLocation(args[3]);
information.setResolveRoot(args[4]);
information.setDeploymentMode(args[5]);
if (args[5].equalsIgnoreCase("synapseDebug")) {
information.setSynapseDebug(true);
} else {
information.setDeploymentMode(args[5]);
}
} else if (args.length == 7) {
information.setAxis2Xml(args[1]);
information.setSynapseHome(args[2]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,11 @@ public interface SynapseEnvironment {
*/
public Map<QName, SynapseXpathVariableResolver> getXpathVariableExtensions();

/**
* This is used to check if the server instance is started
* with synapseDebug mode flag
* @return true if the server is started with debug mode
*/
public boolean isSynapseDebugMode();

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public class Axis2SynapseEnvironment implements SynapseEnvironment {
Map<QName, SynapseXpathVariableResolver> xpathVariableExtensions =
new HashMap<QName, SynapseXpathVariableResolver>();

private boolean synapseDebugMode;

public Axis2SynapseEnvironment(SynapseConfiguration synCfg) {

int coreThreads = SynapseThreadPool.SYNAPSE_CORE_THREADS;
Expand Down Expand Up @@ -499,7 +501,10 @@ public void setXpathVariableExtensions(SynapseXpathVariableResolver variableExt)
}
}


@Override
public boolean isSynapseDebugMode() {
return this.synapseDebugMode;
}

private void handleException(String message, Throwable e) {
log.error(message, e);
Expand Down Expand Up @@ -545,4 +550,8 @@ private Mediator getProxyOutSequence(MessageContext synCtx, ProxyService proxySe
}
return null;
}

public void setSynapseDebugMode(boolean synapseDebugMode) {
this.synapseDebugMode = synapseDebugMode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public boolean mediate(MessageContext synCtx) {
break;
case CATEGORY_DEBUG :
synLog.auditDebug(getLogMessage(synCtx));
if (synCtx.getEnvironment().isSynapseDebugMode()) {
synLog.auditLog(getLogMessage(synCtx));
}
break;
case CATEGORY_WARN :
synLog.auditWarn(getLogMessage(synCtx));
Expand Down
8 changes: 7 additions & 1 deletion modules/distribution/src/main/bin/synapse.bat
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ if ""%1""=="""" goto doneStart
if ""%1""==""-sample"" goto SYNAPSESample
if ""%1""==""-serverName"" goto serverName
if ""%1""==""-xdebug"" goto xdebug
if ""%1""==""-synapseDebug"" goto synapseDebug
shift
goto setupArgs

Expand All @@ -57,6 +58,11 @@ set _SERVER_NAME=%1
shift
goto setupArgs

:synapseDebug
shift
set _SNYPASE_DEBUG="synapseDebug"
goto setupArgs

:doneStart
rem find SYNAPSE_HOME if it does not exist due to either an invalid value passed
rem by the user or the %0 problem on Windows 9x
Expand Down Expand Up @@ -111,7 +117,7 @@ rem
rem Start the Wrapper
rem
:startup
"%_WRAPPER_EXE%" -c %_WRAPPER_CONF% wrapper.app.parameter.5=%_SYNAPSE_XML% wrapper.app.parameter.8=%_SERVER_NAME% %_XDEBUG%
"%_WRAPPER_EXE%" -c %_WRAPPER_CONF% wrapper.app.parameter.5=%_SYNAPSE_XML% wrapper.app.parameter.8=%_SERVER_NAME% wrapper.app.parameter.9=%_SNYPASE_DEBUG% %_XDEBUG%

if not errorlevel 1 goto :eof
pause
Expand Down
8 changes: 7 additions & 1 deletion modules/distribution/src/main/bin/synapse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,17 @@ if [ "$1" = "-xdebug" ]; then
SERVER_NAME=$2
shift 2 # -serverName and actual name

elif [ "$1" = "-synapseDebug" ]; then
SYNAPSE_DEBUG="synapseDebug"
shift

elif [ "$1" = "-h" ]; then
echo "Usage: synapse.sh ( commands ... )"
echo "commands:"
echo " -xdebug Start Synapse under JPDA debugger"
echo " -sample (number) Start with sample Synapse configuration of given number"
echo " -serverName <name> Name of the Synapse server instance"
echo " -synapseDebug Start Synapse under debug mode"
shift
exit 0

Expand Down Expand Up @@ -185,4 +190,5 @@ $JAVA_HOME/bin/java -server -Xms512M -Xmx512M \
$SYNAPSE_HOME \
$SYNAPSE_XML \
$SYNAPSE_HOME/repository \
$SERVER_NAME
$SERVER_NAME \
$SYNAPSE_DEBUG