This commit is contained in:
lzx
2025-11-13 17:08:38 +08:00
parent 8d7da5d345
commit 00389efb75
25 changed files with 2919 additions and 1967 deletions

View File

@@ -211,20 +211,20 @@ func LogTopup(toAddress string, status string, amount float64, txHash string, bl
}
// LogWithdraw 记录提现消息
func LogWithdraw(toAddress string, status string, amount float64, fromAddress string, txHash string, blockHeight uint64) {
func LogWithdraw(fromAddress string, status string, amount float64, toAddress string, txHash string, blockHeight uint64) {
if txLogger == nil {
return
}
// 使用 toAddress 作为文件名
lf, err := txLogger.getOrCreateLogFile(toAddress)
lf, err := txLogger.getOrCreateLogFile(fromAddress)
if err != nil {
fmt.Printf("⚠️ 获取日志文件失败: %v\n", err)
return
}
timestamp := time.Now().Format("2006-01-02 15:04:05")
content := fmt.Sprintf("%s [withdraw]-[%s] | 金额: %.6f | FromAddress: %s | ToAddress: %s | 交易哈希: %s | 区块高度: %d",
content := fmt.Sprintf("%s [提现]-[%s] | 金额: %.6f | FromAddress: %s | ToAddress: %s | 交易哈希: %s | 区块高度: %d",
timestamp, status, amount, fromAddress, toAddress, txHash, blockHeight)
if err := lf.write(content); err != nil {
@@ -233,7 +233,7 @@ func LogWithdraw(toAddress string, status string, amount float64, fromAddress st
}
// LogPay 记录支付消息
func LogPay(status string, fromAddress string, queueId string, transactions map[string]*message.PayData_resp) {
func LogPay(status string, fromAddress string, queueId string, transactions map[string]*message.PayData) {
if txLogger == nil {
return
}
@@ -258,6 +258,26 @@ func LogPay(status string, fromAddress string, queueId string, transactions map[
}
}
// 记录当前监听的钱包和所有消息
func LogETHNode(msg string) {
if txLogger == nil {
return
}
lf, err := txLogger.getOrCreateLogFile("ethnode")
if err != nil {
fmt.Printf("⚠️ 获取日志文件失败: %v\n", err)
return
}
timestamp := time.Now().Format("2006-01-02 15:04:05")
content := fmt.Sprintf("[ETH-NODE:%s]: %s", timestamp, msg)
if err := lf.write(content); err != nil {
fmt.Printf("⚠️ 写入日志失败: %v\n", err)
}
}
// Close 关闭所有日志文件
func CloseTransactionLogger() {
if txLogger == nil {