Class PopulateAuditContext

    • Field Detail

      • log

        @Nonnull
        private final org.slf4j.Logger log
        Class logger.
      • fieldsToExtract

        @Nonnull
        @NonnullElements
        private Set<String> fieldsToExtract
        Fields being audited, to optimize extraction..
      • fieldReplacements

        @Nonnull
        private Map<String,​String> fieldReplacements
        Map allowing substitutions of values during field extraction.
      • dateTimeFormatter

        @Nonnull
        private DateTimeFormatter dateTimeFormatter
        Formatter for date/time fields.
      • useDefaultTimeZone

        private boolean useDefaultTimeZone
        Convert date/time fields to default time zone.
      • clearAuditContext

        private boolean clearAuditContext
        Flag signalling to clear context on entry.
    • Constructor Detail

      • PopulateAuditContext

        public PopulateAuditContext()
        Constructor.
    • Method Detail

      • setFormattingMapParser

        public void setFormattingMapParser​(@Nonnull
                                           PopulateAuditContext.FormattingMapParser parser)
        Set the parsed map of logging category to formatting strings for log entries.

        A formatting string consists of tokens prefixed by '%' separated by any non-alphanumeric or whitespace. Tokens can contain any letter or number or a hyphen. Anything other than a token, including whitespace, is a literal.

        The input class exposes the parsed field data for efficiency.

        Parameters:
        parser - the parsed map
      • setFieldReplacements

        public void setFieldReplacements​(@Nullable
                                         Map<String,​String> map)
        Set the map of field values to replace, and the replacement values.
        Parameters:
        map - map of replacements
      • setDateTimeFormat

        public void setDateTimeFormat​(@Nullable @NotEmpty
                                      String format)
        Set the formatting string to apply when extracting date/time fields.
        Parameters:
        format - formatting string
      • setUseDefaultTimeZone

        public void setUseDefaultTimeZone​(boolean flag)
        Convert date/time fields to default time zone.
        Parameters:
        flag - flag to set
      • setClearAuditContext

        public void setClearAuditContext​(boolean flag)
        Sets whether to clear any existing fields from the audit context.

        Defaults to false.

        Parameters:
        flag - flag to set
        Since:
        4.3.0
      • addField

        private void addField​(@Nonnull @NotEmpty
                              String key,
                              @Nullable
                              Object value)
        Add a non-null field to the audit record.
        Parameters:
        key - field label
        value - value to add