2019-03-11 13:46:36 +01:00
|
|
|
package driver
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
var debugEnabled bool = false
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
if os.Getenv("ZREPL_REPLICATION_DRIVER_DEBUG") != "" {
|
|
|
|
debugEnabled = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-22 20:45:27 +01:00
|
|
|
//nolint[:deadcode,unused]
|
2019-03-11 13:46:36 +01:00
|
|
|
func debug(format string, args ...interface{}) {
|
|
|
|
if debugEnabled {
|
|
|
|
fmt.Fprintf(os.Stderr, "repl: driver: %s\n", fmt.Sprintf(format, args...))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type debugFunc func(format string, args ...interface{})
|
|
|
|
|
2019-03-22 20:45:27 +01:00
|
|
|
//nolint[:deadcode,unused]
|
2019-03-11 13:46:36 +01:00
|
|
|
func debugPrefix(prefixFormat string, prefixFormatArgs ...interface{}) debugFunc {
|
|
|
|
prefix := fmt.Sprintf(prefixFormat, prefixFormatArgs...)
|
|
|
|
return func(format string, args ...interface{}) {
|
|
|
|
debug("%s: %s", prefix, fmt.Sprintf(format, args))
|
|
|
|
}
|
2019-03-22 19:41:12 +01:00
|
|
|
}
|