func (s *logSuite) TestFlagSet(c *gc.C) { s.SetFeatureFlags(feature.LogErrorStack) err := errors.New("test error") err2 := utils.LoggedErrorStack(err) c.Assert(err, gc.Equals, err2) expected := "ERROR juju.utils error stack:\ntest error" c.Assert(c.GetTestLog(), jc.Contains, expected) }
func (p *environProvisioner) loop() error { var environConfigChanges <-chan struct{} environWatcher, err := p.st.WatchForEnvironConfigChanges() if err != nil { return utils.LoggedErrorStack(errors.Trace(err)) } environConfigChanges = environWatcher.Changes() defer watcher.Stop(environWatcher, &p.tomb) p.environ, err = worker.WaitForEnviron(environWatcher, p.st, p.tomb.Dying()) if err != nil { return utils.LoggedErrorStack(errors.Trace(err)) } p.broker = p.environ harvestMode := p.environ.Config().ProvisionerHarvestMode() task, err := p.getStartTask(harvestMode) if err != nil { return utils.LoggedErrorStack(errors.Trace(err)) } defer watcher.Stop(task, &p.tomb) for { select { case <-p.tomb.Dying(): return tomb.ErrDying case <-task.Dying(): err := task.Err() logger.Errorf("environ provisioner died: %v", err) return err case _, ok := <-environConfigChanges: if !ok { return watcher.EnsureErr(environWatcher) } environConfig, err := p.st.EnvironConfig() if err != nil { logger.Errorf("cannot load environment configuration: %v", err) return err } if err := p.setConfig(environConfig); err != nil { logger.Errorf("loaded invalid environment configuration: %v", err) } task.SetHarvestMode(environConfig.ProvisionerHarvestMode()) } } }
func (*logSuite) TestFlagNotSet(c *gc.C) { err := errors.New("test error") err2 := utils.LoggedErrorStack(err) c.Assert(err, gc.Equals, err2) c.Assert(c.GetTestLog(), gc.Equals, "") }