Package org.apache.logging.log4j.message
Class DefaultFlowMessageFactory.AbstractFlowMessage
- java.lang.Object
-
- org.apache.logging.log4j.message.DefaultFlowMessageFactory.AbstractFlowMessage
-
- All Implemented Interfaces:
java.io.Serializable,FlowMessage,Message,StringBuilderFormattable
- Direct Known Subclasses:
DefaultFlowMessageFactory.SimpleEntryMessage,DefaultFlowMessageFactory.SimpleExitMessage
- Enclosing class:
- DefaultFlowMessageFactory
private static class DefaultFlowMessageFactory.AbstractFlowMessage extends java.lang.Object implements FlowMessage, StringBuilderFormattable
-
-
Field Summary
Fields Modifier and Type Field Description private Messagemessageprivate static longserialVersionUIDprivate java.lang.Stringtext
-
Constructor Summary
Constructors Constructor Description AbstractFlowMessage(java.lang.String text, Message message)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidformatTo(java.lang.StringBuilder buffer)Writes a text representation of this object into the specifiedStringBuilder, ideally without allocating temporary objects.java.lang.StringgetFormat()Gets the format portion of the Message.java.lang.StringgetFormattedMessage()Gets the Message formatted as a String.MessagegetMessage()The wrapped messagejava.lang.Object[]getParameters()Gets parameter values, if any.java.lang.StringgetText()The message text like "Enter" or "Exit" used to prefix the actual Message.java.lang.ThrowablegetThrowable()Gets the throwable, if any.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
message
private final Message message
-
text
private final java.lang.String text
-
-
Constructor Detail
-
AbstractFlowMessage
AbstractFlowMessage(java.lang.String text, Message message)
-
-
Method Detail
-
getFormattedMessage
public java.lang.String getFormattedMessage()
Description copied from interface:MessageGets the Message formatted as a String. Each Message implementation determines the appropriate way to format the data encapsulated in the Message. Messages that provide more than one way of formatting the Message will implement MultiformatMessage.When configured to log asynchronously, this method is called before the Message is queued, unless this message implements
ReusableMessageor is annotated withAsynchronouslyFormattable. This gives the Message implementation class a chance to create a formatted message String with the current value of any mutable objects. The intention is that the Message implementation caches this formatted message and returns it on subsequent calls. (See LOG4J2-763.)When logging synchronously, this method will not be called for Messages that implement the
StringBuilderFormattableinterface: instead, theformatTo(StringBuilder)method will be called so the Message can format its contents without creating intermediate String objects.- Specified by:
getFormattedMessagein interfaceMessage- Returns:
- The message String.
-
getFormat
public java.lang.String getFormat()
Description copied from interface:MessageGets the format portion of the Message.- Specified by:
getFormatin interfaceMessage- Returns:
- The message format. Some implementations, such as ParameterizedMessage, will use this as the message "pattern". Other Messages may simply return an empty String. TODO Do all messages have a format? What syntax? Using a Formatter object could be cleaner. (RG) In SimpleMessage the format is identical to the formatted message. In ParameterizedMessage and StructuredDataMessage it is not. It is up to the Message implementer to determine what this method will return. A Formatter is inappropriate as this is very specific to the Message implementation so it isn't clear to me how having a Formatter separate from the Message would be cleaner.
-
getParameters
public java.lang.Object[] getParameters()
Description copied from interface:MessageGets parameter values, if any.- Specified by:
getParametersin interfaceMessage- Returns:
- An array of parameter values or null.
-
getThrowable
public java.lang.Throwable getThrowable()
Description copied from interface:MessageGets the throwable, if any.- Specified by:
getThrowablein interfaceMessage- Returns:
- the throwable or null.
-
getMessage
public Message getMessage()
Description copied from interface:FlowMessageThe wrapped message- Specified by:
getMessagein interfaceFlowMessage- Returns:
- the wrapped message
-
getText
public java.lang.String getText()
Description copied from interface:FlowMessageThe message text like "Enter" or "Exit" used to prefix the actual Message.- Specified by:
getTextin interfaceFlowMessage- Returns:
- message text used to prefix the actual Message.
-
formatTo
public void formatTo(java.lang.StringBuilder buffer)
Description copied from interface:StringBuilderFormattableWrites a text representation of this object into the specifiedStringBuilder, ideally without allocating temporary objects.- Specified by:
formatToin interfaceStringBuilderFormattable- Parameters:
buffer- the StringBuilder to write into
-
-