當前位置: 首頁>>代碼示例>>Golang>>正文


Golang gosteno.NewJsonCodec函數代碼示例

本文整理匯總了Golang中github.com/cloudfoundry/gosteno.NewJsonCodec函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewJsonCodec函數的具體用法?Golang NewJsonCodec怎麽用?Golang NewJsonCodec使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewJsonCodec函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: main

func main() {
	flag.Parse()

	if *version {
		fmt.Printf("\n\nversion: %s\ngitSha: %s\n\n", versionNumber, gitSha)
		return
	}

	level := gosteno.LOG_INFO

	if *logLevel {
		level = gosteno.LOG_DEBUG
	}

	loggingConfig := &gosteno.Config{
		Sinks:     make([]gosteno.Sink, 1),
		Level:     level,
		Codec:     gosteno.NewJsonCodec(),
		EnableLOC: true}
	if strings.TrimSpace(*logFilePath) == "" {
		loggingConfig.Sinks[0] = gosteno.NewIOSink(os.Stdout)
	} else {
		loggingConfig.Sinks[0] = gosteno.NewFileSink(*logFilePath)
	}
	gosteno.Init(loggingConfig)
	logger := gosteno.NewLogger("deaagent")

	loggregatorClient := loggregatorclient.NewLoggregatorClient(*loggregatorAddress, logger, 4096)

	agent := deaagent.NewAgent(*instancesJsonFilePath, logger)
	agent.Start(loggregatorClient)
}
開發者ID:shageman,項目名稱:loggregator,代碼行數:32,代碼來源:main.go

示例2: InitLoggerFromConfig

func InitLoggerFromConfig(c *config.Config, logCounter *vcap.LogCounter) {
	l, err := steno.GetLogLevel(c.Logging.Level)
	if err != nil {
		panic(err)
	}

	s := make([]steno.Sink, 0, 3)
	if c.Logging.File != "" {
		s = append(s, steno.NewFileSink(c.Logging.File))
	} else {
		s = append(s, steno.NewIOSink(os.Stdout))
	}

	if c.Logging.Syslog != "" {
		s = append(s, steno.NewSyslogSink(c.Logging.Syslog))
	}

	s = append(s, logCounter)

	stenoConfig := &steno.Config{
		Sinks: s,
		Codec: steno.NewJsonCodec(),
		Level: l,
	}

	steno.Init(stenoConfig)
}
開發者ID:jungle0755,項目名稱:gorouter,代碼行數:27,代碼來源:main.go

示例3: loadLoggerAndConfig

func loadLoggerAndConfig(c *cli.Context, component string) (logger.Logger, *gosteno.Logger, *config.Config) {
	configPath := c.String("config")
	if configPath == "" {
		fmt.Printf("Config path required")
		os.Exit(1)
	}

	conf, err := config.FromFile(configPath)
	if err != nil {
		fmt.Printf("Failed to load config: %s", err.Error())
		os.Exit(1)
	}

	stenoConf := &gosteno.Config{
		Sinks: []gosteno.Sink{
			gosteno.NewIOSink(os.Stdout),
			gosteno.NewSyslogSink("vcap.hm9000." + component),
		},
		Level: conf.LogLevel(),
		Codec: gosteno.NewJsonCodec(),
	}
	gosteno.Init(stenoConf)
	steno := gosteno.NewLogger("vcap.hm9000." + component)
	hmLogger := logger.NewRealLogger(steno)

	return hmLogger, steno, conf
}
開發者ID:johntdyer,項目名稱:golang-devops-stuff,代碼行數:27,代碼來源:hm9000.go

示例4: SetupLoggerFromConfig

func SetupLoggerFromConfig(c *config.Config) {
	l, err := steno.GetLogLevel(c.Logging.Level)
	if err != nil {
		panic(err)
	}

	s := make([]steno.Sink, 0)
	if c.Logging.File != "" {
		s = append(s, steno.NewFileSink(c.Logging.File))
	} else {
		s = append(s, steno.NewIOSink(os.Stdout))
	}

	if c.Logging.Syslog != "" {
		s = append(s, steno.NewSyslogSink(c.Logging.Syslog))
	}

	stenoConfig := &steno.Config{
		Sinks: s,
		Codec: steno.NewJsonCodec(),
		Level: l,
	}

	steno.Init(stenoConfig)
	log = steno.NewLogger("router.global")
}
開發者ID:jfarrell,項目名稱:gorouter,代碼行數:26,代碼來源:logger.go

示例5: NewLogger

func NewLogger(verbose bool, logFilePath, name string, syslogNamespace string) *gosteno.Logger {
	level := gosteno.LOG_INFO

	if verbose {
		level = gosteno.LOG_DEBUG
	}

	loggingConfig := &gosteno.Config{
		Sinks:     make([]gosteno.Sink, 1),
		Level:     level,
		Codec:     gosteno.NewJsonCodec(),
		EnableLOC: true}

	if strings.TrimSpace(logFilePath) == "" {
		loggingConfig.Sinks[0] = gosteno.NewIOSink(os.Stdout)
	} else {
		loggingConfig.Sinks[0] = gosteno.NewFileSink(logFilePath)
	}

	if syslogNamespace != "" {
		loggingConfig.Sinks = append(loggingConfig.Sinks, GetNewSyslogSink(syslogNamespace))
	}

	gosteno.Init(loggingConfig)
	logger := gosteno.NewLogger(name)
	logger.Debugf("Component %s in debug mode!", name)

	return logger
}
開發者ID:lyuyun,項目名稱:loggregator,代碼行數:29,代碼來源:logger.go

示例6: main

func main() {
	flag.Parse()

	level, err := gosteno.GetLogLevel(*logLevel)
	if err != nil {
		level = gosteno.LOG_INFO
	}
	loggingConfig := &gosteno.Config{
		Sinks: []gosteno.Sink{
			gosteno.NewIOSink(os.Stdout),
		},
		Level:     level,
		Codec:     gosteno.NewJsonCodec(),
		EnableLOC: true,
	}

	gosteno.Init(loggingConfig)
	logger := gosteno.NewLogger("statsdinjector")

	statsdMessageListener := statsdlistener.New(*statsdPort, logger)
	statsdEmitter := statsdemitter.New(*metronPort, logger)

	inputChan := make(chan *events.Envelope)

	go statsdMessageListener.Run(inputChan)
	statsdEmitter.Run(inputChan)
}
開發者ID:kei-yamazaki,項目名稱:loggregator,代碼行數:27,代碼來源:main.go

示例7: main

func main() {
	flag.Parse()

	if *version {
		fmt.Printf("\n\nversion: %s\ngitSha: %s\n\n", versionNumber, gitSha)
		return
	}

	level := gosteno.LOG_INFO

	if *logLevel {
		level = gosteno.LOG_DEBUG
	}

	loggingConfig := &gosteno.Config{
		Sinks:     make([]gosteno.Sink, 1),
		Level:     level,
		Codec:     gosteno.NewJsonCodec(),
		EnableLOC: true}

	if strings.TrimSpace(*logFilePath) == "" {
		loggingConfig.Sinks[0] = gosteno.NewIOSink(os.Stdout)
	} else {
		loggingConfig.Sinks[0] = gosteno.NewFileSink(*logFilePath)
	}
	gosteno.Init(loggingConfig)
	logger := gosteno.NewLogger("loggregator")

	listener := loggregator.NewAgentListener(*host, logger)
	incomingData := listener.Start()

	cfSink := loggregator.NewCfSink(incomingData, logger)
	cfSink.Start()
}
開發者ID:shageman,項目名稱:loggregator,代碼行數:34,代碼來源:main.go

示例8: setup_steno

func setup_steno(conf *proxy.ProxyConfig) {
	level, err := steno.GetLogLevel(conf.LOGGING.LEVEL)
	if err != nil {
		panic(err)
	}

	log_path := conf.LOGGING.PATH
	if log_path != "" {
		os.MkdirAll(filepath.Dir(log_path), 0755)
	}

	sinks := make([]steno.Sink, 0)
	if log_path != "" {
		sinks = append(sinks, steno.NewFileSink(log_path))
	} else {
		sinks = append(sinks, steno.NewIOSink(os.Stdout))
	}

	stenoConfig := &steno.Config{
		Sinks: sinks,
		Codec: steno.NewJsonCodec(),
		Level: level,
	}

	steno.Init(stenoConfig)
}
開發者ID:008by,項目名稱:cf-services-contrib-release,代碼行數:26,代碼來源:logger.go

示例9: init

func init() {
	steno.Init(&steno.Config{
		Sinks: []steno.Sink{steno.NewIOSink(os.Stderr)},
		Codec: steno.NewJsonCodec(),
		Level: steno.LOG_ALL,
	})

	log = steno.NewLogger("directory_server_test")
}
開發者ID:9cc9,項目名稱:dea_ng,代碼行數:9,代碼來源:log_test.go

示例10: init

func init() {
	stenoConfig := &steno.Config{
		Sinks: []steno.Sink{steno.NewIOSink(os.Stderr)},
		Codec: steno.NewJsonCodec(),
		Level: steno.LOG_ALL,
	}

	steno.Init(stenoConfig)
	log = steno.NewLogger("common.logger")
}
開發者ID:hfeeki,項目名稱:gorouter,代碼行數:10,代碼來源:init.go

示例11: Test

func Test(t *testing.T) {
	config := &steno.Config{
		Sinks: []steno.Sink{},
		Codec: steno.NewJsonCodec(),
		Level: steno.LOG_INFO,
	}

	steno.Init(config)

	log = steno.NewLogger("test")

	TestingT(t)
}
開發者ID:johnvilsack,項目名稱:golang-stuff,代碼行數:13,代碼來源:helper_test.go

示例12: InitLog

func InitLog(logFile string) {
	c := &steno.Config{
		Level:     steno.LOG_INFO,
		Codec:     steno.NewJsonCodec(),
		EnableLOC: true,
	}
	if logFile == "" {
		c.Sinks = []steno.Sink{steno.NewIOSink(os.Stdout)}
	} else {
		c.Sinks = []steno.Sink{steno.NewFileSink(logFile)}
	}
	steno.Init(c)
	obj = steno.NewLogger("")
}
開發者ID:hayatoshimizuBSKYB,項目名稱:vcap-services,代碼行數:14,代碼來源:logger.go

示例13: main

func main() {

	stenoConfig := &steno.Config{
		Sinks: []steno.Sink{steno.NewIOSink(os.Stderr)},
		Codec: steno.NewJsonCodec(),
		Level: steno.LOG_ALL,
	}

	steno.Init(stenoConfig)
	log = steno.NewLogger("router.test")
	s := true
	log.Infof("test %s ", s)

	p := &Proxy{}
	p.Logger = steno.NewLogger("router.registry")
	p.Infof("hello %s", "ss\n")
	fmt.Printf("fmt world\n")
}
開發者ID:ndzj081221130,項目名稱:router-src,代碼行數:18,代碼來源:hello.go

示例14: getLogger

func getLogger(debug bool) *gosteno.Logger {
	if debug {
		level := gosteno.LOG_DEBUG

		loggingConfig := &gosteno.Config{
			Sinks:     make([]gosteno.Sink, 1),
			Level:     level,
			Codec:     gosteno.NewJsonCodec(),
			EnableLOC: true,
		}

		loggingConfig.Sinks[0] = gosteno.NewIOSink(os.Stdout)

		gosteno.Init(loggingConfig)
	}

	return gosteno.NewLogger("TestLogger")
}
開發者ID:narayana1208,項目名稱:loggregator,代碼行數:18,代碼來源:base.go

示例15: loadLoggerAndConfig

func loadLoggerAndConfig(c *cli.Context, component string) (logger.Logger, *gosteno.Logger, *config.Config) {
	configPath := c.String("config")
	if configPath == "" {
		fmt.Printf("Config path required")
		os.Exit(1)
	}

	conf, err := config.FromFile(configPath)
	if err != nil {
		fmt.Printf("Failed to load config: %s", err.Error())
		os.Exit(1)
	}

	sinks := make([]gosteno.Sink, 0, 3)
	if conf.LogDirectory != "" {
		logName := fmt.Sprintf("hm9000_%s.log", component)
		logFile := path.Join(conf.LogDirectory, logName)

		sinks = append(sinks, gosteno.NewFileSink(logFile))
	} else {
		sinks = append(sinks, gosteno.NewIOSink(os.Stdout))
	}
	sinks = append(sinks, gosteno.NewSyslogSink("vcap.hm9000."+component))

	stenoConf := &gosteno.Config{
		Sinks: sinks,
		Level: conf.LogLevel(),
		Codec: gosteno.NewJsonCodec(),
	}
	gosteno.Init(stenoConf)
	steno := gosteno.NewLogger("vcap.hm9000." + component)
	hmLogger := logger.NewRealLogger(steno)

	debugAddr := c.String("debugAddr")
	if debugAddr != "" {
		_, err = cf_debug_server.Run(debugAddr, nil)
		if err != nil {
			hmLogger.Error("Failed to start debug server", err)
			os.Exit(1)
		}
	}

	return hmLogger, steno, conf
}
開發者ID:nagyistge,項目名稱:hm9000,代碼行數:44,代碼來源:hm9000.go


注:本文中的github.com/cloudfoundry/gosteno.NewJsonCodec函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。