I have made a contract which generates a public event on blockchain that will notify client about a transaction. To listen to the event I have written following snippet in geth console:
var event = token.CoinTransfer({}, '', function(error, result){
if (!error)
console.log("Coin transfer: " + result.args.amount + " tokens were sent. Balances now are as following: \n Sender:\t" + result.args.sender + " \t" + token.coinBalanceOf.call(result.args.sender) + " tokens \n Receiver:\t" + result.args.receiver + " \t" + token.coinBalanceOf.call(result.args.receiver) + " tokens" )
});
Now instead of console.log()
I want these transaction to be stored in a text file TransactionHistory.txt
. How can we do this? Is there a better way than listening to event, to maintain transaction logs?