Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Universal output redirection, more exit handling #35

Merged
merged 8 commits into from
Apr 13, 2015
Merged

Conversation

warpfork
Copy link
Member

All output from the CLI can now be shunted to any io.Writer. Tests can use this to check output. Right now, existing tests route everything to ioutil.Discard for lack of any useful assertions.

This cleans up all output leaking through test reports, making reading much more pleasant again.

Introduced new errors for user-facing messages, with graceful reporting for and a mechanism for custom exit codes, as well as a polite logging mechanism for unexpected errors.

Trading one junk drawer for another, to some extent (I hate code called "util"), but it does seem fair to say at least that none of this code will be used outside of executor implementations.

Signed-off-by: Eric Myhre <hash@exultant.us>
Signed-off-by: Eric Myhre <hash@exultant.us>
Signed-off-by: Eric Myhre <hash@exultant.us>
All tests toss output on the floor.  The real main message passes information to the user on os.Stderr.

Signed-off-by: Eric Myhre <hash@exultant.us>
Signed-off-by: Eric Myhre <hash@exultant.us>
This is the last thing that was pushing output out-of-place through our test harnesses!  Hooray!

Signed-off-by: Eric Myhre <hash@exultant.us>
Signed-off-by: Eric Myhre <hash@exultant.us>
fmt.Fprintf(logFile, "\n")
fmt.Fprintf(logFile, "Full error:\n")
fmt.Fprintf(logFile, "-----------\n")
fmt.Fprintf(logFile, "%s\n", caught)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Print the message without the stack?

@kofalt
Copy link
Member

kofalt commented Apr 13, 2015

LGTM for an initial overhaul.
We 'lose' the ability to print to stderr from the CLI, but we weren't doing that anyway, so...

This looks good until we get more aggressive about an output overhaul.

Simultaneously, add a little more data to the full form logs.  The structural serialization is often redundant... but occasionally adds some really useful precision.

Signed-off-by: Eric Myhre <hash@exultant.us>
@warpfork
Copy link
Member Author

Added a little more terseness for the default user facing message; should be better.

kofalt added a commit that referenced this pull request Apr 13, 2015
Universal output redirection, more exit handling
@kofalt kofalt merged commit 2df41a0 into master Apr 13, 2015
@kofalt kofalt deleted the silence-is-golden branch April 13, 2015 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants