Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-1753

Improve logging for Predicates

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Done
    • Major
    • 2.2.0.Final
    • 2.1.3.Final
    • Predicate Language
    • None

    Description

      When using the predicate language, there is no debugging to speak of that lets you see

      • What predicates were processed for a request
      • What the result of each predicate was
      • What handlers ran in what order

      This request involves creating a new PREDICATE_LOGGER and has two main pieces:

      • Add logging to the PredicatesHandler and some select predicates such as regex or paths to trace the flow of execution
      • Create toString() methods to get useful text representations of all predicates, handlers, and exchange attributes commonly used in the predicate language

      The string representation closely matches the actual predicate language itself, so the logs should be very readable.  

      Example

      Given the following predicate rules:

      path-template('/foo/{bar}/{f}')->response-code(404)
      path-suffix(.env)->response-code(404)
      not regex( '.*\.(bmp|gif|jpe?g|png)' ) -> rewrite('/index.cfm%{RELATIVE_PATH}')
      

      And an incoming request to

      /main
      

      The sample logging output to the PREDICATE_LOGGER with "trace" level enabled would be:

      [TRACE] Predicate [path-template( '/foo/{bar}/{f}' )] resolved to false for HttpServerExchange{ GET /main}.
      [TRACE] Predicate [path-suffix( '.env' )] resolved to false for HttpServerExchange{ GET /main}.
      [TRACE] Predicate [ not regex( pattern='.*\.(bmp|gif|jpe?g|png)', value='%{RELATIVE_PATH}', full-match='false', case-sensitive='false' )] resolved to true. Next handler is [rewrite( '/index.cfm%{RELATIVE_PATH}' )] for HttpServerExchange{ GET /main}.
      [DEBUG] Request rewritten to [/index.cfm/main] for HttpServerExchange{ GET /main}.
      

      Attachments

        Activity

          People

            flaviarnn Flavia Rainone
            bdw429s Brad Wood
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: