Filters within Logger++ were developed with the intention of being highly customisable and therefore may be as simple or complex as you require. Once a filter has been entered, the color of the input field will change to reflect the validity of the filter.
With the new parser, fields have been separated into three groups: Proxy, Request and Response. A list of fields and their group can be found here.
When using a field within a filter, the format used is GROUP.FIELD.
E.g. Request.Method, Response.Length, Proxy.Tool
== – Equal, valid on all fields.
!= – Not Equal, valid on all fields.
< – Less Than, only valid on numeric fields (Integer, Short, Date, …)
> – Greater Than, only valid on numeric fields (Integer, Short, Date, …)
<= – Less Than Or Equal, only valid on numeric fields (Integer, Short, Date, …)
>= – Greater Than Or Equal, only valid on numeric fields (Integer, Short, Date, …)
In addition to the basic boolean operators above, some additional operators have been added.
CONTAINS – True if value is found anywhere in the string
Request.Body CONTAINS “SEARCHVALUE”
IN – True if value is found within the provided array
Response.InferredType IN [“JSON”, “HTML”, “XML”]
MATCHES – True if value matches the provided regular expression
Request.Path MATCHES “/api/(account|payments)/.*”
Note: The matches operation expects the entire string to match the expression. To match values which contain the pattern anywhere in the string, either include wildcard matches at the start and end of the pattern as below, or see the Regular Expressions section.
Multiple filters can be combined into compound filters using the following operators.
&&, AND – True only if all components evaluate to true.
||, OR – True if any one of the components evaluates to true.
^, XOR – True only if components differ in evaluation result.
Note: Compound operations cannot be mixed without explicitly specifying order of precedence using parenthesis.
Request.Body == “A” AND Response.Status == 200 OR Response.Status == 302 – Invalid
Request.Body == “A” AND ( Response.Status == 200 OR Response.Status == 302 ) – Valid
Sometimes, you may wish to match only entries which do not match a certain filter. This can be achieved by wrapping the section of the filter to negate like follows.
!( Request.Body CONTAINS “CSRF” )
In addition to the MATCHES operator, regular expressions can also be used with the == and != operators. Where the MATCHES operator requires the entire string to match the expression, this operator will return true if a match is found anywhere within the string.
To use regex with the == and != operators, simply wrap the regular expression with forward slashes: /regex/
Request.QueryParams == /u?id=0/
Aliases are reusable filter snippets which can be used in both log and color filters. For example, you may wish to define an alias for POST requests without a CSRF parameter.
The “Filter Library” tab of the extension can be used to view and manage the available aliases, to add an alias, click the ‘Add Snippet’ button at the bottom of the panel, add your snippet and set an appropriate alias for it. To use a defined alias in a log or color filter, prefix the alias name with the # symbol as shown in the below examples.
Response.Status == 200 OR #ALIAS_NAME
!( #ALIAS_NAME )
In addition to standard filters, color filters can be set by clicking the ‘Colorize’ button in the main tab. To add a filter press the add button and enter a filter as above, and optionally set the title, foreground and background colors. Changes can be observed instantly.
Tips and Tricks
Filters can be generated by right clicking a log entry field, or right clicking within a request / response viewer with selected text.
Right-clicking in the main filter text box will show a dropdown list of the available fields to be used.
Visit the project on GitHub here