Package io.spine.logging.flogger.parser
Class PrintfMessageParser
- java.lang.Object
-
- io.spine.logging.flogger.parser.MessageParser
-
- io.spine.logging.flogger.parser.PrintfMessageParser
-
- Direct Known Subclasses:
DefaultPrintfMessageParser
public abstract class PrintfMessageParser extends MessageParser
A specializedMessageParserfor processing log messages in printf style, as used byString.format(java.lang.String, java.lang.Object...). This is an abstract parser which knows how to process and extract placeholder terms at a high level, but does not impose its own semantics for place-holder types.Typically you should not subclass this class, but instead subclass
DefaultPrintfMessageParser, which provides compatibility withString.format(java.lang.String, java.lang.Object...).- See Also:
- Original Java code of Google Flogger
-
-
Field Summary
-
Fields inherited from class io.spine.logging.flogger.parser.MessageParser
MAX_ARG_COUNT
-
-
Constructor Summary
Constructors Constructor Description PrintfMessageParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <T> voidparseImpl(MessageBuilder<T> builder)Abstract parse method implemented by specific subclasses to modify parsing behavior.voidunescape(StringBuilder out, String message, int start, int end)Appends the unescaped literal representation of the given message string (assumed to be escaped according to this parser's escaping rules).
-
-
-
Method Detail
-
unescape
public final void unescape(StringBuilder out, String message, int start, int end)
Description copied from class:MessageParserAppends the unescaped literal representation of the given message string (assumed to be escaped according to this parser's escaping rules). This method is designed to be invoked from a callback method in aMessageBuilderinstance.- Specified by:
unescapein classMessageParser- Parameters:
out- the destination into which to append charactersmessage- the escaped log messagestart- the start index (inclusive) in the log messageend- the end index (exclusive) in the log message
-
parseImpl
protected final <T> void parseImpl(MessageBuilder<T> builder) throws ParseException
Description copied from class:MessageParserAbstract parse method implemented by specific subclasses to modify parsing behavior.Note that when extending parsing behavior, it is expected that specific parsers such as
DefaultPrintfMessageParserorDefaultBraceStyleMessageParserwill be sub-classed. Extending this class directly is only necessary when an entirely new type of format needs to be supported (which should be extremely rare).Implementations of this method are required to invoke the
MessageBuilder.addParameterImpl(int, int, io.spine.logging.flogger.parameter.Parameter)method of the supplied builder once for each parameter place-holder in the message.- Specified by:
parseImplin classMessageParser- Throws:
ParseException
-
-