Skip to content

Commit d928960

Browse files
fix: 日志打印优化
1 parent bf03836 commit d928960

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

backend/app/service/cronjob_helper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func handleTar(sourceDir, targetDir, name, exclusionRules string, secret string)
165165
} else {
166166
commands = fmt.Sprintf("tar --warning=no-file-changed --ignore-failed-read -zcf %s %s %s", targetDir+"/"+name, excludeRules, path)
167167
}
168-
global.LOG.Debug(commands)
168+
global.LOG.Debug(strings.ReplaceAll(commands, secret, "******"))
169169
stdout, err := cmd.ExecWithTimeOut(commands, 24*time.Hour)
170170
if err != nil {
171171
if len(stdout) != 0 {
@@ -189,7 +189,7 @@ func handleUnTar(sourceFile, targetDir string, secret string) error {
189189
} else {
190190
commands = fmt.Sprintf("tar -zxvf %s %s", sourceFile+" -C ", targetDir+" > /dev/null 2>&1")
191191
}
192-
global.LOG.Debug(commands)
192+
global.LOG.Debug(strings.ReplaceAll(commands, secret, "******"))
193193
stdout, err := cmd.ExecWithTimeOut(commands, 24*time.Hour)
194194
if err != nil {
195195
global.LOG.Errorf("do handle untar failed, stdout: %s, err: %v", stdout, err)

backend/app/service/snapshot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ func (u *SnapshotService) handleUnTar(sourceDir, targetDir string, secret string
396396
} else {
397397
commands = fmt.Sprintf("tar -zxvf %s %s", sourceDir+" -C ", targetDir+" > /dev/null 2>&1")
398398
}
399-
global.LOG.Debug(commands)
399+
global.LOG.Debug(strings.ReplaceAll(commands, secret, "******"))
400400
stdout, err := cmd.ExecWithTimeOut(commands, 30*time.Minute)
401401
if err != nil {
402402
if len(stdout) != 0 {

backend/app/service/snapshot_create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ func handleSnapTar(sourceDir, targetDir, name, exclusionRules string, secret str
261261
} else {
262262
commands = fmt.Sprintf("tar --warning=no-file-changed --ignore-failed-read -zcf %s %s -C %s .", targetDir+"/"+name, exStr, sourceDir)
263263
}
264-
global.LOG.Debug(commands)
264+
global.LOG.Debug(strings.ReplaceAll(commands, secret, "******"))
265265
stdout, err := cmd.ExecWithTimeOut(commands, 30*time.Minute)
266266
if err != nil {
267267
if len(stdout) != 0 {

backend/utils/files/tar_gz.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (t TarGzArchiver) Extract(filePath, dstDir string, secret string) error {
2424
} else {
2525
commands = fmt.Sprintf("tar -zxvf %s %s", filePath+" -C ", dstDir+" > /dev/null 2>&1")
2626
}
27-
global.LOG.Debug(commands)
27+
global.LOG.Debug(strings.ReplaceAll(commands, secret, "******"))
2828
if err = cmd.ExecCmd(commands); err != nil {
2929
return err
3030
}
@@ -50,7 +50,7 @@ func (t TarGzArchiver) Compress(sourcePaths []string, dstFile string, secret str
5050
} else {
5151
commands = fmt.Sprintf("tar -zcf %s %s", dstFile, path)
5252
}
53-
global.LOG.Debug(commands)
53+
global.LOG.Debug(strings.ReplaceAll(commands, secret, "******"))
5454
if err = cmd.ExecCmd(commands); err != nil {
5555
return err
5656
}

0 commit comments

Comments
 (0)