当前位置: 首页>>代码示例>>Golang>>正文


Golang loggo.LoggerInfo函数代码示例

本文整理汇总了Golang中github.com/juju/loggo.LoggerInfo函数的典型用法代码示例。如果您正苦于以下问题:Golang LoggerInfo函数的具体用法?Golang LoggerInfo怎么用?Golang LoggerInfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了LoggerInfo函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestConfigureLoggers

func (s *GlobalSuite) TestConfigureLoggers(c *gc.C) {
	err := loggo.ConfigureLoggers("testing.module=debug")
	c.Assert(err, gc.IsNil)
	expected := "<root>=WARNING;testing.module=DEBUG"
	c.Assert(loggo.DefaultContext().Config().String(), gc.Equals, expected)
	c.Assert(loggo.LoggerInfo(), gc.Equals, expected)
}
开发者ID:juju,项目名称:loggo,代码行数:7,代码来源:global_test.go

示例2: main

func main() {
	args := os.Args
	if len(args) > 1 {
		loggo.ConfigureLoggers(args[1])
	} else {
		fmt.Println("Add a parameter to configure the logging:")
		fmt.Println("E.g. \"<root>=INFO;first=TRACE\"")
	}
	fmt.Println("\nCurrent logging levels:")
	fmt.Println(loggo.LoggerInfo())
	fmt.Println("")

	rootLogger.Infof("Start of test.")

	FirstCritical("first critical")
	FirstError("first error")
	FirstWarning("first warning")
	FirstInfo("first info")
	FirstDebug("first debug")
	FirstTrace("first trace")

	loggo.ReplaceDefaultWriter(loggo.NewSimpleWriter(os.Stderr, &loggo.ColorFormatter{}))

	SecondCritical("second critical")
	SecondError("second error")
	SecondWarning("second warning")
	SecondInfo("second info")
	SecondDebug("second debug")
	SecondTrace("second trace")

}
开发者ID:njpatel,项目名称:loggo,代码行数:31,代码来源:main.go

示例3: main

func main() {
	args := os.Args
	if len(args) > 1 {
		loggo.ConfigureLoggers(args[1])
	} else {
		fmt.Println("Add a parameter to configure the logging:")
		fmt.Println("E.g. \"<root>=INFO;first=TRACE\"")
	}
	fmt.Println("\nCurrent logging levels:")
	fmt.Println(loggo.LoggerInfo())
	fmt.Println("")

	rootLogger.Infof("Start of test.")

	FirstCritical("first critical")
	FirstError("first error")
	FirstWarning("first warning")
	FirstInfo("first info")
	FirstTrace("first trace")

	SecondCritical("first critical")
	SecondError("first error")
	SecondWarning("first warning")
	SecondInfo("first info")
	SecondTrace("first trace")

}
开发者ID:chadqueen,项目名称:swfsm,代码行数:27,代码来源:main.go

示例4: NewLogger

// NewLogger returns a worker.Worker that uses the notify watcher returned
// from the setup.
func NewLogger(api *logger.State, agentConfig agent.Config) worker.Worker {
	logger := &Logger{
		api:         api,
		agentConfig: agentConfig,
		lastConfig:  loggo.LoggerInfo(),
	}
	log.Debugf("initial log config: %q", logger.lastConfig)
	return worker.NewNotifyWorker(logger)
}
开发者ID:imoapps,项目名称:juju,代码行数:11,代码来源:logger.go

示例5: NewLogger

// NewLogger returns a worker.Worker that uses the notify watcher returned
// from the setup.
func NewLogger(api *logger.State, agentConfig agent.Config) (worker.Worker, error) {
	logger := &Logger{
		api:         api,
		agentConfig: agentConfig,
		lastConfig:  loggo.LoggerInfo(),
	}
	log.Debugf("initial log config: %q", logger.lastConfig)
	w, err := watcher.NewNotifyWorker(watcher.NotifyConfig{
		Handler: logger,
	})
	if err != nil {
		return nil, errors.Trace(err)
	}
	return w, nil
}
开发者ID:exekias,项目名称:juju,代码行数:17,代码来源:logger.go

示例6: 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)
	}
}
开发者ID:njpatel,项目名称:loggo,代码行数:24,代码来源:logger_test.go

示例7: waitLoggingInfo

func (s *LoggerSuite) waitLoggingInfo(c *gc.C, expected string) {
	timeout := time.After(worstCase)
	for {
		select {
		case <-timeout:
			c.Fatalf("timeout while waiting for logging info to change")
		case <-time.After(10 * time.Millisecond):
			loggerInfo := loggo.LoggerInfo()
			if loggerInfo != expected {
				c.Logf("logging is %q, still waiting", loggerInfo)
				continue
			}
			return
		}
	}
}
开发者ID:felicianotech,项目名称:juju,代码行数:16,代码来源:logger_test.go

示例8: ensureUnitLogging

func (c *Config) ensureUnitLogging() error {
	loggingConfig := c.asString("logging-config")
	// If the logging config hasn't been set, then look for the os environment
	// variable, and failing that, get the config from loggo itself.
	if loggingConfig == "" {
		if environmentValue := os.Getenv(osenv.JujuLoggingConfigEnvKey); environmentValue != "" {
			loggingConfig = environmentValue
		} else {
			loggingConfig = loggo.LoggerInfo()
		}
	}
	levels, err := loggo.ParseConfigString(loggingConfig)
	if err != nil {
		return err
	}
	// If there is is no specified level for "unit", then set one.
	if _, ok := levels["unit"]; !ok {
		loggingConfig = loggingConfig + ";unit=DEBUG"
	}
	c.defined["logging-config"] = loggingConfig
	return nil
}
开发者ID:kat-co,项目名称:juju,代码行数:22,代码来源:config.go

示例9: main

func main() {
	args := os.Args
	if len(args) > 1 {
		loggo.ConfigureLoggers(args[1])
	} else {
		fmt.Println("Add a parameter to configure the logging:")
		fmt.Println("E.g. \"<root>=INFO;first=TRACE\"")
	}
	fmt.Println("\nCurrent logging levels:")
	fmt.Println(loggo.LoggerInfo())
	fmt.Println("")

	rootLogger.Infof("Start of test.")

	FirstCritical("first critical")
	FirstError("first error")
	FirstWarning("first warning")
	FirstInfo("first info")
	FirstTrace("first trace")

	SecondCritical("first critical")
	SecondError("first error")
	SecondWarning("first warning")
	SecondInfo("first info")
	SecondTrace("first trace")

	writer, err := rfw.Open("./myprogram", 0644)
	if err != nil {
		log.Fatalln("Could not open '/var/log/myprogram': ", err)
	}

	log := log.New(writer, "[myprogram] ", log.LstdFlags)
	log.Println("Logging as normal")

	//defaultWriter, _, err := loggo.RemoveWriter("default")

	// err is non-nil if and only if the name isn't found.
	//loggo.RegisterWriter("default", writer, loggo.TRACE)
	newWriter := loggo.NewSimpleWriter(writer, &loggo.DefaultFormatter{})
	err = loggo.RegisterWriter("testfile", newWriter, loggo.TRACE)

	now := time.Now().Nanosecond()
	fmt.Printf("CurrentTime: %d\n", now)
	FirstCritical("first critical")
	FirstError("first error")
	FirstWarning("first warning")
	FirstInfo("first info")
	FirstTrace("first trace")

	SecondCritical("first critical")
	SecondError("first error")
	SecondWarning("first warning")
	SecondInfo("first info")
	SecondTrace("first trace")

	viper.SetConfigName("config")        // name of config file (without extension)
	viper.AddConfigPath("/etc/appname/") // path to look for the config file in
	viper.AddConfigPath("$HOME/")        // call multiple times to add many search paths
	viper.ReadInConfig()                 // Find and read the config file

	title := viper.GetString("title")
	fmt.Printf("TITLE=%s\n", title)
}
开发者ID:ritzalam,项目名称:voiceconfmanager,代码行数:63,代码来源:logging.go


注:本文中的github.com/juju/loggo.LoggerInfo函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。