예제 #1
0
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)
}
예제 #2
0
파일: main.go 프로젝트: jungle0755/gorouter
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)
}
예제 #3
0
파일: config.go 프로젝트: nkuacac/pat
func initLogging() {
	if params.level == "" {
		params.level = "off"
	}

	level, err := gosteno.GetLogLevel(strings.ToLower(params.level))
	if err != nil {
		panic(err)
	}

	sinks := []gosteno.Sink{}
	if params.path != "" {
		sinks = append(sinks, NewFileSink(params.path))
	} else {
		sinks = append(sinks, NewIOSink(os.Stdout))
	}

	c := &gosteno.Config{
		Sinks:     sinks,
		Level:     level,
		EnableLOC: true,
	}

	InitGoSteno(c)
}
예제 #4
0
파일: logger.go 프로젝트: jfarrell/gorouter
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")
}
예제 #5
0
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)
}
예제 #6
0
func setupStdoutLogger() steno.Logger {
	level, err := steno.GetLogLevel("debug")
	if err != nil {
		panic(err)
	}

	sinks := make([]steno.Sink, 0)
	sinks = append(sinks, steno.NewIOSink(os.Stdout))

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

	steno.Init(stenoConfig)

	return steno.NewLogger("mongodb_proxy")
}
예제 #7
0
func NewLogger(file *os.File, level string) (Logger, error) {
	if len(level) == 0 {
		level = "debug"
	}

	logLevel, err := steno.GetLogLevel(level)
	if err != nil {
		return nil, err
	}

	out := steno.NewIOSink(file)
	out.SetCodec(steno.NewJsonPrettifier(steno.EXCLUDE_DATA))

	cnf := &steno.Config{
		Sinks:     []steno.Sink{out},
		Level:     logLevel,
		Port:      8080, // TODO: parameterize?
		EnableLOC: false,
	}
	steno.Init(cnf)

	return steno.NewLogger("gonatsd"), nil
}
예제 #8
0
파일: logger.go 프로젝트: 9cc9/dea_ng
func SetupSteno(logConfig *LogConfig) {
	level, err := steno.GetLogLevel(logConfig.Level)
	if err != nil {
		panic(err)
	}

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

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

	steno.Init(stenoConfig)
}