/** * {@inheritDoc} */ public void format(final Object obj, final StringBuffer output) { if (obj instanceof LoggingEvent) { format((LoggingEvent) obj, output); } }
/** * Obtains an instance of pattern converter. * @param options options, may be null. * @return instance of pattern converter. */ public static LoggerPatternConverter newInstance( final String[] options) { if ((options == null) || (options.length == 0)) { return INSTANCE; } return new LoggerPatternConverter(options); }
/** * Constructor. * @param name name of converter. * @param style style name for associated output. * @param options options, may be null, first element will be interpreted as an abbreviation pattern. */ protected NamePatternConverter( final String name, final String style, final String[] options) { super(name, style); if ((options != null) && (options.length > 0)) { abbreviator = NameAbbreviator.getAbbreviator(options[0]); } else { abbreviator = NameAbbreviator.getDefaultAbbreviator(); } }
/** Format event to string buffer. @param sbuf string buffer to receive formatted event, may not be null. @param e event to format, may not be null. */ public void format(final StringBuffer sbuf, final LoggingEvent e) { for (int i = 0; i < patternConverters.length; i++) { int startField = sbuf.length(); patternConverters[i].format(e, sbuf); patternFields[i].format(startField, sbuf); } }
/** * {@inheritDoc} */ public void format(final LoggingEvent event, final StringBuffer output) { synchronized(this) { df.format(event.timeStamp, output); } }
/** * Gets an instance of ClassNamePatternConverter. * @param options options, may be null. * @return instance of pattern converter. */ public static ClassNamePatternConverter newInstance( final String[] options) { return new ClassNamePatternConverter(options); }
/** * Obtains an instance of RelativeTimePatternConverter. * @param options options, currently ignored, may be null. * @return instance of RelativeTimePatternConverter. */ public static RelativeTimePatternConverter newInstance( final String[] options) { return new RelativeTimePatternConverter(); }
/** * Create new pattern converter. * @return pattern converter. */ public org.apache.log4j.helpers.PatternConverter parse() { return new BridgePatternConverter(pattern); } }
/** * Gets an instance of the class. * @param options pattern options, may be null. If first element is "short", * only the first line of the throwable will be formatted. * @return instance of class. */ public static ThrowableInformationPatternConverter newInstance( final String[] options) { return new ThrowableInformationPatternConverter(options); }
/** * Abbreviate name in string buffer. * @param nameStart starting position of name to abbreviate. * @param buf string buffer containing name. */ protected final void abbreviate(final int nameStart, final StringBuffer buf) { abbreviator.abbreviate(nameStart, buf); } }
/** Returns PatternParser used to parse the conversion string. Subclasses may override this to return a subclass of PatternParser which recognize custom conversion characters. @since 0.9.0 */ protected org.apache.log4j.helpers.PatternParser createPatternParser(String pattern) { return new org.apache.log4j.pattern.BridgePatternParser(pattern); }
/** * Obtains an instance of pattern converter. * @param options options, may be null. * @return instance of pattern converter. */ public static DatePatternConverter newInstance( final String[] options) { return new DatePatternConverter(options); }
/** * Obtains an instance of PropertiesPatternConverter. * @param options options, may be null or first element contains name of property to format. * @return instance of PropertiesPatternConverter. */ public static PropertiesPatternConverter newInstance( final String[] options) { return new PropertiesPatternConverter(options); }
/** Return the message for this logging event. <p>Before serialization, the returned object is the message passed by the user to generate the logging event. After serialization, the returned value equals the String form of the message possibly after object rendering. @since 1.1 */ public Object getMessage() { if(message != null) { return message; } else { return getRenderedMessage(); } }
/** * Obtains an instance of pattern converter. * @param options options, may be null. * @return instance of pattern converter. */ public static PatternConverter newInstance( final String[] options) { if ((options == null) || (options.length == 0)) { return DatePatternConverter.newInstance( new String[] { "yyyy-MM-dd" }); } return DatePatternConverter.newInstance(options); } }
/** * Returns the set of the key values in the properties * for the event. * * The returned set is unmodifiable by the caller. * * Provided for compatibility with log4j 1.3 * * @return Set an unmodifiable set of the property keys. * @since 1.2.15 */ public Set getPropertyKeySet() { return getProperties().keySet(); }
/** * {@inheritDoc} */ protected String convert(final LoggingEvent event) { // // code should be unreachable. // StringBuffer sbuf = new StringBuffer(); format(sbuf, event); return sbuf.toString(); }
/** * Append formatted date to string buffer. * @param date date * @param toAppendTo buffer to which formatted date is appended. */ public void format(final Date date, final StringBuffer toAppendTo) { synchronized(this) { df.format(date.getTime(), toAppendTo); } } }
/** * Formats a Date into a date/time string. * * @param date the date to format. * @param sbuf the string buffer to write to. * @param fieldPosition remains untouched. * @return the formatted time string. */ public StringBuffer format( Date date, StringBuffer sbuf, FieldPosition fieldPosition) { format(date.getTime(), sbuf); return sbuf; }