Probably is best that you exec the script from a file anyway
geth --exec 'loadScript("/tmp/test.js")' attach
Then you can direct the output, for example in Linux and Mac:
geth --exec 'loadScript("/tmp/checkbalances.js")' attach > log.txt
If you want to deal with raw data I'd suggest to use a library like ethereumjs-abi. The rules used to encode/decode are in the solidity abi.
In your case your data split into chunks of 20 bytes/40 hex look like
0000000000000000000000000000000000000000000000000000000000000040
000000000000000000000000000000000000000000000000000000000000001d
0000000000000000000000000000000000000000000000000000000000000006
4c6f6e646f6e0000000000000000000000000000000000000000000000000000
The first parameter location
is a string, since strings are of variable length they store an offset instead of the value. So 0x00..040 = 64
is the offset to the location
parameter.
The second parameter temperature
is uint256, and it fits in 32 bytes so its value is stored directly. Value is then 0x00..001d = 29
.
The event doesn't have more parameters and the rest of the data is used by the parameters like location
that were not included directly.
The parameter location
is at offset 0x40 = 64
and we have this data
0000000000000000000000000000000000000000000000000000000000000006
4c6f6e646f6e0000000000000000000000000000000000000000000000000000
Strings are array of bytes, the first slot is length in this case 0x00..06 = 6
are the length of our string. The rest are the data of our string, the first six bytes are 4c6f6e646f6e
. Using web3.toAscii("4c6f6e646f6e") == 'London'
.
Best Answer
You can fetch the logs related to transaction using
Eth.get_transaction_receipt(tx_hash)
.web3
should be connected into the network you are using, where the transaction is deployed.From here you can fetch the
logs
, which should return transaction Receipt Event Logs corresponding to here.