-- 
Damjan

> On 8 Oct 2018, at 07:37, Aleksander Djuric <aleksander.dju...@gmail.com> 
> wrote:
> 
> Hi Everyone!
> 
> I am trying to parse binary ELOG file, but have no success.
> Is there someone who know something about ELOG file format?
> At now I'm trying to get the unix timestamp of the each event.
> 
> I had found small python script here:
> https://github.com/theleos88/vpp-bench/wiki/ELOG 
> <https://github.com/theleos88/vpp-bench/wiki/ELOG>
> ...but it's not work for me.
> 
> The event definition in my case looks like:
> ELOG_TYPE_DECLARE (el) = {
>       .format = "test [%d]: event",
>       .format_args = "i4",
> };
> 
> Just for test this event prints always number "234"
> For parsing the binary log I had written the code based on the script I have 
> mentioned above:
> 
> #!/usr/bin/python -d
> import io
> import binascii
> import os
> import mmap
> import itertools
> import struct
> import sys
> import time
> infil = '/tmp/test.log'
> def parse_int(itr, size):
>     int_str = []
>     for i in range(0,size):
>         int_str.append( next(itr))
>     d = b"".join(int_str)
>     return int(binascii.hexlify(d), 16)
> def parse_double(itr):
>     int_str = []
>     for i in range(0,8):
>         int_str.append(next(itr))
>     d = b"".join(int_str)
>     return struct.unpack('d', d)[0]
> if __name__ == '__main__':
>     with open(infil, 'rb') as f:
>         # memory-map the file, size 0 means whole file
>         mm = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
>         itr = iter(mm)
>         for b in itr:
>             if (b == b'@'):
>                 try:
>                     e = parse_int(itr, 3)   # Binary file dependent
>                     d = parse_int(itr, 4)   # Data
>                     ts = parse_double(itr)   # Timestamp
>                      print ("Id:",e,"Data",d,"TS",ts)
>                 except:
>                     print ("fail")
>         mm.close()
> 
> The script output looks very strange:
> 
> ('Id:', 12583082, 'Data', 4077750898, 'TS', -2.033971772667215e+189)
> ('Id:', 4913710, 'Data', 234, 'TS', 6.36910374265963e-272)
> ('Id:', 4946789, 'Data', 234, 'TS', -3.781860196468732e+215)
> ('Id:', 4980415, 'Data', 234, 'TS', 2.8913004726712464e+252)
> ('Id:', 5014033, 'Data', 234, 'TS', 1.0459787848697367e-194)
> ('Id:', 5047603, 'Data', 234, 'TS', 1.8541854501616871e+87)
> ('Id:', 5081197, 'Data', 234, 'TS', -1.9417949536011382e+216)
> ('Id:', 5114754, 'Data', 234, 'TS', -1.1766415030126902e-236)
> ('Id:', 5148346, 'Data', 234, 'TS', 2.805116355676246e-134)
> ('Id:', 5181997, 'Data', 234, 'TS', 1.2734961345447485e-257)
> fail
> 
> 1) It seems that the first and the last line of the log has a different 
> format (???).
> 2) I can't understand the format of the timestamp field (or these 8 bytes is 
> not a timestamp).
> 3) Data prints correctly.
> 
> Could anyone help me please?
> Thanks in advance,
> Aleksander

Looking into g2 source might be good start. g2 is GTK based elog graphical 
viewer...

https://git.fd.io/vpp/tree/src/tools/g2 
<https://git.fd.io/vpp/tree/src/tools/g2>

-- 
Damjan

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#10770): https://lists.fd.io/g/vpp-dev/message/10770
Mute This Topic: https://lists.fd.io/mt/26875131/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to