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) } } }
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 }
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) }