The log file created using event is shown below. Is it possible to show the variable names of the fields that the values are being displayed.
Asked
Active
Viewed 2,018 times
0
-
Just to clarify, do you want the hex values in string? Or do you want the variable names printed out with it? – thefett Oct 02 '17 at 11:05
-
Hi @thefett, thanks for your reply. I wanted to see the variable names printed out with it. Is that possible? – userDSSR Oct 02 '17 at 14:59
1 Answers
1
Just change the event to place the name first:
contract Test {
uint public number;
event Print(string _name, uint _value);
function setnum(uint _num) public{
number = _num;
Print("number",number);
}
}
thefett
- 3,873
- 5
- 26
- 48
-
Hi @thefett. This works for now but in a round about way. The variable name and the value falls in two separate lines and it requires the variable name to be hardcoded again in the event execution. I was trying to get the same format as the "decoded input" in the Log file, which has the variable name along with the value. I am not sure if that is possible for now. – userDSSR Oct 02 '17 at 16:28
-
Ah I see, I don't think it is possible without hardcoding it. The 'logs' portion is just the decoded logsBloom which you can see here: https://ethereum.stackexchange.com/questions/3418/how-does-ethereum-make-use-of-bloom-filters is just stored data, so if you don't specify what you're storing, then it can't figure it out from just the logs data – thefett Oct 02 '17 at 17:38
