Class BaseMessageFormatter

    • Method Detail

      • appendFormattedMessage

        @CanIgnoreReturnValue
        public static StringBuilder appendFormattedMessage​(LogData data,
                                                           StringBuilder out)
        Appends the formatted log message of the given log data to the given buffer.

        Note that the LogData need not have a template context or arguments, it might just have a literal argument, which will be appended without additional formatting.

        Parameters:
        data - the log data with the message to be appended.
        out - a buffer to append to.
        Returns:
        the given buffer (for method chaining).
      • addParameterImpl

        public void addParameterImpl​(int termStart,
                                     int termEnd,
                                     Parameter param)
        Description copied from class: MessageBuilder
        Adds the specified parameter to the format instance currently being built. This method is to signify that the parsing of the next parameter is complete.

        Note that each successive call to this method during parsing will specify a disjoint ranges of characters from the log message and that each range will be higher that the previously specified one.

        Specified by:
        addParameterImpl in class MessageBuilder<StringBuilder>
        Parameters:
        termStart - the index of the first character in the log message string that was parsed to form the given parameter.
        termEnd - the index after the last character in the log message string that was parsed to form the given parameter.
        param - a parameter representing the format specified by the substring of the log message in the range [termStart, termEnd).
      • visit

        public void visit​(Object value,
                          FormatChar format,
                          FormatOptions options)
        Description copied from interface: ParameterVisitor
        Visits a log message argument with formatting specified by %s, %d etc...

        Note that this method may still visit arguments which represent date/time values if the format is not explicit (e.g. log("time=%s", dateTime)).

        Specified by:
        visit in interface ParameterVisitor
        Parameters:
        value - the non-null log message argument.
        format - the printf format specifier.
        options - formatting options.
      • visitDateTime

        public void visitDateTime​(Object value,
                                  DateTimeFormat format,
                                  FormatOptions options)
        Description copied from interface: ParameterVisitor
        Visits a date/time log message argument with formatting specified by %t or similar.

        Note that because this method is called based on the specified format (and not the argument type) it may visit arguments whose type is not a known date/time value. This is necessary to permit new date/time types to be supported by different logging backends (e.g. JodaTime).

        Specified by:
        visitDateTime in interface ParameterVisitor
        Parameters:
        value - the non-null log message argument.
        format - the date/time format specifier.
        options - formatting options.
      • visitPreformatted

        public void visitPreformatted​(Object value,
                                      String formatted)
        Description copied from interface: ParameterVisitor
        Visits a log message argument for which formatting has already occurred. This method is only invoked when non-printf message formatting is used (e.g. brace style formatting).

        This method is intended for use by Parameter implementations which describe formatting rules which cannot by represented by either FormatChar or DateTimeFormat. This method discards formatting and type information, and the visitor implementation may choose to reexamine the type of the original argument if doing structural logging.

        Specified by:
        visitPreformatted in interface ParameterVisitor
        Parameters:
        value - the original non-null log message argument.
        formatted - the formatted representation of the argument
      • visitMissing

        public void visitMissing()
        Description copied from interface: ParameterVisitor
        Visits a missing argument. This method is called when there is no corresponding value for the parameter's argument index.
        Specified by:
        visitMissing in interface ParameterVisitor