tidb redact 源码

2022-09-19 浏览 (648)

tidb redact 代码

文件路径:/br/pkg/redact/redact.go

/ Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0.

package redact

import (
	"encoding/hex"
	"strings"

	"github.com/pingcap/errors"
)

/ InitRedact inits the enableRedactLog
func InitRedact(redactLog bool) {
	errors.RedactLogEnabled.Store(redactLog)
}

/ NeedRedact returns whether to redact log
func NeedRedact() bool {
	return errors.RedactLogEnabled.Load()
}

/ String receives string argument and return omitted information if redact log enabled
func String(arg string) string {
	if NeedRedact() {
		return "?"
	}
	return arg
}

/ Key receives a key return omitted information if redact log enabled
func Key(key []byte) string {
	if NeedRedact() {
		return "?"
	}
	return strings.ToUpper(hex.EncodeToString(key))
}

相关信息

tidb 源码目录

相关文章

tidb bind_cache 源码

tidb bind_record 源码

tidb handle 源码

tidb session_handle 源码

tidb stat 源码

tidb backup 源码

tidb cmd 源码

tidb debug 源码

tidb main 源码

tidb restore 源码

^