Fix errors from logging regexes in JSON

Errors were being thrown on queries using LIKE or ILIKE because they use regexes internally and that was being encoded as JSON in the log. There is no regex in JSON, so I told it to convert the regex to a string before encoding. Alternatively, we could not encode the query as JSON when logging it, which is less complicated.