BaseMessageFormatter

public class BaseMessageFormatter extends MessageBuilder<T> implements ParameterVisitor

The default formatter for log messages and arguments.

This formatter can be overridden to modify the behaviour of the ParameterVisitor methods, but this is not expected to be common. Most logger backends will only ever need to use appendFormattedMessage.

See also

<a href="https://github.com/google/flogger/blob/cb9e836a897d36a78309ee8badf5cad4e6a2d3d8/api/src/main/java/com/google/common/flogger/backend/BaseMessageFormatter.java">

Original Java code of Google Flogger

Constructors

Link copied to clipboard
protected void BaseMessageFormatter(TemplateContext context, Array<Object> args, StringBuilder out)

Properties

Link copied to clipboard
protected final Array<Object> args
Link copied to clipboard
protected final StringBuilder out

Functions

Link copied to clipboard
public void addParameterImpl(int termStart, int termEnd, Parameter param)
Adds the specified parameter to the format instance currently being built.
Link copied to clipboard
@CanIgnoreReturnValue()
public static StringBuilder appendFormattedMessage(LogData data, StringBuilder out)
Appends the formatted log message of the given log data to the given buffer.
Link copied to clipboard
Returns the implementation specific result of parsing the current log message.
Link copied to clipboard
public void visit(Object value, FormatChar format, FormatOptions options)
Visits a log message argument with formatting specified by %s, %d etc...
Link copied to clipboard
public void visitDateTime(Object value, DateTimeFormat format, FormatOptions options)
Visits a date/time log message argument with formatting specified by %t or similar.
Link copied to clipboard
public void visitMissing()
Visits a missing argument.
Link copied to clipboard
public void visitNull()
Visits a null argument.
Link copied to clipboard
public void visitPreformatted(Object value, String formatted)
Visits a log message argument for which formatting has already occurred.

Inherited functions

Link copied to clipboard
public final void addParameter(int termStart, int termEnd, Parameter param)
Called by parser implementations to signify that the parsing of the next parameter is complete.
Link copied to clipboard
public final T build()
Builds a log message using the current message context.
Link copied to clipboard
public final int getExpectedArgumentCount()
Returns the expected number of arguments to be formatted by this message.
Link copied to clipboard
public final String getMessage()
Returns the log format message to be parsed by this builder.
Link copied to clipboard
public final MessageParser getParser()
Returns the parser used to process the log format message in this builder.