Class LogEntry

java.lang.Object
org.mockserver.log.model.LogEntry
All Implemented Interfaces:
com.lmax.disruptor.EventTranslator<LogEntry>

public class LogEntry extends Object implements com.lmax.disruptor.EventTranslator<LogEntry>
Author:
jamesdbloom
  • Field Details

    • LOG_DATE_FORMAT

      public static final LogEntry.LogDateFormat LOG_DATE_FORMAT
      Thread-safe replacement for the previous shared SimpleDateFormat.

      SimpleDateFormat is NOT thread-safe; this single static instance was formatted concurrently from the Disruptor log handler and the retrieve/export/serialize threads, which can corrupt its internal Calendar and produce garbled timestamps or an intermittent ArrayIndexOutOfBoundsException. DateTimeFormatter is immutable and thread-safe, so a single shared instance is safe to format from any number of threads. The pattern and the system-default zone reproduce exactly the same output the old SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS") (which used the default zone) produced, so timestamp strings remain byte-for-byte identical.

  • Constructor Details

    • LogEntry

      public LogEntry()
  • Method Details

    • estimatedHeapSize

      public long estimatedHeapSize()
      Stable lower-bound estimate of the bytes this entry retains on the heap, counting only the primary request/response body bytes (the dominant cost for large LLM-capture exchanges). It deliberately ignores the lazily-derived httpUpdated* copies and the arguments array so the value never changes after the entry is built — the byte-budget eviction relies on the add-time weight matching the evict-time weight exactly. Reads the httpRequests field directly (not getHttpRequests(), which substitutes a default request when unset).
    • id

      public String id()
    • clear

      public void clear()
    • getLogLevel

      public org.slf4j.event.Level getLogLevel()
    • setLogLevel

      public LogEntry setLogLevel(org.slf4j.event.Level logLevel)
    • isAlwaysLog

      public boolean isAlwaysLog()
    • setAlwaysLog

      public LogEntry setAlwaysLog(boolean alwaysLog)
    • getEpochTime

      public long getEpochTime()
    • setEpochTime

      public LogEntry setEpochTime(long epochTime)
    • getTimestamp

      public String getTimestamp()
    • getType

      public LogEntry.LogMessageType getType()
    • setType

      public LogEntry setType(LogEntry.LogMessageType type)
    • getCorrelationId

      public String getCorrelationId()
    • setCorrelationId

      public LogEntry setCorrelationId(String correlationId)
    • setPort

      public LogEntry setPort(Integer port)
    • getPort

      public Integer getPort()
    • getHttpRequests

      public RequestDefinition[] getHttpRequests()
    • getHttpUpdatedRequests

      public RequestDefinition[] getHttpUpdatedRequests()
    • getHttpUpdatedRequests

      public RequestDefinition[] getHttpUpdatedRequests(Configuration configuration)
      As getHttpUpdatedRequests() but consulting configuration for redactSecretsInLog, so redaction enabled on a Configuration instance (including via PUT /mockserver/configuration) applies to the dashboard and the JSON log-message surface. Falls back to the static store when configuration is null.

      NOTE the result is memoised on first call, so toggling redaction after an entry has already been rendered does not retroactively change that entry.

      Parameters:
      configuration - the effective server configuration (may be null)
    • getRedactedHttpRequests

      public RequestDefinition[] getRedactedHttpRequests()
      Like getHttpRequests() but with sensitive headers / configured JSON body fields masked when mockserver.redactSecretsInLog is enabled. Unlike getHttpUpdatedRequests() this does NOT apply body templating (updateBody), so when redaction is off it returns the raw requests byte-for-byte unchanged — it is the redaction-aware view for the retrieveRecordedRequests / export paths, which must otherwise preserve the captured request exactly.
    • getRedactedHttpRequests

      public RequestDefinition[] getRedactedHttpRequests(Configuration configuration)
      Parameters:
      configuration - the effective server configuration, consulted for redactSecretsInLog (may be null, in which case the static store is used)
      See Also:
    • getRedactedHttpRequest

      public RequestDefinition getRedactedHttpRequest()
      Like getHttpRequest() but with sensitive data masked when mockserver.redactSecretsInLog is enabled; returns the raw request unchanged when redaction is off. Used by the retrieveRecordedRequestsAndResponses path.
    • getRedactedHttpRequest

      public RequestDefinition getRedactedHttpRequest(Configuration configuration)
      Parameters:
      configuration - the effective server configuration (may be null)
      See Also:
    • getRedactedHttpResponse

      public HttpResponse getRedactedHttpResponse()
      Like getHttpResponse() but with sensitive data masked when mockserver.redactSecretsInLog is enabled; returns the raw response unchanged when redaction is off. Used by the retrieveRecordedRequestsAndResponses path.
    • getRedactedHttpResponse

      public HttpResponse getRedactedHttpResponse(Configuration configuration)
      Parameters:
      configuration - the effective server configuration (may be null)
      See Also:
    • matches

      public boolean matches(HttpRequestMatcher matcher)
    • setHttpRequests

      public LogEntry setHttpRequests(RequestDefinition[] httpRequests)
    • getHttpRequest

      public RequestDefinition getHttpRequest()
    • setHttpRequest

      public LogEntry setHttpRequest(RequestDefinition httpRequest)
    • getHttpResponse

      public HttpResponse getHttpResponse()
    • getHttpUpdatedResponse

      public HttpResponse getHttpUpdatedResponse()
    • getHttpUpdatedResponse

      public HttpResponse getHttpUpdatedResponse(Configuration configuration)
      As getHttpUpdatedResponse() but consulting configuration for redactSecretsInLog. Memoised on first call, as above.
      Parameters:
      configuration - the effective server configuration (may be null)
    • setHttpResponse

      public LogEntry setHttpResponse(HttpResponse httpResponse)
    • getHttpError

      public HttpError getHttpError()
    • setHttpError

      public LogEntry setHttpError(HttpError httpError)
    • getExpectation

      public Expectation getExpectation()
    • setExpectation

      public LogEntry setExpectation(Expectation expectation)
    • setExpectation

      public LogEntry setExpectation(RequestDefinition httpRequest, HttpResponse httpResponse)
    • getExpectationId

      public String getExpectationId()
    • setExpectationId

      public LogEntry setExpectationId(String expectationId)
    • matchesAnyExpectationId

      public boolean matchesAnyExpectationId(List<String> expectationIds)
    • getThrowable

      public Throwable getThrowable()
    • setThrowable

      public LogEntry setThrowable(Throwable throwable)
    • getConsumer

      public Runnable getConsumer()
    • setConsumer

      public LogEntry setConsumer(Runnable consumer)
    • isDeleted

      public boolean isDeleted()
    • setDeleted

      public LogEntry setDeleted(boolean deleted)
    • isSkipRecordedRequestPersistence

      public boolean isSkipRecordedRequestPersistence()
    • setSkipRecordedRequestPersistence

      public LogEntry setSkipRecordedRequestPersistence(boolean skipRecordedRequestPersistence)
    • getMessageFormat

      public String getMessageFormat()
    • setMessageFormat

      public LogEntry setMessageFormat(String messageFormat)
    • getMessage

      public String getMessage()
    • getCompactMessage

      public String getCompactMessage()
    • getArguments

      public Object[] getArguments()
    • setArguments

      public LogEntry setArguments(Object... arguments)
    • getBecause

      public String getBecause()
    • setBecause

      public LogEntry setBecause(String because)
    • cloneAndClear

      public LogEntry cloneAndClear()
    • clone

      public LogEntry clone()
      Overrides:
      clone in class Object
    • translateTo

      public void translateTo(LogEntry event, long sequence)
      Specified by:
      translateTo in interface com.lmax.disruptor.EventTranslator<LogEntry>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object