atg.nucleus.logging
Class VariableArgumentApplicationLoggingUtil

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingUtil

public class VariableArgumentApplicationLoggingUtil
extends java.lang.Object

Implementation class for variable argument logging utility methods. Implemented as an instance class for subclassing and overriding purposes.

All methods use MessageFormat style argument strings. The MessageFormat interpretation used by this class has been extended to understand DynamicBeans property syntax DynamicBeans. The syntax supported is that handled by DynamicBeans.getSubPropertyValue(java.lang.Object, java.lang.String). For example, "{0.absoluteName}" or "{0.addresses[0].city}".

Created: August 19 2008


Nested Class Summary
protected  class VariableArgumentApplicationLoggingUtil.NumberIndexDictionary
          A very minimal map implementation that wraps and list and allows one to access properties by number.
 
Field Summary
static java.lang.String CLASS_VERSION
          Class version string
static java.lang.String INSTANCE_CLASS_PROPERTY_NAME
           
static VariableArgumentApplicationLoggingUtil sInstance
           
static java.lang.String TRACE_PREFIX
          Prefix for trace messages when logging through a non-TraceApplicationLogging
 
Constructor Summary
VariableArgumentApplicationLoggingUtil()
           
 
Method Summary
protected  java.util.regex.Pattern createArgBeanPropertyPattern()
          Create a quick and dirty pattern for looking for likely bean property syntax.
protected  java.util.regex.Pattern createArgPresentPattern(int pIndex)
          Create a pattern to look for the usage of a numeric format argument.
 java.util.regex.Pattern[] createArgPresentPatterns()
          Create the patterns to detect if a given format argment is present.
protected  java.util.regex.Pattern[] createArgPresentPatterns(int pSize)
          Create regex argument patterns for looking for references.
 int findPropertiedArgClose(int pIndex, java.lang.String pSource)
          Open curly brace, look for the end of the first argument, but only return a "found" index if it looks like the first argument has property-like syntax.
protected  java.util.regex.Pattern getArgBeanPropertyPattern()
           
protected  java.util.regex.Pattern getArgPresentPattern(int pIndex)
          Get a pattern to attempt to detect if format argument pIndex is referenced.
protected  java.util.regex.Pattern[] getArgPresentPatterns()
          Get the array of patterns to look for a particular pattern being referenced.
protected  java.lang.String getBundleString(ApplicationLogging pLogging, java.util.ResourceBundle pBundle, java.lang.String pKey, java.lang.Object[] pArgs)
          Get the specified String from the bundle using the specified key.
static VariableArgumentApplicationLoggingUtil getInstance()
          Return an instance of this class for use by other implementations.
protected  java.lang.String getTracePrefix()
          Prefix to use when logging trace messages through a non-TraceApplicationLogging logger.
protected  java.lang.Throwable getUnreferencedThrowable(ApplicationLogging pLogging, java.lang.String pFormat, java.lang.Object[] pArgs)
          Return the unreferenced throwable, if it is the last argument.
protected  boolean hasArgBeanProperty(java.lang.String pString)
          Return whether the string has bean property syntax in the provided format string.
 java.lang.String messageFormat(java.lang.String pFormat, java.lang.Object[] pArgs)
          Format the specified format string using the the same format that MessageFormat.
protected  java.lang.Object[] replaceArgsForImprovedPrinting(java.lang.Object[] pArgs)
          Arrays, for example, are not very useful when printed out directly, so instead replace with lists.
 void vlogDebug(ApplicationLogging pLogging, java.util.ResourceBundle pBundle, java.lang.String pKey, java.lang.Object[] pArgs)
          Log a resource-based log debug message through pLogging.
 void vlogDebug(ApplicationLogging pLogging, java.lang.String pFormat, java.lang.Object[] pArgs)
          Log a formatted debug message through pLogging.
 void vlogDebug(ApplicationLogging pLogging, java.lang.Throwable pThrowable, java.util.ResourceBundle pBundle, java.lang.String pKey, java.lang.Object[] pArgs)
          Log a resource-based log debug message through pLogging.
 void vlogDebug(ApplicationLogging pLogging, java.lang.Throwable pThrowable, java.lang.String pFormat, java.lang.Object[] pArgs)
          Log a formatted debug message through pLogging.
 void vlogError(ApplicationLogging pLogging, java.util.ResourceBundle pBundle, java.lang.String pKey, java.lang.Object[] pArgs)
          Log a resource-based log error message through pLogging.
 void vlogError(ApplicationLogging pLogging, java.lang.String pFormat, java.lang.Object[] pArgs)
          Log a formatted error message through pLogging.
 void vlogError(ApplicationLogging pLogging, java.lang.Throwable pThrowable, java.util.ResourceBundle pBundle, java.lang.String pKey, java.lang.Object[] pArgs)
          Log a resource-based log error message through pLogging.
 void vlogError(ApplicationLogging pLogging, java.lang.Throwable pThrowable, java.lang.String pFormat, java.lang.Object[] pArgs)
          Log a formatted error message through pLogging.
 void vlogInfo(ApplicationLogging pLogging, java.util.ResourceBundle pBundle, java.lang.String pKey, java.lang.Object[] pArgs)
          Log a resource-based log info message through pLogging.
 void vlogInfo(ApplicationLogging pLogging, java.lang.String pFormat, java.lang.Object[] pArgs)
          Log a formatted info message through pLogging.
 void vlogInfo(ApplicationLogging pLogging, java.lang.Throwable pThrowable, java.util.ResourceBundle pBundle, java.lang.String pKey, java.lang.Object[] pArgs)
          Log a resource-based log info message through pLogging.
 void vlogInfo(ApplicationLogging pLogging, java.lang.Throwable pThrowable, java.lang.String pFormat, java.lang.Object[] pArgs)
          Log a formatted info message through pLogging.
 void vlogTrace(ApplicationLogging pLogging, java.util.ResourceBundle pBundle, java.lang.String pKey, java.lang.Object[] pArgs)
          Log a resource-based log trace message through pLogging.
 void vlogTrace(ApplicationLogging pLogging, java.lang.String pFormat, java.lang.Object[] pArgs)
          Log a formatted trace message through pLogging.
 void vlogTrace(ApplicationLogging pLogging, java.lang.Throwable pThrowable, java.util.ResourceBundle pBundle, java.lang.String pKey, java.lang.Object[] pArgs)
          Log a resource-based log trace message through pLogging.
 void vlogTrace(ApplicationLogging pLogging, java.lang.Throwable pThrowable, java.lang.String pFormat, java.lang.Object[] pArgs)
          Log a formatted trace message through pLogging.
 void vlogWarning(ApplicationLogging pLogging, java.util.ResourceBundle pBundle, java.lang.String pKey, java.lang.Object[] pArgs)
          Log a resource-based log warning message through pLogging.
 void vlogWarning(ApplicationLogging pLogging, java.lang.String pFormat, java.lang.Object[] pArgs)
          Log a formatted warning message through pLogging.
 void vlogWarning(ApplicationLogging pLogging, java.lang.Throwable pThrowable, java.util.ResourceBundle pBundle, java.lang.String pKey, java.lang.Object[] pArgs)
          Log a resource-based log warning message through pLogging.
 void vlogWarning(ApplicationLogging pLogging, java.lang.Throwable pThrowable, java.lang.String pFormat, java.lang.Object[] pArgs)
          Log a formatted warning message through pLogging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


sInstance

public static volatile VariableArgumentApplicationLoggingUtil sInstance

INSTANCE_CLASS_PROPERTY_NAME

public static final java.lang.String INSTANCE_CLASS_PROPERTY_NAME
See Also:
Constant Field Values

TRACE_PREFIX

public static final java.lang.String TRACE_PREFIX
Prefix for trace messages when logging through a non-TraceApplicationLogging

See Also:
Constant Field Values
Constructor Detail

VariableArgumentApplicationLoggingUtil

public VariableArgumentApplicationLoggingUtil()
Method Detail

getInstance

public static VariableArgumentApplicationLoggingUtil getInstance()
Return an instance of this class for use by other implementations.


getArgPresentPatterns

protected java.util.regex.Pattern[] getArgPresentPatterns()
Get the array of patterns to look for a particular pattern being referenced.


getArgBeanPropertyPattern

protected java.util.regex.Pattern getArgBeanPropertyPattern()

vlogDebug

public void vlogDebug(ApplicationLogging pLogging,
                      java.lang.Throwable pThrowable,
                      java.util.ResourceBundle pBundle,
                      java.lang.String pKey,
                      java.lang.Object[] pArgs)
Log a resource-based log debug message through pLogging. The key should refer to a resource containing a format string to use. If not currently doing debug logging, then just return.

Parameters:
pLogging - The application logging to log through.
pThrowable - the exception to be logged. Will be logged after the message.
pBundle - The resoure bundle.
pKey - the resource key in the bundle to use as a format string.
pArgs - the format arguments needed by the key's format string.

vlogDebug

public void vlogDebug(ApplicationLogging pLogging,
                      java.util.ResourceBundle pBundle,
                      java.lang.String pKey,
                      java.lang.Object[] pArgs)
Log a resource-based log debug message through pLogging. The key should refer to a resource containing a format string to use. If not currently doing debug logging, then just return.

Parameters:
pLogging - The application logging to log through.
pBundle - The resoure bundle.
pKey - the resource key in the bundle to use as a format string.
pArgs - the format arguments needed by the key's format string.

vlogDebug

public void vlogDebug(ApplicationLogging pLogging,
                      java.lang.Throwable pThrowable,
                      java.lang.String pFormat,
                      java.lang.Object[] pArgs)
Log a formatted debug message through pLogging. If not currently doing debug logging, then just return.

Parameters:
pLogging - The application logging to log through.
pThrowable - the exception to be logged. Will be logged after the message.
pFormat - The format string to use. Uses MessageFormat to render.
pArgs - the format arguments needed by the key's format string.

vlogDebug

public void vlogDebug(ApplicationLogging pLogging,
                      java.lang.String pFormat,
                      java.lang.Object[] pArgs)
Log a formatted debug message through pLogging. If not currently doing debug logging, then just return.

Parameters:
pLogging - The application logging to log through.
pFormat - The format string to use. Uses MessageFormat to render.
pArgs - the format arguments needed by the key's format string.

vlogError

public void vlogError(ApplicationLogging pLogging,
                      java.lang.Throwable pThrowable,
                      java.util.ResourceBundle pBundle,
                      java.lang.String pKey,
                      java.lang.Object[] pArgs)
Log a resource-based log error message through pLogging. The key should refer to a resource containing a format string to use. If not currently doing error logging, then just return.

Parameters:
pLogging - The application logging to log through.
pThrowable - the exception to be logged. Will be logged after the message.
pBundle - The resoure bundle.
pKey - the resource key in the bundle to use as a format string.
pArgs - the format arguments needed by the key's format string.

vlogError

public void vlogError(ApplicationLogging pLogging,
                      java.util.ResourceBundle pBundle,
                      java.lang.String pKey,
                      java.lang.Object[] pArgs)
Log a resource-based log error message through pLogging. The key should refer to a resource containing a format string to use. If not currently doing error logging, then just return.

Parameters:
pLogging - The application logging to log through.
pBundle - The resoure bundle.
pKey - the resource key in the bundle to use as a format string.
pArgs - the format arguments needed by the key's format string.

vlogError

public void vlogError(ApplicationLogging pLogging,
                      java.lang.Throwable pThrowable,
                      java.lang.String pFormat,
                      java.lang.Object[] pArgs)
Log a formatted error message through pLogging. If not currently doing error logging, then just return.

Parameters:
pLogging - The application logging to log through.
pThrowable - the exception to be logged. Will be logged after the message.
pFormat - The format string to use. Uses MessageFormat to render.
pArgs - the format arguments needed by the key's format string.

vlogError

public void vlogError(ApplicationLogging pLogging,
                      java.lang.String pFormat,
                      java.lang.Object[] pArgs)
Log a formatted error message through pLogging. If not currently doing error logging, then just return.

Parameters:
pLogging - The application logging to log through.
pFormat - The format string to use. Uses MessageFormat to render.
pArgs - the format arguments needed by the key's format string.

vlogWarning

public void vlogWarning(ApplicationLogging pLogging,
                        java.lang.Throwable pThrowable,
                        java.util.ResourceBundle pBundle,
                        java.lang.String pKey,
                        java.lang.Object[] pArgs)
Log a resource-based log warning message through pLogging. The key should refer to a resource containing a format string to use. If not currently doing warning logging, then just return.

Parameters:
pLogging - The application logging to log through.
pThrowable - the exception to be logged. Will be logged after the message.
pBundle - The resoure bundle.
pKey - the resource key in the bundle to use as a format string.
pArgs - the format arguments needed by the key's format string.

vlogWarning

public void vlogWarning(ApplicationLogging pLogging,
                        java.util.ResourceBundle pBundle,
                        java.lang.String pKey,
                        java.lang.Object[] pArgs)
Log a resource-based log warning message through pLogging. The key should refer to a resource containing a format string to use. If not currently doing warning logging, then just return.

Parameters:
pLogging - The application logging to log through.
pBundle - The resoure bundle.
pKey - the resource key in the bundle to use as a format string.
pArgs - the format arguments needed by the key's format string.

vlogWarning

public void vlogWarning(ApplicationLogging pLogging,
                        java.lang.Throwable pThrowable,
                        java.lang.String pFormat,
                        java.lang.Object[] pArgs)
Log a formatted warning message through pLogging. If not currently doing warning logging, then just return.

Parameters:
pLogging - The application logging to log through.
pThrowable - the exception to be logged. Will be logged after the message.
pFormat - The format string to use. Uses MessageFormat to render.
pArgs - the format arguments needed by the key's format string.

vlogWarning

public void vlogWarning(ApplicationLogging pLogging,
                        java.lang.String pFormat,
                        java.lang.Object[] pArgs)
Log a formatted warning message through pLogging. If not currently doing warning logging, then just return.

Parameters:
pLogging - The application logging to log through.
pFormat - The format string to use. Uses MessageFormat to render.
pArgs - the format arguments needed by the key's format string.

vlogInfo

public void vlogInfo(ApplicationLogging pLogging,
                     java.lang.Throwable pThrowable,
                     java.util.ResourceBundle pBundle,
                     java.lang.String pKey,
                     java.lang.Object[] pArgs)
Log a resource-based log info message through pLogging. The key should refer to a resource containing a format string to use. If not currently doing info logging, then just return.

Parameters:
pLogging - The application logging to log through.
pThrowable - the exception to be logged. Will be logged after the message.
pBundle - The resoure bundle.
pKey - the resource key in the bundle to use as a format string.
pArgs - the format arguments needed by the key's format string.

vlogInfo

public void vlogInfo(ApplicationLogging pLogging,
                     java.util.ResourceBundle pBundle,
                     java.lang.String pKey,
                     java.lang.Object[] pArgs)
Log a resource-based log info message through pLogging. The key should refer to a resource containing a format string to use. If not currently doing info logging, then just return.

Parameters:
pLogging - The application logging to log through.
pBundle - The resoure bundle.
pKey - the resource key in the bundle to use as a format string.
pArgs - the format arguments needed by the key's format string.

vlogInfo

public void vlogInfo(ApplicationLogging pLogging,
                     java.lang.Throwable pThrowable,
                     java.lang.String pFormat,
                     java.lang.Object[] pArgs)
Log a formatted info message through pLogging. If not currently doing info logging, then just return.

Parameters:
pLogging - The application logging to log through.
pThrowable - the exception to be logged. Will be logged after the message.
pFormat - The format string to use. Uses MessageFormat to render.
pArgs - the format arguments needed by the key's format string.

vlogInfo

public void vlogInfo(ApplicationLogging pLogging,
                     java.lang.String pFormat,
                     java.lang.Object[] pArgs)
Log a formatted info message through pLogging. If not currently doing info logging, then just return.

Parameters:
pLogging - The application logging to log through.
pFormat - The format string to use. Uses MessageFormat to render.
pArgs - the format arguments needed by the key's format string.

vlogTrace

public void vlogTrace(ApplicationLogging pLogging,
                      java.lang.Throwable pThrowable,
                      java.util.ResourceBundle pBundle,
                      java.lang.String pKey,
                      java.lang.Object[] pArgs)
Log a resource-based log trace message through pLogging. The key should refer to a resource containing a format string to use. If not currently doing trace logging, then just return.

Parameters:
pLogging - The application logging to log through.
pThrowable - the exception to be logged. Will be logged after the message.
pBundle - The resoure bundle.
pKey - the resource key in the bundle to use as a format string.
pArgs - the format arguments needed by the key's format string.

vlogTrace

public void vlogTrace(ApplicationLogging pLogging,
                      java.util.ResourceBundle pBundle,
                      java.lang.String pKey,
                      java.lang.Object[] pArgs)
Log a resource-based log trace message through pLogging. The key should refer to a resource containing a format string to use. If not currently doing trace logging, then just return.

Parameters:
pLogging - The application logging to log through.
pBundle - The resoure bundle.
pKey - the resource key in the bundle to use as a format string.
pArgs - the format arguments needed by the key's format string.

vlogTrace

public void vlogTrace(ApplicationLogging pLogging,
                      java.lang.Throwable pThrowable,
                      java.lang.String pFormat,
                      java.lang.Object[] pArgs)
Log a formatted trace message through pLogging. If not currently doing trace logging, then just return.

Parameters:
pLogging - The application logging to log through.
pThrowable - the exception to be logged. Will be logged after the message.
pFormat - The format string to use. Uses MessageFormat to render.
pArgs - the format arguments needed by the key's format string.

vlogTrace

public void vlogTrace(ApplicationLogging pLogging,
                      java.lang.String pFormat,
                      java.lang.Object[] pArgs)
Log a formatted trace message through pLogging. If not currently doing trace logging, then just return.

Parameters:
pLogging - The application logging to log through.
pFormat - The format string to use. Uses MessageFormat to render.
pArgs - the format arguments needed by the key's format string.

getBundleString

protected java.lang.String getBundleString(ApplicationLogging pLogging,
                                           java.util.ResourceBundle pBundle,
                                           java.lang.String pKey,
                                           java.lang.Object[] pArgs)
Get the specified String from the bundle using the specified key. Attempts to log on any problems, so poor user might be able get a clue.

Parameters:
pLogging - the application logging to use.
pBundle - the resource bundle to obtain the resource from.
pKey - the key to look up in the resource bundle.
pArgs - the format arguments.

messageFormat

public java.lang.String messageFormat(java.lang.String pFormat,
                                      java.lang.Object[] pArgs)
Format the specified format string using the the same format that MessageFormat. The message format syntax has been entended to accept DynamicBeans property syntax for the first argument. This allows expressions such as "{0.addresses[0].city}" to be interpretted.

Parameters:
pFormat - the format string.
pArgs - the format arguments.

replaceArgsForImprovedPrinting

protected java.lang.Object[] replaceArgsForImprovedPrinting(java.lang.Object[] pArgs)
Arrays, for example, are not very useful when printed out directly, so instead replace with lists. Other replacements may be added later.

Parameters:
pArgs - the source list of format arguments.
Returns:
either pArgs, or a modified copy of pArgs, if at least one array was found in the list.

findPropertiedArgClose

public int findPropertiedArgClose(int pIndex,
                                  java.lang.String pSource)
Open curly brace, look for the end of the first argument, but only return a "found" index if it looks like the first argument has property-like syntax. The goal is to avoid doing anything expensive if there is only standard syntax.

Parameters:
pIndex - the starting index.
pSource - the source string.

getTracePrefix

protected java.lang.String getTracePrefix()
Prefix to use when logging trace messages through a non-TraceApplicationLogging logger. Message goes through debug, instead.


getUnreferencedThrowable

protected java.lang.Throwable getUnreferencedThrowable(ApplicationLogging pLogging,
                                                       java.lang.String pFormat,
                                                       java.lang.Object[] pArgs)
Return the unreferenced throwable, if it is the last argument. Will also log a warning.

Parameters:
pLogging - the logging to use for a warning, if an unreferenced throwable is found to be the last argument.
pFormat - the format string.
-

getArgPresentPattern

protected java.util.regex.Pattern getArgPresentPattern(int pIndex)
Get a pattern to attempt to detect if format argument pIndex is referenced.

Parameters:
pIndex - the format index to attempt to match

createArgPresentPatterns

public java.util.regex.Pattern[] createArgPresentPatterns()
Create the patterns to detect if a given format argment is present. By default, returns an array of 20 elements.

See Also:
createArgPresentPatterns()

createArgPresentPatterns

protected java.util.regex.Pattern[] createArgPresentPatterns(int pSize)
Create regex argument patterns for looking for references. The pattern at the correspnding element looks for a match for that element. For example, the pattern at slot 3 will match "{3}" "{3.foo}" and "{3,Date,MMYY}"

Parameters:
pSize - the size of the array to return.

createArgPresentPattern

protected java.util.regex.Pattern createArgPresentPattern(int pIndex)
Create a pattern to look for the usage of a numeric format argument. For example "{1}" or "{0.foo}".

Parameters:
pIndex - the numeric argument to look for.

createArgBeanPropertyPattern

protected java.util.regex.Pattern createArgBeanPropertyPattern()
Create a quick and dirty pattern for looking for likely bean property syntax. This provides us a reasonable way to avoid doing a careful parse of the whole string when there is no bean property syntax to manage.


hasArgBeanProperty

protected boolean hasArgBeanProperty(java.lang.String pString)
Return whether the string has bean property syntax in the provided format string.

Parameters:
pString - a MessageFormat-ish string, that possibly contains additional bean property syntax.