本文整理匯總了Golang中github.com/juju/loggo.ResetLoggers函數的典型用法代碼示例。如果您正苦於以下問題:Golang ResetLoggers函數的具體用法?Golang ResetLoggers怎麽用?Golang ResetLoggers使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ResetLoggers函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SetUpTest
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)
}
示例2: SetUpTest
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)
}
示例3: SetUpTest
func (s *LogSuite) SetUpTest(c *gc.C) {
s.CleanupSuite.SetUpTest(c)
s.AddCleanup(func(_ *gc.C) {
loggo.ResetLoggers()
loggo.ResetWriters()
})
}
示例4: setUp
func (s *LoggingSuite) setUp(c *gc.C) {
loggo.ResetWriters()
loggo.ReplaceDefaultWriter(&gocheckWriter{c})
loggo.ResetLoggers()
err := loggo.ConfigureLoggers(logConfig)
c.Assert(err, gc.IsNil)
}
示例5: SetUpTest
func (s *LogSuite) SetUpTest(c *gc.C) {
s.CleanupSuite.SetUpTest(c)
s.PatchEnvironment(osenv.JujuLoggingConfigEnvKey, "")
s.AddCleanup(func(_ *gc.C) {
loggo.ResetLoggers()
loggo.ResetWriters()
})
}
示例6: SetUpSuite
func (t *LoggingSuite) SetUpSuite(c *gc.C) {
t.CleanupSuite.SetUpSuite(c)
t.setUp(c)
t.AddSuiteCleanup(func(*gc.C) {
loggo.ResetLoggers()
loggo.ResetWriters()
})
}
示例7: SetUpTest
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)
}
示例8: setUp
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)
}
示例9: SetUpTest
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)
}
示例10: TestInitialState
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)
}
示例11: SetUpTest
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)
}
示例12: setLogging
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
}
}
}
示例13: TestConfigureLoggers
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)
}
}
示例14: SetUpTest
func (*auditSuite) SetUpTest(c *gc.C) {
loggo.ResetLoggers()
loggo.ResetWriters()
err := loggo.ConfigureLoggers(`<root>=ERROR; audit=INFO`)
c.Assert(err, jc.ErrorIsNil)
}
示例15: SetUpTest
func (s *ConfigSuite) SetUpTest(c *gc.C) {
s.FakeJujuHomeSuite.SetUpTest(c)
// Make sure that the defaults are used, which
// is <root>=WARNING
loggo.ResetLoggers()
}