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:
parent
2c9485da7f
commit
7f26fb6fae
@ -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) {
|
||||
if env, ok := os.LookupEnv(key); ok {
|
||||
h.enabled = env != "" && env != "0"
|
||||
h.verbose = env == "2"
|
||||
for _, key := range keys {
|
||||
if env, ok := os.LookupEnv(key); ok {
|
||||
h.enabled = env != "" && env != "0"
|
||||
h.verbose = env == "2"
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user