mirror of
https://github.com/uptrace/go-clickhouse.git
synced 2025-06-08 23:26:11 +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=0 - disables the hook.
|
||||||
// - CHDEBUG=1 - enables the hook.
|
// - CHDEBUG=1 - enables the hook.
|
||||||
// - CHDEBUG=2 - enables the hook and verbose mode.
|
// - CHDEBUG=2 - enables the hook and verbose mode.
|
||||||
func FromEnv(key string) Option {
|
func FromEnv(keys ...string) Option {
|
||||||
if key == "" {
|
if len(keys) == 0 {
|
||||||
key = "CHDEBUG"
|
keys = []string{"CHDEBUG"}
|
||||||
}
|
}
|
||||||
return func(h *QueryHook) {
|
return func(h *QueryHook) {
|
||||||
if env, ok := os.LookupEnv(key); ok {
|
for _, key := range keys {
|
||||||
h.enabled = env != "" && env != "0"
|
if env, ok := os.LookupEnv(key); ok {
|
||||||
h.verbose = env == "2"
|
h.enabled = env != "" && env != "0"
|
||||||
|
h.verbose = env == "2"
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user