1 Star 0 Fork 0

litian/machine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
log.go 1.48 KB
一键复制 编辑 原始数据 按行查看 历史
package log
import (
"io"
"regexp"
)
const redactedText = "<REDACTED>"
var (
logger = NewFmtMachineLogger()
// (?s) enables '.' to match '\n' -- see https://golang.org/pkg/regexp/syntax/
certRegex = regexp.MustCompile("(?s)-----BEGIN CERTIFICATE-----.*-----END CERTIFICATE-----")
keyRegex = regexp.MustCompile("(?s)-----BEGIN RSA PRIVATE KEY-----.*-----END RSA PRIVATE KEY-----")
)
func stripSecrets(original []string) []string {
stripped := []string{}
for _, line := range original {
line = certRegex.ReplaceAllString(line, redactedText)
line = keyRegex.ReplaceAllString(line, redactedText)
stripped = append(stripped, line)
}
return stripped
}
func Debug(args ...interface{}) {
logger.Debug(args...)
}
func Debugf(fmtString string, args ...interface{}) {
logger.Debugf(fmtString, args...)
}
func Error(args ...interface{}) {
logger.Error(args...)
}
func Errorf(fmtString string, args ...interface{}) {
logger.Errorf(fmtString, args...)
}
func Info(args ...interface{}) {
logger.Info(args...)
}
func Infof(fmtString string, args ...interface{}) {
logger.Infof(fmtString, args...)
}
func Warn(args ...interface{}) {
logger.Warn(args...)
}
func Warnf(fmtString string, args ...interface{}) {
logger.Warnf(fmtString, args...)
}
func SetDebug(debug bool) {
logger.SetDebug(debug)
}
func SetOutWriter(out io.Writer) {
logger.SetOutWriter(out)
}
func SetErrWriter(err io.Writer) {
logger.SetErrWriter(err)
}
func History() []string {
return stripSecrets(logger.History())
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/litian33/machine.git
git@gitee.com:litian33/machine.git
litian33
machine
machine
v0.14.0-rancher1

搜索帮助