com.yahoo.marketing.apt.client
Class LogHelper

java.lang.Object
  extended by com.yahoo.marketing.apt.client.LogHelper

public class LogHelper
extends java.lang.Object

The wrapper class of the Log class in Apache's common logging library to log the soap request and response messages.

Since:
0.5
Version:
3.0.0

Field Summary
private  boolean enableLogging
          Whether to enable logging.
private  org.apache.commons.logging.Log logger
          The Log object.
private  boolean logSOAPMessages
          Whether to log soap messages.
 
Constructor Summary
LogHelper()
          Default constructor.
LogHelper(org.apache.commons.logging.Log log)
          Constructor to instantiate LogHelper with the given Log object.
LogHelper(java.util.Properties logConfig)
          Constructor to instantiate LogHelper by reading log configuration options from logConfig.
LogHelper(java.lang.String configFilename)
          Constructor to instantiate LogHelper by reading log configuration options from property file configFilename.
 
Method Summary
 void debug(java.lang.String message)
          Log message as debug message, if enableLogging is true.
 void debug(org.apache.axis.client.Stub serviceStub)
          Log the soap request and response message as debug message, if both logSOAPMessages and enableLogging are true.
 void debug(org.apache.axis.client.Stub serviceStub, java.lang.String message)
          Log the soap request and response message together with message as debug message, if both logSOAPMessages and enableLogging are true.
 void error(java.lang.String message)
          Log message as error message, if enableLogging is true.
 void error(org.apache.axis.client.Stub serviceStub)
          Log the soap request and response message as error message, if both logSOAPMessages and enableLogging are true.
 void error(org.apache.axis.client.Stub serviceStub, java.lang.String message)
          Log the soap request and response message together with message as error message, if both logSOAPMessages and enableLogging are true.
 void fatal(java.lang.String message)
          Log message as fatal message, if enableLogging is true.
 void fatal(org.apache.axis.client.Stub serviceStub)
          Log the soap request and response message as fatal message, if both logSOAPMessages and enableLogging are true.
 void fatal(org.apache.axis.client.Stub serviceStub, java.lang.String message)
          Log the soap request and response message together with message as fatal message, if both logSOAPMessages and enableLogging are true.
 org.apache.commons.logging.Log getLogger()
          Return the current Log object
 java.lang.String getMessageAsString(org.apache.axis.Message message)
          Return soap request or response as String from the message.
 void info(java.lang.String message)
          Log message as info message, if enableLogging is true.
 void info(org.apache.axis.client.Stub serviceStub)
          Log the soap request and response message as info message, if both logSOAPMessages and enableLogging are true.
 void info(org.apache.axis.client.Stub serviceStub, java.lang.String message)
          Log the soap request and response message together with message as info message, if both logSOAPMessages and enableLogging are true.
 boolean isEnableLogging()
          Return the current value of enableLogging.
 boolean isLogSOAPMessages()
          Return the current value of logSOAPMessages.
 void log(java.lang.String message, java.lang.String methodName)
          Log the message as type of methodName if enableLogging is true.
 void log(org.apache.axis.client.Stub serviceStub, java.lang.String message, java.lang.String methodName)
          Log the soap request and response message together with message, if both logSOAPMessages and enableLogging are true.
 void setEnableLogging(boolean enableLogging)
          Set the value of enableLogging.
 void setLogger(org.apache.commons.logging.Log logger)
          Provide the customized Log object.
 void setLogSOAPMessages(boolean logSOAPMessages)
          Set the value of logSOAPMessages.
private  void setup(java.util.Properties logConfig)
          Do the work of construction.
 void trace(java.lang.String message)
          Log message as trace message, if enableLogging is true.
 void trace(org.apache.axis.client.Stub serviceStub)
          Log the soap request and response message as trace message, if both logSOAPMessages and enableLogging are true.
 void trace(org.apache.axis.client.Stub serviceStub, java.lang.String message)
          Log the soap request and response message together with message as trace message, if both logSOAPMessages and enableLogging are true.
 void warn(java.lang.String message)
          Log message as warn message, if enableLogging is true.
 void warn(org.apache.axis.client.Stub serviceStub)
          Log the soap request and response message as warn message, if both logSOAPMessages and enableLogging are true.
 void warn(org.apache.axis.client.Stub serviceStub, java.lang.String message)
          Log the soap request and response message together with message as warn message, if both logSOAPMessages and enableLogging are true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private org.apache.commons.logging.Log logger
The Log object.


enableLogging

private boolean enableLogging
Whether to enable logging. By default enableLogging is set to true.


logSOAPMessages

private boolean logSOAPMessages
Whether to log soap messages. By default logSOAPMessages is set to false.

Constructor Detail

LogHelper

public LogHelper()
          throws java.io.IOException
Default constructor. Read log configurations from default property file.

Throws:
java.io.IOException

LogHelper

public LogHelper(org.apache.commons.logging.Log log)
Constructor to instantiate LogHelper with the given Log object.


LogHelper

public LogHelper(java.util.Properties logConfig)
Constructor to instantiate LogHelper by reading log configuration options from logConfig.

Parameters:
logConfig - the Properties object containing the log configuration options.

LogHelper

public LogHelper(java.lang.String configFilename)
          throws java.io.IOException
Constructor to instantiate LogHelper by reading log configuration options from property file configFilename.

Parameters:
configFilename - the Property file containing the log configuration options.
Throws:
java.io.IOException
Method Detail

setup

private void setup(java.util.Properties logConfig)
Do the work of construction.

Parameters:
logConfig - the Properties object containing the log configuration options.

trace

public void trace(java.lang.String message)
Log message as trace message, if enableLogging is true.

Parameters:
message - the message to be logged.

info

public void info(java.lang.String message)
Log message as info message, if enableLogging is true.

Parameters:
message - the message to be logged.

debug

public void debug(java.lang.String message)
Log message as debug message, if enableLogging is true.

Parameters:
message - the message to be logged.

warn

public void warn(java.lang.String message)
Log message as warn message, if enableLogging is true.

Parameters:
message - the message to be logged.

error

public void error(java.lang.String message)
Log message as error message, if enableLogging is true.

Parameters:
message - the message to be logged.

fatal

public void fatal(java.lang.String message)
Log message as fatal message, if enableLogging is true.

Parameters:
message - the message to be logged.

trace

public void trace(org.apache.axis.client.Stub serviceStub,
                  java.lang.String message)
Log the soap request and response message together with message as trace message, if both logSOAPMessages and enableLogging are true.

Parameters:
serviceStub - the Stub object containing the soap request and response message.
message - will be logged before the soap request and response message.

info

public void info(org.apache.axis.client.Stub serviceStub,
                 java.lang.String message)
Log the soap request and response message together with message as info message, if both logSOAPMessages and enableLogging are true.

Parameters:
serviceStub - the Stub object containing the soap request and response message.
message - will be logged before the soap request and response message.

debug

public void debug(org.apache.axis.client.Stub serviceStub,
                  java.lang.String message)
Log the soap request and response message together with message as debug message, if both logSOAPMessages and enableLogging are true.

Parameters:
serviceStub - the Stub object containing the soap request and response message.
message - will be logged before the soap request and response message.

warn

public void warn(org.apache.axis.client.Stub serviceStub,
                 java.lang.String message)
Log the soap request and response message together with message as warn message, if both logSOAPMessages and enableLogging are true.

Parameters:
serviceStub - the Stub object containing the soap request and response message.
message - will be logged before the soap request and response message.

error

public void error(org.apache.axis.client.Stub serviceStub,
                  java.lang.String message)
Log the soap request and response message together with message as error message, if both logSOAPMessages and enableLogging are true.

Parameters:
serviceStub - the Stub object containing the soap request and response message.
message - will be logged before the soap request and response message.

fatal

public void fatal(org.apache.axis.client.Stub serviceStub,
                  java.lang.String message)
Log the soap request and response message together with message as fatal message, if both logSOAPMessages and enableLogging are true.

Parameters:
serviceStub - the Stub object containing the soap request and response message.
message - will be logged before the soap request and response message.

trace

public void trace(org.apache.axis.client.Stub serviceStub)
Log the soap request and response message as trace message, if both logSOAPMessages and enableLogging are true.

Parameters:
serviceStub - the Stub object containing the soap request and response message

info

public void info(org.apache.axis.client.Stub serviceStub)
Log the soap request and response message as info message, if both logSOAPMessages and enableLogging are true.

Parameters:
serviceStub - the Stub object containing the soap request and response message

debug

public void debug(org.apache.axis.client.Stub serviceStub)
Log the soap request and response message as debug message, if both logSOAPMessages and enableLogging are true.

Parameters:
serviceStub - the Stub object containing the soap request and response message

warn

public void warn(org.apache.axis.client.Stub serviceStub)
Log the soap request and response message as warn message, if both logSOAPMessages and enableLogging are true.

Parameters:
serviceStub - the Stub object containing the soap request and response message

error

public void error(org.apache.axis.client.Stub serviceStub)
Log the soap request and response message as error message, if both logSOAPMessages and enableLogging are true.

Parameters:
serviceStub - the Stub object containing the soap request and response message

fatal

public void fatal(org.apache.axis.client.Stub serviceStub)
Log the soap request and response message as fatal message, if both logSOAPMessages and enableLogging are true.

Parameters:
serviceStub - the Stub object containing the soap request and response message

log

public void log(java.lang.String message,
                java.lang.String methodName)
Log the message as type of methodName if enableLogging is true.

Parameters:
message - the message to be logged.
methodName - the log method to be called. They include: trace, debug, info, warn, error and fatal.

log

public void log(org.apache.axis.client.Stub serviceStub,
                java.lang.String message,
                java.lang.String methodName)
Log the soap request and response message together with message, if both logSOAPMessages and enableLogging are true.

Parameters:
serviceStub - the Stub object containing the soap request and response message
message - will be logged before the soap request and response message if the message object is not null
methodName - the log method to be called. They include: trace, debug, info, warn, error and fatal.

getLogger

public org.apache.commons.logging.Log getLogger()
Return the current Log object

Returns:
logger.

setLogger

public void setLogger(org.apache.commons.logging.Log logger)
Provide the customized Log object.

Parameters:
logger -

isEnableLogging

public boolean isEnableLogging()
Return the current value of enableLogging.

Returns:
enableLogging.

setEnableLogging

public void setEnableLogging(boolean enableLogging)
Set the value of enableLogging. Logging is enabled if the value is set to true.

Parameters:
enableLogging -

isLogSOAPMessages

public boolean isLogSOAPMessages()
Return the current value of logSOAPMessages.

Returns:
enableLogging.

setLogSOAPMessages

public void setLogSOAPMessages(boolean logSOAPMessages)
Set the value of logSOAPMessages. SOAP requests and responses are logged if the value is set to true and logging is enabled (setEnableLogging(true)).

Parameters:
logSOAPMessages -

getMessageAsString

public java.lang.String getMessageAsString(org.apache.axis.Message message)
                                    throws org.apache.axis.AxisFault,
                                           java.lang.Exception
Return soap request or response as String from the message.

Parameters:
message - the soap request or response Message object
Returns:
the soap request or response as String
Throws:
org.apache.axis.AxisFault
java.lang.Exception