log error details at debug level #35

Merged
merged 1 commit into from Apr 7, 2016
Jump to file or symbol
Failed to load files and symbols.
+3 −1
Split
View
@@ -9,6 +9,7 @@ import (
"sort"
"strings"
+ "github.com/juju/errors"
"github.com/juju/loggo"
"launchpad.net/gnuflag"
)
@@ -446,6 +447,7 @@ func (c *SuperCommand) Run(ctx *Context) error {
err := c.action.command.Run(ctx)
if err != nil && !IsErrSilent(err) {
logger.Errorf("%v", err)
+ logger.Debugf("(error details: %v)", errors.Details(err))
// Now that this has been logged, don't log again in cmd.Main.
if !IsRcPassthroughError(err) {
err = ErrSilent
View
@@ -258,7 +258,7 @@ func (s *SuperCommandSuite) TestLogging(c *gc.C) {
ctx := cmdtesting.Context(c)
code := cmd.Main(sc, ctx, []string{"blah", "--option", "error", "--debug"})
c.Assert(code, gc.Equals, 1)
- c.Assert(bufferString(ctx.Stderr), gc.Matches, `^.* ERROR .* BAM!\n`)
+ c.Assert(bufferString(ctx.Stderr), gc.Matches, `^.* ERROR .* BAM!\n.* DEBUG .* \(error details.*\).*\n`)
}
func (s *SuperCommandSuite) TestNotifyRun(c *gc.C) {