Beispiel #1
0
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)
		}
	}
}
Beispiel #2
0
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
}
Beispiel #3
0
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)
}