com.ibm.websphere.logging.hpel.reader

Class HpelFormatter

  1. java.lang.Object
  2. extended bycom.ibm.websphere.logging.hpel.reader.HpelFormatter

  1. public abstract class HpelFormatter
  2. extends java.lang.Object
Abstract class for formatters used to convert HPEL log records into a formatted string output. This class should be used for getting formatter instances.

Nested Class Summary

Modifier and Type Class and Description
  1. protected class
HpelFormatter.CustomHeaderLine
Helper class representing one line of the customary defined header.

Field Summary

Modifier and Type Field and Description
  1. protected
  2. HpelFormatter.CustomHeaderLine[]
customHeader
Set of lines to use in the custom header.
  1. protected static
  2. java.util.Map<java.util.logging.Level,java.lang.String>
customLevels
Map between level and it's one character id.
  1. protected
  2. java.text.DateFormat
dateFormat
  1. static
  2. java.lang.String
FORMAT_ADVANCED
"Advanced" type format used in legacy text log files
  1. static
  2. java.lang.String
FORMAT_BASIC
"Basic" type format used in legacy text log files
  1. static
  2. java.lang.String
FORMAT_CBE101
Common Base Event Format
  1. protected
  2. java.util.Properties
headerProps
  1. protected
  2. java.lang.String
lineSeparator
  1. protected
  2. java.util.Locale
locale
Locale this formatters uses for record messages and date formatting
  1. protected static
  2. java.lang.String
nullParamString
  1. protected
  2. java.util.TimeZone
timeZone

Constructor Summary

Constructor and Description
HpelFormatter()

Method Summary

Modifier and Type Method and Description
  1. static
  2. void
addCustomLevel(java.util.logging.Level level,java.lang.String id)
Adds level to be treated specially by this formatter.
  1. static
  2. java.util.logging.Level
addCustomLevel(java.lang.String name,int intValue,java.lang.String id,java.lang.String resourceBundleName)
Adds extra level recognizable by this formatter and Level.parse()
  1. protected abstract
  2. java.lang.String
appendUnusedParms(java.lang.String message,java.lang.Object[] args)
Add parameters to the end of a message based on policy indicated by unusedParmHandling parameter.
  1. static
  2. java.lang.Object[]
convertParameters(java.lang.Object[] parms)
Returns an array of parameters that matches the input parms except: Parameters that are empty strings are converted to "" (2 double quotes)
  1. java.lang.String
formatMessage(RepositoryLogRecord record,java.util.Locale tmpLocale)
Returns the formatted version of the record's message in a specified locale with any place holder parameters substituted with values.
  1. java.lang.String
formatRecord(java.util.logging.LogRecord record)
Formats a LogRecord using the formatter's locale
  1. java.lang.String
formatRecord(RepositoryLogRecord record)
Formats a RepositoryLogRecord using the formatter's locale
  1. abstract
  2. java.lang.String
formatRecord(RepositoryLogRecord record,java.util.Locale locale)
Formats a RepositoryLogRecord using the locale specified.
  1. protected static
  2. void
formatThreadID(RepositoryLogRecord r,java.lang.StringBuilder buffer)
  1. protected
  2. java.lang.String
formatUnlocalized(java.lang.String traceString,java.lang.Object[] parms)
Used for WsLogRecords or CommonBaseEventLogRecords that specify REQUIRES_NO_LOCALIZATION, tries to format, and if unsuccessful in using any parameters appends them per unusedParmHandling.
  1. abstract
  2. java.lang.String
getFooter()
Gets the formatter's footer.
  1. static
  2. HpelFormatter
getFormatter(java.lang.String formatStyle)
Returns the HpelFormatter subclass instance to be used for formatting a RepositoryLogRecord.
  1. abstract
  2. java.lang.String[]
getHeader()
Gets the formatter's header.
  1. java.util.Properties
getHeaderProps()
Returns the Properties that is used to populate the formatter's header.
  1. java.lang.String
getLineSeparator()
  1. java.util.Locale
getLocale()
Returns the formatter's locale that will be used to localize the log record's date timestamp and message.
  1. java.lang.String
getTimeZoneID()
Returns the ID of the time zone to be used in the formatted log record header timestamp
  1. void
setCustomHeader(java.lang.String[] header)
sets new customer header format specification
  1. void
setHeaderProps(java.util.Properties properties)
Sets the Properties that is used to populate the formatter's header.
  1. void
setLineSeparator(java.lang.String lineSeparator)
  1. void
setLocale(java.util.Locale locale)
Sets the formatter locale that will be used to localize a log record being formatted.
  1. void
setTimeZoneID(java.lang.String timeZoneId)
Sets the ID of the time zone to be used in the formatted log record header timestamp
  1. static
  2. java.lang.String
translateMessage(RepositoryLogRecord record,java.util.Locale tmpLocale)
  1. protected static
  2. boolean
verifyTimeZoneID(java.lang.String timeZoneID)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

FORMAT_BASIC

  1. public static final java.lang.String FORMAT_BASIC
"Basic" type format used in legacy text log files
See Also:

FORMAT_ADVANCED

  1. public static final java.lang.String FORMAT_ADVANCED
"Advanced" type format used in legacy text log files
See Also:

FORMAT_CBE101

  1. public static final java.lang.String FORMAT_CBE101
Common Base Event Format
See Also:

lineSeparator

  1. protected java.lang.String lineSeparator

headerProps

  1. protected java.util.Properties headerProps

locale

  1. protected java.util.Locale locale
Locale this formatters uses for record messages and date formatting

timeZone

  1. protected java.util.TimeZone timeZone

dateFormat

  1. protected java.text.DateFormat dateFormat

nullParamString

  1. protected static final java.lang.String nullParamString
See Also:

customLevels

  1. protected static final java.util.Map<java.util.logging.Level,java.lang.String> customLevels
Map between level and it's one character id.

customHeader

  1. protected HpelFormatter.CustomHeaderLine[] customHeader
Set of lines to use in the custom header.

Constructor Detail

HpelFormatter

  1. public HpelFormatter()

Method Detail

getFormatter

  1. public static HpelFormatter getFormatter( java.lang.String formatStyle)
Returns the HpelFormatter subclass instance to be used for formatting a RepositoryLogRecord. The formatter returned is based on the formatStyle requested.
Parameters:
formatStyle - the style of the HpelFormatter instance to be returned. Valid values must match (case-insensitive) FORMAT_BASIC, FORMAT_ADVANCED, or FORMAT_CBE101
Returns:
a HpelFormatter instance that matches the requested formatter style
Throws:
java.lang.IllegalArgumentException - when the formatterName is invalid due to a null value passed or a formatter name that is not recognized
See Also:
TimeZone

addCustomLevel

  1. public static java.util.logging.Level addCustomLevel( java.lang.String name,
  2. int intValue,
  3. java.lang.String id,
  4. java.lang.String resourceBundleName)
Adds extra level recognizable by this formatter and Level.parse()
Parameters:
name - name of the level
intValue - integer value of the level
id - one character id to use for this level. If it's 'null' first character of the level name will be used
resourceBundleName - resource bundle to use for level name translation
Returns:
newly generated level instance

addCustomLevel

  1. public static void addCustomLevel( java.util.logging.Level level,
  2. java.lang.String id)
Adds level to be treated specially by this formatter.
Parameters:
level - level to be added to the special list
id - one character id to use for this level. If it's 'null' first character of the level name will be used

setCustomHeader

  1. public void setCustomHeader(java.lang.String[] header)
sets new customer header format specification
Parameters:
header - array of Strings containing optional parameters with name of the header value to use in them. For example: "Java version: {java.version}".

getTimeZoneID

  1. public java.lang.String getTimeZoneID( )
Returns the ID of the time zone to be used in the formatted log record header timestamp
Returns:
time zone ID
See Also:
TimeZone

setTimeZoneID

  1. public void setTimeZoneID(java.lang.String timeZoneId)
Sets the ID of the time zone to be used in the formatted log record header timestamp
Parameters:
timeZoneId - new timeZoneID attribute value.
Throws:
java.lang.IllegalArgumentException - when the time zone ID is not valid.

getLocale

  1. public java.util.Locale getLocale( )
Returns the formatter's locale that will be used to localize the log record's date timestamp and message.
Returns:
the locale that will be used to localize the log record

setLocale

  1. public void setLocale(java.util.Locale locale)
Sets the formatter locale that will be used to localize a log record being formatted. The formatter locale will be used when formatRecord(RepositoryLogRecord) is invoked. It is possible to format a log record with a locale other than one set by this method using formatRecord(RepositoryLogRecord, Locale). the formatter locale will be set to the system locale until this method gets invoked.
Parameters:
locale - the Locale to be used for localizing the log record, null to disable message localization.

setHeaderProps

  1. public void setHeaderProps(java.util.Properties properties)
Sets the Properties that is used to populate the formatter's header. This Properties used in the parameter should be a Properties returned from invoking ServerInstanceLogRecordList.getHeader().
See Also:

getHeaderProps

  1. public java.util.Properties getHeaderProps( )
Returns the Properties that is used to populate the formatter's header.

formatMessage

  1. public java.lang.String formatMessage( RepositoryLogRecord record,
  2. java.util.Locale tmpLocale)
Returns the formatted version of the record's message in a specified locale with any place holder parameters substituted with values.

In cases where localization is successful, the formatted message is the localized message with any place holder values filled in with corresponding parameter values.

In cases where the localized message is null, the formatted message is the raw message with any place holder values filled in with corresponding parameter values.

This is the same behavior as found in LogRecord.getMessage()

Parameters:
record - log record to read the message from.
tmpLocale - locale to translate message into.
Returns:
the fully localized and formatted message.
See Also:
LogRecord.getMessage()

convertParameters

  1. public static java.lang.Object[] convertParameters( java.lang.Object[] parms)
Returns an array of parameters that matches the input parms except: Parameters that are empty strings are converted to "" (2 double quotes)
Parameters:
parms -
Returns:
Object[]

formatUnlocalized

  1. protected java.lang.String formatUnlocalized( java.lang.String traceString,
  2. java.lang.Object[] parms)
Used for WsLogRecords or CommonBaseEventLogRecords that specify REQUIRES_NO_LOCALIZATION, tries to format, and if unsuccessful in using any parameters appends them per unusedParmHandling.
Returns:
the formatted trace

appendUnusedParms

  1. protected abstract java.lang.String appendUnusedParms( java.lang.String message,
  2. java.lang.Object[] args)
Add parameters to the end of a message based on policy indicated by unusedParmHandling parameter.
Parameters:
message - Message to append arguments onto
args - Arguments to append to message
Returns:
String new copy of message with parameters appended, or message itself if nothing was appended

translateMessage

  1. public static java.lang.String translateMessage( RepositoryLogRecord record,
  2. java.util.Locale tmpLocale)
Parameters:
record - log record to read the message from.
tmpLocale - locale to translate message into.
Returns:
the fully localized message.

formatRecord

  1. public java.lang.String formatRecord( RepositoryLogRecord record)
Formats a RepositoryLogRecord using the formatter's locale
Parameters:
record - log record to be formatted
Returns:
the resulting formatted string output.

formatRecord

  1. public abstract java.lang.String formatRecord( RepositoryLogRecord record,
  2. java.util.Locale locale)
Formats a RepositoryLogRecord using the locale specified.
Parameters:
record - the RepositoryLogRecord to be formatted
locale - the locale to use when formatting this record.
Returns:
the formatted RepositoryLogRecord as string output.

formatRecord

  1. public java.lang.String formatRecord( java.util.logging.LogRecord record)
Formats a LogRecord using the formatter's locale
Parameters:
record - log record to be formatted
Returns:
the resulting formatted string output.

getHeader

  1. public abstract java.lang.String[] getHeader( )
Gets the formatter's header. This method will return an empty array if the formatter does not have a header as part of the formatter's format style return the header as an array of strings

getFooter

  1. public abstract java.lang.String getFooter( )
Gets the formatter's footer. This method will return an empty string if the formatter does not have a footer as part of the formatter's format style.
Returns:
the footer as a string

verifyTimeZoneID

  1. protected static boolean verifyTimeZoneID( java.lang.String timeZoneID)

formatThreadID

  1. protected static void formatThreadID( RepositoryLogRecord r,
  2. java.lang.StringBuilder buffer)

getLineSeparator

  1. public java.lang.String getLineSeparator( )

setLineSeparator

  1. public void setLineSeparator(java.lang.String lineSeparator)