itest: include compressed btcd backend logs

This commit is contained in:
ErikEk committed 2021-08-24 02:00:44 +02:00
1 parent 4487acc5d9
commit ca7192f8fd
3 files changed
+57 -20

No files matched your search

+24 -7
View File
@@ -6,7 +6,9 @@ import (
"encoding/hex"
"errors"
"fmt"
"io/ioutil"
"os"
"strings"
"github.com/btcsuite/btcd/btcjson"
"github.com/btcsuite/btcd/chaincfg"
@@ -118,15 +120,30 @@ func NewBackend(miner string, netParams *chaincfg.Params) (
}
// After shutting down the chain backend, we'll make a copy of
// the log file before deleting the temporary log dir.
logFile := baseLogDir + "/" + netParams.Name + "/btcd.log"
logDestination := fmt.Sprintf(
"%s/output_btcd_chainbackend.log", GetLogDir(),
)
err := CopyFile(logDestination, logFile)
// the log files, including any compressed log files from
// logrorate, before deleting the temporary log dir.
logDir := fmt.Sprintf("%s/%s", baseLogDir, netParams.Name)
files, err := ioutil.ReadDir(logDir)
if err != nil {
errStr += fmt.Sprintf("unable to copy file: %v\n", err)
errStr += fmt.Sprintf(
"unable to read log directory: %v\n", err,
)
}
for _, file := range files {
logFile := fmt.Sprintf("%s/%s", logDir, file.Name())
newFilename := strings.Replace(
file.Name(), "btcd.log", "output_btcd_chainbackend.log", 1,
)
logDestination := fmt.Sprintf(
"%s/%s", GetLogDir(), newFilename,
)
err := CopyFile(logDestination, logFile)
if err != nil {
errStr += fmt.Sprintf("unable to copy file: %v\n", err)
}
}
if err = os.RemoveAll(baseLogDir); err != nil {
errStr += fmt.Sprintf(
"cannot remove dir %s: %v\n", baseLogDir, err,