keybase / keybase/keybase-issues

Logging output changes when printed to terminal vs piped to command

Open
#2,853 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
899
Forks
40
PR merge metrics
No merged PRs in 30d

Description

I'm not sure what logging library is in use, but I was stymied for a while trying to grep some output.

I was running `keybase pgp pull` and a lot of the output is like:

```
▶ WARNING Keybase says that {user} owns key {fingerprint}, but you have not tracked this fingerprint before.
▶ WARNING Keybase says that {user} owns key {fingerprint}, but you have not tracked this fingerprint before.
▶ WARNING Keybase says that {user} owns key {fingerprint}, but you have not tracked this fingerprint before.
```

So I tried `keybase pgp pull | grep WARNING`, which matched no output. After a while of checking if the output was actually going to STDERR or STDOUT and sanity checking my trivial use of `grep`, I finally just tried piping to less:

```
$ keybase pgp pull 2>&1 | less
2017-02-16T17:58:16.205170 ▶ [WARN keybase log.go:34] ...
...
```

So whatever logging library that keybase is using apparently detects if the output is going to terminal or a pipe and actually _changes_ the output. Which is necessary for de-colorizing the output, sure. But changing the actual text makes scripting a lot more difficult than it ought to be.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running `keybase pgp pull` both directly and through a pipe, then trace the logging path used by that command to identify where terminal formatting changes the message text. Done means piped output remains scriptable and the warning text is consistent, while terminal-specific formatting can still be handled separately.

Written by the indexing model from the issue text.

Assessment

Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.