github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/worker/provisioner/logging.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package provisioner
     5  
     6  import (
     7  	"github.com/juju/errors"
     8  	"github.com/juju/utils/featureflag"
     9  
    10  	"github.com/juju/juju/feature"
    11  )
    12  
    13  // loggedErrorStack is a developer helper function that will cause the error
    14  // stack of the error to be printed out at error severity if and only if the
    15  // "log-error-stack" feature flag has been specified.  The passed in error
    16  // is also the return value of this function.
    17  func loggedErrorStack(err error) error {
    18  	if featureflag.Enabled(feature.LogErrorStack) {
    19  		logger.Errorf("error stack:\n%s", errors.ErrorStack(err))
    20  	}
    21  	return err
    22  }