chore_: rename logAndCall to call

This commit is contained in:
frank 2024-09-18 20:05:55 +08:00
parent a1fa91839f
commit 8fbe993bed
No known key found for this signature in database
GPG Key ID: B56FA1FC264D28FD
3 changed files with 106 additions and 92 deletions

View File

@ -55,7 +55,7 @@ type InitializeApplicationResponse struct {
}
func InitializeApplication(requestJSON string) string {
return logAndCallString(initializeApplication, requestJSON)
return callString(initializeApplication, requestJSON)
}
func initializeApplication(requestJSON string) string {
@ -100,7 +100,7 @@ func initializeApplication(requestJSON string) string {
}
func OpenAccounts(datadir string) string {
return logAndCallString(openAccounts, datadir)
return callString(openAccounts, datadir)
}
// DEPRECATED: use InitializeApplication
@ -123,7 +123,7 @@ func openAccounts(datadir string) string {
}
func ExtractGroupMembershipSignatures(signaturePairsStr string) string {
return logAndCallString(extractGroupMembershipSignatures, signaturePairsStr)
return callString(extractGroupMembershipSignatures, signaturePairsStr)
}
// ExtractGroupMembershipSignatures extract public keys from tuples of content/signature.
@ -150,7 +150,7 @@ func extractGroupMembershipSignatures(signaturePairsStr string) string {
}
func SignGroupMembership(content string) string {
return logAndCallString(signGroupMembership, content)
return callString(signGroupMembership, content)
}
// signGroupMembership signs a string containing group membership information.
@ -171,7 +171,7 @@ func signGroupMembership(content string) string {
}
func GetNodeConfig() string {
return logAndCallString(getNodeConfig)
return callString(getNodeConfig)
}
// getNodeConfig returns the current config of the Status node
@ -190,7 +190,7 @@ func getNodeConfig() string {
}
func ValidateNodeConfig(configJSON string) string {
return logAndCallString(validateNodeConfig, configJSON)
return callString(validateNodeConfig, configJSON)
}
// validateNodeConfig validates config for the Status node.
@ -236,7 +236,7 @@ func validateNodeConfig(configJSON string) string {
}
func ResetChainData() string {
return logAndCallString(resetChainData)
return callString(resetChainData)
}
// resetChainData removes chain data from data directory.
@ -246,7 +246,7 @@ func resetChainData() string {
}
func CallRPC(inputJSON string) string {
return logAndCallString(callRPC, inputJSON)
return callString(callRPC, inputJSON)
}
// callRPC calls public APIs via RPC.
@ -259,7 +259,7 @@ func callRPC(inputJSON string) string {
}
func CallPrivateRPC(inputJSON string) string {
return logAndCallString(callPrivateRPC, inputJSON)
return callString(callPrivateRPC, inputJSON)
}
// callPrivateRPC calls both public and private APIs via RPC.
@ -272,7 +272,7 @@ func callPrivateRPC(inputJSON string) string {
}
func VerifyAccountPassword(keyStoreDir, address, password string) string {
return logAndCallString(verifyAccountPassword, keyStoreDir, address, password)
return callString(verifyAccountPassword, keyStoreDir, address, password)
}
// verifyAccountPassword verifies account password.
@ -282,7 +282,7 @@ func verifyAccountPassword(keyStoreDir, address, password string) string {
}
func VerifyDatabasePassword(keyUID, password string) string {
return logAndCallString(verifyDatabasePassword, keyUID, password)
return callString(verifyDatabasePassword, keyUID, password)
}
// verifyDatabasePassword verifies database password.
@ -292,7 +292,7 @@ func verifyDatabasePassword(keyUID, password string) string {
}
func MigrateKeyStoreDir(accountData, password, oldDir, newDir string) string {
return logAndCallString(migrateKeyStoreDir, accountData, password, oldDir, newDir)
return callString(migrateKeyStoreDir, accountData, password, oldDir, newDir)
}
// migrateKeyStoreDir migrates key files to a new directory
@ -371,7 +371,7 @@ func LoginWithConfig(accountData, password, configJSON string) string {
}
func CreateAccountAndLogin(requestJSON string) string {
return logAndCallString(createAccountAndLogin, requestJSON)
return callString(createAccountAndLogin, requestJSON)
}
func createAccountAndLogin(requestJSON string) string {
@ -402,7 +402,7 @@ func createAccountAndLogin(requestJSON string) string {
}
func LoginAccount(requestJSON string) string {
return logAndCallString(loginAccount, requestJSON)
return callString(loginAccount, requestJSON)
}
func loginAccount(requestJSON string) string {
@ -430,7 +430,7 @@ func loginAccount(requestJSON string) string {
}
func RestoreAccountAndLogin(requestJSON string) string {
return logAndCallString(restoreAccountAndLogin, requestJSON)
return callString(restoreAccountAndLogin, requestJSON)
}
func restoreAccountAndLogin(requestJSON string) string {
@ -508,7 +508,7 @@ func SaveAccountAndLogin(accountData, password, settingsJSON, configJSON, subacc
}
func DeleteMultiaccount(keyUID, keyStoreDir string) string {
return logAndCallString(deleteMultiaccount, keyUID, keyStoreDir)
return callString(deleteMultiaccount, keyUID, keyStoreDir)
}
// deleteMultiaccount
@ -518,7 +518,7 @@ func deleteMultiaccount(keyUID, keyStoreDir string) string {
}
func DeleteImportedKey(address, password, keyStoreDir string) string {
return logAndCallString(deleteImportedKey, address, password, keyStoreDir)
return callString(deleteImportedKey, address, password, keyStoreDir)
}
// deleteImportedKey
@ -528,7 +528,7 @@ func deleteImportedKey(address, password, keyStoreDir string) string {
}
func InitKeystore(keydir string) string {
return logAndCallString(initKeystore, keydir)
return callString(initKeystore, keydir)
}
// initKeystore initialize keystore before doing any operations with keys.
@ -602,7 +602,7 @@ func LoginWithKeycard(accountData, password, keyHex string, configJSON string) s
}
func Logout() string {
return logAndCallString(logout)
return callString(logout)
}
// logout is equivalent to clearing whisper identities.
@ -611,7 +611,7 @@ func logout() string {
}
func SignMessage(rpcParams string) string {
return logAndCallString(signMessage, rpcParams)
return callString(signMessage, rpcParams)
}
// signMessage unmarshals rpc params {data, address, password} and
@ -631,7 +631,7 @@ func signMessage(rpcParams string) string {
//
//export SignTypedData
func SignTypedData(data, address, password string) string {
return logAndCallString(signTypedData, data, address, password)
return callString(signTypedData, data, address, password)
}
func signTypedData(data, address, password string) string {
@ -651,7 +651,7 @@ func signTypedData(data, address, password string) string {
//
//export HashTypedData
func HashTypedData(data string) string {
return logAndCallString(hashTypedData, data)
return callString(hashTypedData, data)
}
func hashTypedData(data string) string {
@ -672,7 +672,7 @@ func hashTypedData(data string) string {
//
//export SignTypedDataV4
func SignTypedDataV4(data, address, password string) string {
return logAndCallString(signTypedDataV4, data, address, password)
return callString(signTypedDataV4, data, address, password)
}
func signTypedDataV4(data, address, password string) string {
@ -689,7 +689,7 @@ func signTypedDataV4(data, address, password string) string {
//
//export HashTypedDataV4
func HashTypedDataV4(data string) string {
return logAndCallString(hashTypedDataV4, data)
return callString(hashTypedDataV4, data)
}
func hashTypedDataV4(data string) string {
@ -703,7 +703,7 @@ func hashTypedDataV4(data string) string {
}
func Recover(rpcParams string) string {
return logAndCallString(recoverWithRPCParams, rpcParams)
return callString(recoverWithRPCParams, rpcParams)
}
// recoverWithRPCParams unmarshals rpc params {signDataString, signedData} and passes
@ -719,7 +719,7 @@ func recoverWithRPCParams(rpcParams string) string {
}
func SendTransactionWithChainID(chainID int, txArgsJSON, password string) string {
return logAndCallString(sendTransactionWithChainID, chainID, txArgsJSON, password)
return callString(sendTransactionWithChainID, chainID, txArgsJSON, password)
}
// sendTransactionWithChainID converts RPC args and calls backend.SendTransactionWithChainID.
@ -738,7 +738,7 @@ func sendTransactionWithChainID(chainID int, txArgsJSON, password string) string
}
func SendTransaction(txArgsJSON, password string) string {
return logAndCallString(sendTransaction, txArgsJSON, password)
return callString(sendTransaction, txArgsJSON, password)
}
// sendTransaction converts RPC args and calls backend.SendTransaction.
@ -757,7 +757,7 @@ func sendTransaction(txArgsJSON, password string) string {
}
func SendTransactionWithSignature(txArgsJSON, sigString string) string {
return logAndCallString(sendTransactionWithSignature, txArgsJSON, sigString)
return callString(sendTransactionWithSignature, txArgsJSON, sigString)
}
// sendTransactionWithSignature converts RPC args and calls backend.SendTransactionWithSignature
@ -782,7 +782,7 @@ func sendTransactionWithSignature(txArgsJSON, sigString string) string {
}
func HashTransaction(txArgsJSON string) string {
return logAndCallString(hashTransaction, txArgsJSON)
return callString(hashTransaction, txArgsJSON)
}
// hashTransaction validate the transaction and returns new txArgs and the transaction hash.
@ -811,7 +811,7 @@ func hashTransaction(txArgsJSON string) string {
}
func HashMessage(message string) string {
return logAndCallString(hashMessage, message)
return callString(hashMessage, message)
}
// hashMessage calculates the hash of a message to be safely signed by the keycard
@ -830,7 +830,7 @@ func hashMessage(message string) string {
}
func StartCPUProfile(dataDir string) string {
return logAndCallString(startCPUProfile, dataDir)
return callString(startCPUProfile, dataDir)
}
// startCPUProfile runs pprof for CPU.
@ -840,7 +840,7 @@ func startCPUProfile(dataDir string) string {
}
func StopCPUProfiling() string {
return logAndCallString(stopCPUProfiling)
return callString(stopCPUProfiling)
}
// stopCPUProfiling stops pprof for cpu.
@ -850,7 +850,7 @@ func stopCPUProfiling() string { //nolint: deadcode
}
func WriteHeapProfile(dataDir string) string {
return logAndCallString(writeHeapProfile, dataDir)
return callString(writeHeapProfile, dataDir)
}
// writeHeapProfile starts pprof for heap
@ -875,7 +875,7 @@ func makeJSONResponse(err error) string {
}
func AddPeer(enode string) string {
return logAndCallString(addPeer, enode)
return callString(addPeer, enode)
}
// addPeer adds an enode as a peer.
@ -885,7 +885,7 @@ func addPeer(enode string) string {
}
func ConnectionChange(typ string, expensive int) {
logAndCall(connectionChange, typ, expensive)
call(connectionChange, typ, expensive)
}
// connectionChange handles network state changes as reported
@ -895,7 +895,7 @@ func connectionChange(typ string, expensive int) {
}
func AppStateChange(state string) {
logAndCall(appStateChange, state)
call(appStateChange, state)
}
// appStateChange handles app state changes (background/foreground).
@ -904,7 +904,7 @@ func appStateChange(state string) {
}
func StartLocalNotifications() string {
return logAndCallString(startLocalNotifications)
return callString(startLocalNotifications)
}
// startLocalNotifications
@ -914,7 +914,7 @@ func startLocalNotifications() string {
}
func StopLocalNotifications() string {
return logAndCallString(stopLocalNotifications)
return callString(stopLocalNotifications)
}
// stopLocalNotifications
@ -924,7 +924,7 @@ func stopLocalNotifications() string {
}
func SetMobileSignalHandler(handler SignalHandler) {
logAndCall(setMobileSignalHandler, handler)
call(setMobileSignalHandler, handler)
}
// setMobileSignalHandler setup geth callback to notify about new signal
@ -938,7 +938,7 @@ func setMobileSignalHandler(handler SignalHandler) {
}
func SetSignalEventCallback(cb unsafe.Pointer) {
logAndCall(setSignalEventCallback, cb)
call(setSignalEventCallback, cb)
}
// setSignalEventCallback setup geth callback to notify about new signal
@ -950,7 +950,7 @@ func setSignalEventCallback(cb unsafe.Pointer) {
//
//export ExportNodeLogs
func ExportNodeLogs() string {
return logAndCallString(exportNodeLogs)
return callString(exportNodeLogs)
}
func exportNodeLogs() string {
@ -970,7 +970,7 @@ func exportNodeLogs() string {
}
func SignHash(hexEncodedHash string) string {
return logAndCallString(signHash, hexEncodedHash)
return callString(signHash, hexEncodedHash)
}
// signHash exposes vanilla ECDSA signing required for Swarm messages
@ -983,7 +983,7 @@ func signHash(hexEncodedHash string) string {
}
func GenerateAlias(pk string) string {
return logAndCallString(generateAlias, pk)
return callString(generateAlias, pk)
}
func generateAlias(pk string) string {
@ -993,7 +993,7 @@ func generateAlias(pk string) string {
}
func IsAlias(value string) string {
return logAndCallString(isAlias, value)
return callString(isAlias, value)
}
func isAlias(value string) string {
@ -1001,7 +1001,7 @@ func isAlias(value string) string {
}
func Identicon(pk string) string {
return logAndCallString(identicon, pk)
return callString(identicon, pk)
}
func identicon(pk string) string {
@ -1011,7 +1011,7 @@ func identicon(pk string) string {
}
func EmojiHash(pk string) string {
return logAndCallString(emojiHash, pk)
return callString(emojiHash, pk)
}
func emojiHash(pk string) string {
@ -1019,7 +1019,7 @@ func emojiHash(pk string) string {
}
func ColorHash(pk string) string {
return logAndCallString(colorHash, pk)
return callString(colorHash, pk)
}
func colorHash(pk string) string {
@ -1027,7 +1027,7 @@ func colorHash(pk string) string {
}
func ColorID(pk string) string {
return logAndCallString(colorID, pk)
return callString(colorID, pk)
}
func colorID(pk string) string {
@ -1035,7 +1035,7 @@ func colorID(pk string) string {
}
func ValidateMnemonic(mnemonic string) string {
return logAndCallString(validateMnemonic, mnemonic)
return callString(validateMnemonic, mnemonic)
}
func validateMnemonic(mnemonic string) string {
@ -1059,7 +1059,7 @@ func validateMnemonic(mnemonic string) string {
}
func DecompressPublicKey(key string) string {
return logAndCallString(decompressPublicKey, key)
return callString(decompressPublicKey, key)
}
// decompressPublicKey decompresses 33-byte compressed format to uncompressed 65-byte format.
@ -1080,7 +1080,7 @@ func decompressPublicKey(key string) string {
}
func CompressPublicKey(key string) string {
return logAndCallString(compressPublicKey, key)
return callString(compressPublicKey, key)
}
// compressPublicKey compresses uncompressed 65-byte format to 33-byte compressed format.
@ -1093,7 +1093,7 @@ func compressPublicKey(key string) string {
}
func SerializeLegacyKey(key string) string {
return logAndCallString(serializeLegacyKey, key)
return callString(serializeLegacyKey, key)
}
// serializeLegacyKey compresses an old format public key (0x04...) to the new one zQ...
@ -1106,7 +1106,7 @@ func serializeLegacyKey(key string) string {
}
func MultiformatSerializePublicKey(key, outBase string) string {
return logAndCallString(multiformatSerializePublicKey, key, outBase)
return callString(multiformatSerializePublicKey, key, outBase)
}
// SerializePublicKey compresses an uncompressed multibase encoded multicodec identified EC public key
@ -1120,7 +1120,7 @@ func multiformatSerializePublicKey(key, outBase string) string {
}
func MultiformatDeserializePublicKey(key, outBase string) string {
return logAndCallString(multiformatDeserializePublicKey, key, outBase)
return callString(multiformatDeserializePublicKey, key, outBase)
}
// DeserializePublicKey decompresses a compressed multibase encoded multicodec identified EC public key
@ -1134,7 +1134,7 @@ func multiformatDeserializePublicKey(key, outBase string) string {
}
func ExportUnencryptedDatabase(accountData, password, databasePath string) string {
return logAndCallString(exportUnencryptedDatabase, accountData, password, databasePath)
return callString(exportUnencryptedDatabase, accountData, password, databasePath)
}
// exportUnencryptedDatabase exports the database unencrypted to the given path
@ -1149,7 +1149,7 @@ func exportUnencryptedDatabase(accountData, password, databasePath string) strin
}
func ImportUnencryptedDatabase(accountData, password, databasePath string) string {
return logAndCallString(importUnencryptedDatabase, accountData, password, databasePath)
return callString(importUnencryptedDatabase, accountData, password, databasePath)
}
// importUnencryptedDatabase imports the database unencrypted to the given directory
@ -1164,7 +1164,7 @@ func importUnencryptedDatabase(accountData, password, databasePath string) strin
}
func ChangeDatabasePassword(KeyUID, password, newPassword string) string {
return logAndCallString(changeDatabasePassword, KeyUID, password, newPassword)
return callString(changeDatabasePassword, KeyUID, password, newPassword)
}
// changeDatabasePassword changes the password of the database
@ -1174,7 +1174,7 @@ func changeDatabasePassword(KeyUID, password, newPassword string) string {
}
func ConvertToKeycardAccount(accountData, settingsJSON, keycardUID, password, newPassword string) string {
return logAndCallString(convertToKeycardAccount, accountData, settingsJSON, keycardUID, password, newPassword)
return callString(convertToKeycardAccount, accountData, settingsJSON, keycardUID, password, newPassword)
}
// convertToKeycardAccount converts the account to a keycard account
@ -1195,7 +1195,7 @@ func convertToKeycardAccount(accountData, settingsJSON, keycardUID, password, ne
}
func ConvertToRegularAccount(mnemonic, currPassword, newPassword string) string {
return logAndCallString(convertToRegularAccount, mnemonic, currPassword, newPassword)
return callString(convertToRegularAccount, mnemonic, currPassword, newPassword)
}
// convertToRegularAccount converts the account to a regular account
@ -1271,7 +1271,7 @@ type FleetDescription struct {
}
func Fleets() string {
return logAndCallString(fleets)
return callString(fleets)
}
func fleets() string {
@ -1288,7 +1288,7 @@ func fleets() string {
}
func SwitchFleet(fleet string, configJSON string) string {
return logAndCallString(switchFleet, fleet, configJSON)
return callString(switchFleet, fleet, configJSON)
}
func switchFleet(fleet string, configJSON string) string {
@ -1327,7 +1327,7 @@ func GenerateImages(filepath string, aX, aY, bX, bY int) string {
}
func LocalPairingPreflightOutboundCheck() string {
return logAndCallString(localPairingPreflightOutboundCheck)
return callString(localPairingPreflightOutboundCheck)
}
// localPairingPreflightOutboundCheck creates a local tls server accessible via an outbound network address.
@ -1341,7 +1341,7 @@ func localPairingPreflightOutboundCheck() string {
}
func StartSearchForLocalPairingPeers() string {
return logAndCallString(startSearchForLocalPairingPeers)
return callString(startSearchForLocalPairingPeers)
}
// startSearchForLocalPairingPeers starts a UDP multicast beacon that both listens for and broadcasts to LAN peers
@ -1360,7 +1360,7 @@ func startSearchForLocalPairingPeers() string {
}
func GetConnectionStringForBeingBootstrapped(configJSON string) string {
return logAndCallString(getConnectionStringForBeingBootstrapped, configJSON)
return callString(getConnectionStringForBeingBootstrapped, configJSON)
}
// getConnectionStringForBeingBootstrapped starts a pairing.ReceiverServer
@ -1392,7 +1392,7 @@ func getConnectionStringForBeingBootstrapped(configJSON string) string {
}
func GetConnectionStringForBootstrappingAnotherDevice(configJSON string) string {
return logAndCallString(getConnectionStringForBootstrappingAnotherDevice, configJSON)
return callString(getConnectionStringForBootstrappingAnotherDevice, configJSON)
}
// getConnectionStringForBootstrappingAnotherDevice starts a pairing.SenderServer
@ -1431,7 +1431,7 @@ func (i *inputConnectionStringForBootstrappingResponse) toJSON(err error) string
}
func InputConnectionStringForBootstrapping(cs, configJSON string) string {
return logAndCallString(inputConnectionStringForBootstrapping, cs, configJSON)
return callString(inputConnectionStringForBootstrapping, cs, configJSON)
}
// inputConnectionStringForBootstrapping starts a pairing.ReceiverClient
@ -1474,7 +1474,7 @@ func inputConnectionStringForBootstrapping(cs, configJSON string) string {
}
func InputConnectionStringForBootstrappingAnotherDevice(cs, configJSON string) string {
return logAndCallString(inputConnectionStringForBootstrappingAnotherDevice, cs, configJSON)
return callString(inputConnectionStringForBootstrappingAnotherDevice, cs, configJSON)
}
// inputConnectionStringForBootstrappingAnotherDevice starts a pairing.SendingClient
@ -1501,7 +1501,7 @@ func inputConnectionStringForBootstrappingAnotherDevice(cs, configJSON string) s
}
func GetConnectionStringForExportingKeypairsKeystores(configJSON string) string {
return logAndCallString(getConnectionStringForExportingKeypairsKeystores, configJSON)
return callString(getConnectionStringForExportingKeypairsKeystores, configJSON)
}
// getConnectionStringForExportingKeypairsKeystores starts a pairing.SenderServer
@ -1520,7 +1520,7 @@ func getConnectionStringForExportingKeypairsKeystores(configJSON string) string
}
func InputConnectionStringForImportingKeypairsKeystores(cs, configJSON string) string {
return logAndCallString(inputConnectionStringForImportingKeypairsKeystores, cs, configJSON)
return callString(inputConnectionStringForImportingKeypairsKeystores, cs, configJSON)
}
// inputConnectionStringForImportingKeypairsKeystores starts a pairing.ReceiverClient
@ -1539,7 +1539,7 @@ func inputConnectionStringForImportingKeypairsKeystores(cs, configJSON string) s
}
func ValidateConnectionString(cs string) string {
return logAndCallString(validateConnectionString, cs)
return callString(validateConnectionString, cs)
}
func validateConnectionString(cs string) string {
@ -1551,7 +1551,7 @@ func validateConnectionString(cs string) string {
}
func EncodeTransfer(to string, value string) string {
return logAndCallString(encodeTransfer, to, value)
return callString(encodeTransfer, to, value)
}
func encodeTransfer(to string, value string) string {
@ -1564,7 +1564,7 @@ func encodeTransfer(to string, value string) string {
}
func EncodeFunctionCall(method string, paramsJSON string) string {
return logAndCallString(encodeFunctionCall, method, paramsJSON)
return callString(encodeFunctionCall, method, paramsJSON)
}
func encodeFunctionCall(method string, paramsJSON string) string {
@ -1604,7 +1604,7 @@ func decodeParameters(decodeParamJSON string) string {
}
func HexToNumber(hex string) string {
return logAndCallString(hexToNumber, hex)
return callString(hexToNumber, hex)
}
func hexToNumber(hex string) string {
@ -1612,7 +1612,7 @@ func hexToNumber(hex string) string {
}
func NumberToHex(numString string) string {
return logAndCallString(numberToHex, numString)
return callString(numberToHex, numString)
}
func numberToHex(numString string) string {
@ -1624,7 +1624,7 @@ func Sha3(str string) string {
}
func Utf8ToHex(str string) string {
return logAndCallString(utf8ToHex, str)
return callString(utf8ToHex, str)
}
func utf8ToHex(str string) string {
@ -1636,7 +1636,7 @@ func utf8ToHex(str string) string {
}
func HexToUtf8(hexString string) string {
return logAndCallString(hexToUtf8, hexString)
return callString(hexToUtf8, hexString)
}
func hexToUtf8(hexString string) string {
@ -1648,7 +1648,7 @@ func hexToUtf8(hexString string) string {
}
func CheckAddressChecksum(address string) string {
return logAndCallString(checkAddressChecksum, address)
return callString(checkAddressChecksum, address)
}
func checkAddressChecksum(address string) string {
@ -1661,7 +1661,7 @@ func checkAddressChecksum(address string) string {
}
func IsAddress(address string) string {
return logAndCallString(isAddress, address)
return callString(isAddress, address)
}
func isAddress(address string) string {
@ -1674,7 +1674,7 @@ func isAddress(address string) string {
}
func ToChecksumAddress(address string) string {
return logAndCallString(toChecksumAddress, address)
return callString(toChecksumAddress, address)
}
func toChecksumAddress(address string) string {
@ -1686,7 +1686,7 @@ func toChecksumAddress(address string) string {
}
func DeserializeAndCompressKey(DesktopKey string) string {
return logAndCallString(deserializeAndCompressKey, DesktopKey)
return callString(deserializeAndCompressKey, DesktopKey)
}
func deserializeAndCompressKey(DesktopKey string) string {
@ -1734,7 +1734,7 @@ func GetRandomMnemonic() string {
}
func ToggleCentralizedMetrics(requestJSON string) string {
return logAndCallString(toggleCentralizedMetrics, requestJSON)
return callString(toggleCentralizedMetrics, requestJSON)
}
func toggleCentralizedMetrics(requestJSON string) string {
@ -1758,7 +1758,7 @@ func toggleCentralizedMetrics(requestJSON string) string {
}
func CentralizedMetricsInfo() string {
return logAndCallString(centralizedMetricsInfo)
return callString(centralizedMetricsInfo)
}
func centralizedMetricsInfo() string {
@ -1774,7 +1774,7 @@ func centralizedMetricsInfo() string {
}
func AddCentralizedMetric(requestJSON string) string {
return logAndCallString(addCentralizedMetric, requestJSON)
return callString(addCentralizedMetric, requestJSON)
}
func addCentralizedMetric(requestJSON string) string {

View File

@ -25,12 +25,26 @@ func getShortFunctionName(fn any) string {
return parts[len(parts)-1]
}
// logAndCall logs request call details and executes the fn function if logging is enabled
func logAndCall(fn any, params ...any) any {
// call executes the given function and logs request details if logging is enabled
//
// Parameters:
// - fn: The function to be executed
// - params: A variadic list of parameters to be passed to the function
//
// Returns:
// - The result of the function execution (if any)
//
// Functionality:
// 1. Sets up panic recovery to log and re-panic
// 2. Records start time if request logging is enabled
// 3. Uses reflection to call the given function
// 4. If request logging is enabled, logs method name, parameters, response, and execution duration
// 5. Removes sensitive information before logging
func call(fn any, params ...any) any {
defer func() {
if r := recover(); r != nil {
// we're not sure if request logging is enabled here, so we log it use default logger
log.Error("panic found in logAndCall", "error", r, "stacktrace", string(debug.Stack()))
log.Error("panic found in call", "error", r, "stacktrace", string(debug.Stack()))
panic(r)
}
}()
@ -71,8 +85,8 @@ func logAndCall(fn any, params ...any) any {
return resp
}
func logAndCallString(fn any, params ...any) string {
resp := logAndCall(fn, params...)
func callString(fn any, params ...any) string {
resp := call(fn, params...)
if resp == nil {
return ""
}

View File

@ -59,7 +59,7 @@ func TestRemoveSensitiveInfo(t *testing.T) {
}
}
func TestLogAndCall(t *testing.T) {
func TestCall(t *testing.T) {
// Enable request logging
requestlog.EnableRequestLogging(true)
@ -79,7 +79,7 @@ func TestLogAndCall(t *testing.T) {
testParam := "test input"
expectedResult := "test result: test input"
result := logAndCallString(testFunc, testParam)
result := callString(testFunc, testParam)
// Check the result
if result != expectedResult {
@ -106,11 +106,11 @@ func TestLogAndCall(t *testing.T) {
}
require.PanicsWithValue(t, e, func() {
logAndCall(panicFunc)
call(panicFunc)
})
// Check if the panic was logged
if !strings.Contains(logOutput, "panic found in logAndCall") {
if !strings.Contains(logOutput, "panic found in call") {
t.Errorf("Log output doesn't contain panic information")
}
if !strings.Contains(logOutput, e) {