code: public static void format(LogData logData, SimpleLogHandler receiver) {
      Metadata metadata = logData.getMetadata();
      Throwable thrown = metadata.findValue(LogContext.Key.LOG_CAUSE);
      // Either no metadata, or exactly one "cause" means we don't need to do additional formatting.
      // This is pretty common and will save some work and object allocations.
      boolean hasOnlyKnownMetadata = metadata.size() == 0 || (metadata.size() == 1 && thrown != null);
  
      TemplateContext ctx = logData.getTemplateContext();
      String message;
      if (ctx == null) {
        // If a literal message (no arguments) is logged and no metadata exists, just use the string.
        // Having no format arguments is fairly common and this avoids allocating StringBuilders and
        // formatter instances in a lot of situations.
        message = safeToString(logData.getLiteralArgument());
        if (!hasOnlyKnownMetadata) {
          // If unknown metadata exists we have to append it to the message (this is not that common
          // because a Throwable "cause" is already handled separately).
          message = appendContext(new StringBuilder(message), metadata);
        }
      } else {
        StringBuilder buffer = formatMessage(logData);
        message = hasOnlyKnownMetadata ? buffer.toString() : appendContext(buffer, metadata);
      }
      receiver.handleFormattedLogMessage(logData.getLevel(), message, thrown);
    }
docs: Formats the log message and any metadata for the given {@link LogData}, calling the supplied
  receiver object with the results.