Class AuditEventDefaultFormatter

java.lang.Object
com.puppycrawl.tools.checkstyle.AuditEventDefaultFormatter
All Implemented Interfaces:
AuditEventFormatter

public class AuditEventDefaultFormatter extends Object implements AuditEventFormatter
Represents the default formatter for log message. Default log message format is: [SEVERITY LEVEL] filePath:lineNo:columnNo: message. [CheckName] When the module id of the message has been set, the format is: [SEVERITY LEVEL] filePath:lineNo:columnNo: message. [ModuleId]
  • Field Details

    • LENGTH_OF_ALL_SEPARATORS

      private static final int LENGTH_OF_ALL_SEPARATORS
      Length of all separators.
      See Also:
    • SUFFIX

      private static final String SUFFIX
      Suffix of module names like FooCheck.
      See Also:
  • Constructor Details

    • AuditEventDefaultFormatter

      public AuditEventDefaultFormatter()
  • Method Details

    • format

      public String format(AuditEvent event)
      Description copied from interface: AuditEventFormatter
      Formats an event message.
      Specified by:
      format in interface AuditEventFormatter
      Parameters:
      event - audit event.
      Returns:
      string representation of event message.
    • initStringBuilderWithOptimalBuffer

      private static StringBuilder initStringBuilderWithOptimalBuffer(AuditEvent event, String severityLevelName)
      Returns the StringBuilder that should avoid StringBuffer.expandCapacity. bufferLength = fileNameLength + messageLength + lengthOfAllSeparators + + severityNameLength + checkNameLength. Method is excluded from pitest validation.
      Parameters:
      event - audit event.
      severityLevelName - severity level name.
      Returns:
      optimal StringBuilder.
    • getCheckShortName

      private static String getCheckShortName(AuditEvent event)
      Returns check name without 'Check' suffix.
      Parameters:
      event - audit event.
      Returns:
      check name without 'Check' suffix.