Class HpelFormatter
- java.lang.Object
- 
- com.ibm.websphere.logging.hpel.reader.HpelFormatter
 
- 
- Direct Known Subclasses:
- HpelCBEFormatter,- HpelPlainFormatter
 
 public abstract class HpelFormatter extends java.lang.ObjectAbstract class for formatters used to convert HPEL log records into a formatted string output. This class should be used for getting formatter instances.
- 
- 
Field SummaryFields Modifier and Type Field Description static java.lang.StringFORMAT_ADVANCEDAdvanced type format used in legacy text log filesstatic java.lang.StringFORMAT_BASICBasic type format used in legacy text log filesstatic java.lang.StringFORMAT_CBE101Common Base Event Formatstatic java.lang.StringFORMAT_JSONJson Format
 - 
Constructor SummaryConstructors Constructor Description HpelFormatter()
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static java.util.logging.LeveladdCustomLevel(java.lang.String name, int intValue, java.lang.String id, java.lang.String resourceBundleName)Adds extra level recognizable by this formatter and Level.parse()static voidaddCustomLevel(java.util.logging.Level level, java.lang.String id)Adds level to be treated specially by this formatter.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)java.lang.StringformatMessage(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.java.lang.StringformatRecord(RepositoryLogRecord record)Formats a RepositoryLogRecord using the formatter's localeabstract java.lang.StringformatRecord(RepositoryLogRecord record, java.util.Locale locale)Formats a RepositoryLogRecord using the locale specified.java.lang.StringformatRecord(java.util.logging.LogRecord record)Formats a LogRecord using the formatter's localeabstract java.lang.StringgetFooter()Gets the formatter's footer.static HpelFormattergetFormatter(java.lang.String formatStyle)Returns the HpelFormatter subclass instance to be used for formatting a RepositoryLogRecord.abstract java.lang.String[]getHeader()Gets the formatter's header.java.util.PropertiesgetHeaderProps()Returns the Properties that is used to populate the formatter's header.java.lang.StringgetLineSeparator()java.util.LocalegetLocale()Returns the formatter's locale that will be used to localize the log record's date timestamp and message.java.lang.StringgetTimeZoneID()Returns the ID of the time zone to be used in the formatted log record header timestampvoidsetCustomHeader(java.lang.String[] header)sets new customer header format specificationvoidsetDateFormat(java.util.Locale locale, boolean isoDateFormat)Sets the formatter locale and the dateFormat that will be used to localize a log record being formatted.voidsetHeaderProps(java.util.Properties properties)Sets the Properties that is used to populate the formatter's header.voidsetLineSeparator(java.lang.String lineSeparator)voidsetStartDatetime(long headerStartDatetime)voidsetTimeZoneID(java.lang.String timeZoneId)Sets the ID of the time zone to be used in the formatted log record header timestampstatic java.lang.StringtranslateMessage(RepositoryLogRecord record, java.util.Locale tmpLocale)
 
- 
- 
- 
Field Detail- 
FORMAT_BASICpublic static final java.lang.String FORMAT_BASIC Basic type format used in legacy text log files- See Also:
- Constant Field Values
 
 - 
FORMAT_ADVANCEDpublic static final java.lang.String FORMAT_ADVANCED Advanced type format used in legacy text log files- See Also:
- Constant Field Values
 
 - 
FORMAT_CBE101public static final java.lang.String FORMAT_CBE101 Common Base Event Format- See Also:
- Constant Field Values
 
 - 
FORMAT_JSONpublic static final java.lang.String FORMAT_JSON Json Format- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getFormatterpublic 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- nullvalue passed or a formatter name that is not recognized
- See Also:
- TimeZone
 
 - 
addCustomLevelpublic static 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()- Parameters:
- name- name of the level
- intValue- integer value of the level
- id- one character id to use for this level. If it's- nullfirst character of the level name will be used
- resourceBundleName- resource bundle to use for level name translation
- Returns:
- newly generated level instance
 
 - 
addCustomLevelpublic static void addCustomLevel(java.util.logging.Level level, 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- nullfirst character of the level name will be used
 
 - 
setCustomHeaderpublic 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} .
 
 - 
getTimeZoneIDpublic 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
 
 - 
setTimeZoneIDpublic 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.
 
 - 
getLocalepublic 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
 
 - 
setDateFormatpublic void setDateFormat(java.util.Locale locale, boolean isoDateFormat)Sets the formatter locale and the dateFormat that will be used to localize a log record being formatted. The formatter locale will be used whenformatRecord(RepositoryLogRecord)is invoked. It is possible to format a log record with a locale other than one set by this method usingformatRecord(RepositoryLogRecord, Locale). the formatter locale will be set to the system locale until this method gets invoked. The dateFormat can be either the default format or the ISO-8601 format.- Parameters:
- locale- the Locale to be used for localizing the log record,- nullto disable message localization.
- flag- to use ISO-8601 date format for output.
 
 - 
setHeaderPropspublic 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:
- ServerInstanceLogRecordList
 
 - 
getHeaderPropspublic java.util.Properties getHeaderProps() Returns the Properties that is used to populate the formatter's header.
 - 
formatMessagepublic 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.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()
 
 - 
convertParameterspublic 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[]
 
 - 
translateMessagepublic static java.lang.String translateMessage(RepositoryLogRecord record, java.util.Locale tmpLocale) - Parameters:
- record- log record to read the message from.
- tmpLocale- locale to translate message into.
- Returns:
- the fully localized message.
 
 - 
formatRecordpublic 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.
 
 - 
formatRecordpublic abstract java.lang.String formatRecord(RepositoryLogRecord record, 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.
 
 - 
formatRecordpublic 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.
 
 - 
getHeaderpublic 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
 - 
getFooterpublic 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
 
 - 
getLineSeparatorpublic java.lang.String getLineSeparator() 
 - 
setLineSeparatorpublic void setLineSeparator(java.lang.String lineSeparator) 
 - 
setStartDatetimepublic void setStartDatetime(long headerStartDatetime) 
 
- 
 
-