log/info removes quotes from strings making debugging harder than it needs to be.

Description

log/info removes quotes from strings making debugging harder than it needs to be. I found that {:test1 "", :test2 "2"} is logged as {:test1 , :test2 2}. I see the same issue when I print a map using println. prn prints the map with the quotes which is better for debugging.

I will make a patch and add it later.

Environment

None

Activity

Show:
import
August 28, 2017, 5:23 PM

Comment made by: tangrammer

Hi guys, I could avoid this annoying problem adding overwriting print-method for String type in my app code ... is it a convenient approach?

Ilmo Raunio
May 8, 2018, 2:13 PM

Attached is an alternative fix to the already proposed TLOG20.patch, where we use pr-str instead. This changeset allows for logged Clojure code to be compiler compliant when copypasted into a REPL (for example). The changeset affects the usage of logp and its derivatives.

This fix is necessary for easier debugging of production problems and, particularly, when a Clojure data entity is too large to do quote insertions manually.

Alexander Taggart
May 22, 2018, 12:12 PM

Despite the examples given, many real-world log entries contain not only structured data, but also human-readable explanatory text. As such, switching to always using `pr-str` will emit quotes and escaped characters when not desired, and with no way to work around it (unlike how one can work around the current issue by manually wrapping values with `pr-str`). This kind of breaking change is a no-go.

That said, it may be reasonable to add new macros to handle this common point of friction.

A variant of `logp` is problematic since in the common case of mixing text and data we can’t know for certain which args the user intends to be treated which way.

A variant of `logf` might work, whereby all format args are mapped over `pr-str`, with explanatory text residing in the format string.

Alexander Taggart
February 28, 2020, 1:26 AM

See the clojure.tools.logging.readable namespace in the 1.0.0 release.

Assignee

Alexander Taggart

Reporter

Lonnie Souder

Labels

None

Approval

None

Patch

None

Priority

Minor
Configure