-
Notifications
You must be signed in to change notification settings - Fork 954
Description
Ref #573, #565, #553, #456, #453, #402, #578, #526, #525, #488
Right now it's very clear that debug
takes a subjective stance on its output format. This is unsuitable for a variety of use-cases, especially the disparity between the isatty(2) == 0
and == 1
cases.
Let's figure out how to solve this.
My initial knee-jerk idea would be to introduce a DEBUG_FORMAT
environment variable. It would accept a string with delimiters similar to date-time or printf formats that indicate different elements of a debug log.
This would also remove the need for a plethora of custom environment variables that have been proposed.
We'd have a default format that would then be the same between interactive/non-interactive TTY sessions (fd 2, as always).
This would look something like
DEBUG_FORMAT="%N %m %D"
Where %N
is the namespace (colored if interactive terminal), %m
is the message and %D
is the time diff - the exact format in the screenshot in the readme.
Of course there would be other delimiters available, and the above doesn't necessarily need to be the default, but it would solve pretty much any use-case imaginable regarding the output format in a non-subjective manner.
That's just my personal proposal, but this RFC is after any solution, so if you have a different idea please sound off below.
Activity
48 remaining items
the0neWhoKnocks commentedon Oct 12, 2020
Just curious what sort of progress has been made on this. I see it's on the list for the 5.x milestone. It would be a really nice feature to be able to use.
Joshfindit commentedon Mar 21, 2021
I'm honestly only in this thread because I want
debug
to stop automatically returning seconds and instead always return milliseconds.It's easy to miss that one call took 1000x longer.
Qix- commentedon Mar 21, 2021
@Joshfindit the problem there is that sometimes events don't happen for hours at a time. Millisecond triviality goes out the window at that scale. Hence why we use
ms
. But I understand if not everyone wants that behavior.Joshfindit commentedon Mar 21, 2021
@Qix- It’s your package, it’s bot for me to tell you what’s right for you or other users, that’s just why I’m here. Custom output will let me accomplish it.
DimitarNestorov commentedon Sep 14, 2021
Same. Here's a solution:
Qix- commentedon Sep 14, 2021
Yep @DimitarNestorov's way is currently the "official" way of doing it and is entirely acceptable.
ajorpheus commentedon Dec 2, 2022
If you stumble across this issue while trying to enable timestamps for GHA log, here is the good bit:
GitHub Actions now provides timestamps by default with "shift + T" in the logs.
Merge remote-tracking branch 'origin/format'
dmatora commentedon Mar 24, 2023
@SCG82 when I try to do that, name and useColors are undefined
doesn't it require
debug.formatArgs = formatArgs.bind(debug)
or something (which isn't works as well?Download commentedon Apr 20, 2023
jmrossy commentedon Oct 10, 2023
In case anyone needs to strip the output format down to just the content, this worked for me: