0

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.

Log File

  • Just to clarify, do you want the hex values in string? Or do you want the variable names printed out with it? – thefett Oct 2 '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 2 '17 at 14:59
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);
    }


}
  • 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 2 '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: ethereum.stackexchange.com/questions/3418/… 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 2 '17 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.