1
0
mirror of https://github.com/uptrace/go-clickhouse.git synced 2024-11-24 08:42:30 +02:00

chore: support multiple env keys

This commit is contained in:
Vladimir Mihailenco 2022-08-28 16:53:07 +03:00
parent 2c9485da7f
commit 7f26fb6fae

View File

@ -43,14 +43,17 @@ func WithWriter(w io.Writer) Option {
// - CHDEBUG=0 - disables the hook.
// - CHDEBUG=1 - enables the hook.
// - CHDEBUG=2 - enables the hook and verbose mode.
func FromEnv(key string) Option {
if key == "" {
key = "CHDEBUG"
func FromEnv(keys ...string) Option {
if len(keys) == 0 {
keys = []string{"CHDEBUG"}
}
return func(h *QueryHook) {
for _, key := range keys {
if env, ok := os.LookupEnv(key); ok {
h.enabled = env != "" && env != "0"
h.verbose = env == "2"
break
}
}
}
}