예제 #1
0
파일: io.go 프로젝트: speedland/wcg
func UseEnvConfig() {
	out := strings.ToLower(os.Getenv("LOGGING_PATH"))
	cfg := &logSinkFileConfig{
		Path:       out,
		Level:      wcg.LogLevelInfo,
		StackLevel: wcg.LogLevelError,
	}
	cfg.Level, _ = wcg.ParseLogLevel(os.Getenv("LOGGING_LEVEL"))
	cfg.StackLevel, _ = wcg.ParseLogLevel(os.Getenv("LOGGING_STACK_LEVEL"))

	if cfg.Path != "" {
		sink := NewIOLogSinkFromConfig(cfg)
		if sink != nil {
			wcg.LogConfig.AddSink(sink, LogSinkFileConfig.Level)
		}
	}
}
예제 #2
0
파일: server.go 프로젝트: speedland/wcg
func NewTestServer() *TestServer {
	ctx, _ := aetest.NewContext(nil)
	// reset sinks
	level, err := wcg.ParseLogLevel(os.Getenv("LOGGING_LEVEL"))
	if err == nil {
		wcg.LogConfig.Level = level
	}
	wcg.LogConfig.ConfigureSinks()
	wcg.LogConfig.AddSink(
		gae.NewGAELogSinkWithContext(gae.LogSinkConfig.Format, ctx),
		level,
	)
	ts := &TestServer{
		Context: ctx,
	}
	return ts
}
예제 #3
0
파일: server.go 프로젝트: speedland/wcg
func RunTestServer(f func(*TestServer)) {
	ctx, _ := aetest.NewContext(nil)
	defer func() {
		ctx.Close()
	}()
	// reset sinks
	level, err := wcg.ParseLogLevel(os.Getenv("LOGGING_LEVEL"))
	if err == nil {
		wcg.LogConfig.Level = level
	}
	wcg.LogConfig.ConfigureSinks()
	wcg.LogConfig.AddSink(
		gae.NewGAELogSinkWithContext(gae.LogSinkConfig.Format, ctx),
		level,
	)
	ts := &TestServer{
		Context: ctx,
	}
	f(ts)
}