func (s *ToolsMetadataSuite) SetUpTest(c *gc.C) { s.FakeJujuXDGDataHomeSuite.SetUpTest(c) s.AddCleanup(dummy.Reset) s.AddCleanup(func(*gc.C) { loggo.ResetLoggers() }) cfg, err := config.New(config.UseDefaults, map[string]interface{}{ "name": "erewhemos", "type": "dummy", "uuid": coretesting.ModelTag.Id(), "controller-uuid": coretesting.ModelTag.Id(), "conroller": true, }) c.Assert(err, jc.ErrorIsNil) env, err := environs.Prepare( modelcmd.BootstrapContextNoVerify(coretesting.Context(c)), jujuclienttesting.NewMemStore(), environs.PrepareParams{ ControllerName: cfg.Name(), BaseConfig: cfg.AllAttrs(), CloudName: "dummy", }, ) c.Assert(err, jc.ErrorIsNil) s.env = env loggo.GetLogger("").SetLogLevel(loggo.INFO) // Switch the default tools location. s.publicStorageDir = c.MkDir() s.PatchValue(&tools.DefaultBaseURL, s.publicStorageDir) }
func (s *writerSuite) SetUpTest(c *gc.C) { loggo.ResetLoggers() loggo.RemoveWriter("default") s.logger = loggo.GetLogger("test.writer") // Make it so the logger itself writes all messages. s.logger.SetLogLevel(loggo.TRACE) }
func (s *LogSuite) SetUpTest(c *gc.C) { s.CleanupSuite.SetUpTest(c) s.AddCleanup(func(_ *gc.C) { loggo.ResetLoggers() loggo.ResetWriters() }) }
func (s *LoggingSuite) setUp(c *gc.C) { loggo.ResetWriters() loggo.ReplaceDefaultWriter(&gocheckWriter{c}) loggo.ResetLoggers() err := loggo.ConfigureLoggers(logConfig) c.Assert(err, gc.IsNil) }
func (s *LogSuite) SetUpTest(c *gc.C) { s.CleanupSuite.SetUpTest(c) s.PatchEnvironment(osenv.JujuLoggingConfigEnvKey, "") s.AddCleanup(func(_ *gc.C) { loggo.ResetLoggers() loggo.ResetWriters() }) }
func (t *LoggingSuite) SetUpSuite(c *gc.C) { t.CleanupSuite.SetUpSuite(c) t.setUp(c) t.AddSuiteCleanup(func(*gc.C) { loggo.ResetLoggers() loggo.ResetWriters() }) }
func (s *logwriterSuite) SetUpTest(c *gc.C) { loggo.ResetLoggers() loggo.RemoveWriter("default") s.writer = &loggo.TestWriter{} err := loggo.RegisterWriter("test", s.writer, loggo.TRACE) c.Assert(err, gc.IsNil) s.logger = loggo.GetLogger("test.writer") // Make it so the logger itself writes all messages. s.logger.SetLogLevel(loggo.TRACE) }
func (s *LoggingSuite) setUp(c *gc.C) { loggo.ResetWriters() // Don't use the default writer for the test logging, which // means we can still get logging output from tests that // replace the default writer. loggo.ReplaceDefaultWriter(discardWriter{}) loggo.RegisterWriter("loggingsuite", &gocheckWriter{c}, loggo.TRACE) loggo.ResetLoggers() err := loggo.ConfigureLoggers(logConfig) c.Assert(err, gc.IsNil) }
func (s *ToolsMetadataSuite) SetUpTest(c *gc.C) { s.FakeJujuHomeSuite.SetUpTest(c) s.AddCleanup(func(*gc.C) { dummy.Reset() loggo.ResetLoggers() }) env, err := environs.PrepareFromName( "erewhemos", envcmd.BootstrapContextNoVerify(coretesting.Context(c)), configstore.NewMem()) c.Assert(err, jc.ErrorIsNil) s.env = env loggo.GetLogger("").SetLogLevel(loggo.INFO) // Switch the default tools location. s.publicStorageDir = c.MkDir() s.PatchValue(&tools.DefaultBaseURL, s.publicStorageDir) }
func (s *LoggerSuite) TestInitialState(c *gc.C) { config, err := s.State.EnvironConfig() c.Assert(err, jc.ErrorIsNil) expected := config.LoggingConfig() initial := "<root>=DEBUG;wibble=ERROR" c.Assert(expected, gc.Not(gc.Equals), initial) loggo.ResetLoggers() err = loggo.ConfigureLoggers(initial) c.Assert(err, jc.ErrorIsNil) loggingWorker, _ := s.makeLogger(c) defer worker.Stop(loggingWorker) s.waitLoggingInfo(c, expected) }
func (s *ToolsMetadataSuite) SetUpTest(c *gc.C) { s.LoggingSuite.SetUpTest(c) s.home = coretesting.MakeSampleHome(c) s.AddCleanup(func(*gc.C) { s.home.Restore() dummy.Reset() loggo.ResetLoggers() }) env, err := environs.PrepareFromName("erewhemos", coretesting.Context(c), configstore.NewMem()) c.Assert(err, gc.IsNil) s.env = env envtesting.RemoveAllTools(c, s.env) loggo.GetLogger("").SetLogLevel(loggo.INFO) // Switch the default tools location. s.publicStorageDir = c.MkDir() s.PatchValue(&tools.DefaultBaseURL, s.publicStorageDir) }
func (logger *Logger) setLogging() { loggingConfig, err := logger.api.LoggingConfig(logger.agentConfig.Tag()) if err != nil { log.Errorf("%v", err) } else { if loggingConfig != logger.lastConfig { log.Debugf("reconfiguring logging from %q to %q", logger.lastConfig, loggingConfig) loggo.ResetLoggers() if err := loggo.ConfigureLoggers(loggingConfig); err != nil { // This shouldn't occur as the loggingConfig should be // validated by the original Config before it gets here. log.Warningf("configure loggers failed: %v", err) // Try to reset to what we had before loggo.ConfigureLoggers(logger.lastConfig) } logger.lastConfig = loggingConfig } } }
func (*loggerSuite) TestConfigureLoggers(c *gc.C) { for i, test := range configureLoggersTests { c.Logf("test %d: %q", i, test.spec) loggo.ResetLoggers() err := loggo.ConfigureLoggers(test.spec) c.Check(loggo.LoggerInfo(), gc.Equals, test.info) if test.err != "" { c.Assert(err, gc.ErrorMatches, test.err) continue } c.Assert(err, gc.IsNil) // Test that it's idempotent. err = loggo.ConfigureLoggers(test.spec) c.Assert(err, gc.IsNil) c.Assert(loggo.LoggerInfo(), gc.Equals, test.info) // Test that calling ConfigureLoggers with the // output of LoggerInfo works too. err = loggo.ConfigureLoggers(test.info) c.Assert(err, gc.IsNil) c.Assert(loggo.LoggerInfo(), gc.Equals, test.info) } }
func (*auditSuite) SetUpTest(c *gc.C) { loggo.ResetLoggers() loggo.ResetWriters() err := loggo.ConfigureLoggers(`<root>=ERROR; audit=INFO`) c.Assert(err, jc.ErrorIsNil) }
func (s *ConfigSuite) SetUpTest(c *gc.C) { s.FakeJujuHomeSuite.SetUpTest(c) // Make sure that the defaults are used, which // is <root>=WARNING loggo.ResetLoggers() }
func (s *SignMetadataSuite) TearDownTest(c *gc.C) { loggo.ResetLoggers() }
func (s *LoggingSuite) TearDownSuite(c *gc.C) { loggo.ResetLoggers() loggo.ResetWriters() }
func (s *writerSuite) TearDownSuite(c *gc.C) { loggo.ResetLoggers() }
func (t *LoggingSuite) setUp(c *gc.C) { loggo.ResetWriters() loggo.ReplaceDefaultWriter(&gocheckWriter{c}) loggo.ResetLoggers() }
func (*loggerSuite) SetUpTest(c *gc.C) { loggo.ResetLoggers() }