ModelInference / synoptic

Inferring models of systems from observations of their behavior
Other
81 stars 25 forks source link

Log parser not finding matches #408

Open akhirsch-gt opened 8 years ago

akhirsch-gt commented 8 years ago

I have a log that contains the line " 1 al_new: void" (without quotes). I am trying to parse this log with synoptic, with the option-r '(?<TIME>)\\s*al_new:\\s*.+(?<TYPE=>new)'to try to parse it. However, synoptic keeps telling me the line does not parse. When I put the "processed" output into a java file with regex (?:\\s*(\\S+)\\s*)\\s*al_new:\\s*.+, it does parse!

Moreover, the example on your wiki page does not work: it only processes ^hello as a regex, ignoring everything after the space. It then complains that there is no TYPE or STATE assigned in the regex.

Is it possible to fix this, or to write my own parser and use synoptic as a library?

bestchai commented 8 years ago

Thanks for the bug report. I'll look into this issue, but it might take a while.

The quick fix to this is to pre-process your input log using some other text-processing tools, such as awk/sed/perl and then use synoptic on the simpler, post-processed, input log. For example, for the line "1 al_new: void" in your example input, the post-processed log would contain the line "new", which is the TYPE that you'd like synoptic to use (based on your "(?<TYPE=>new)" fragment).

Synoptic can be used as a library, but this is not documented and is fairly involved. If you're interested, take a look at InvariMintSynoptic.java class in the InvariMint project, here: https://github.com/ModelInference/synoptic/blob/master/InvariMint/src/algorithms/InvariMintSynoptic.java This class contains an runStdAlg method that runs the synoptic algorithm using synoptic as a library. You'll have to piece together the library usage by tracing this method and this class in the InvariMint codebase. The bulk of the logic is in the PGraphInvariMint class.

akhirsch-gt commented 8 years ago

After spending some time tracing through your code, I realized (based on seeing how the log printing worked) that the issue was with my command. However, this is partly due to the documentation:

Your wiki uses the example synoptic -r '^hello .+'. However, on Ubuntu 14.04, this is processed as three arguments (without double quotes): "-r", "'^hello", and ".+'". In my case, without the space, I was processing the regex '(?:\\s*(\\S+)\\s*)\\s*al_new:\\s*.+', which didn't match because of the single quotes. If I remove the quotes, then it works.

I'm leaving this open because I still believe that there are two things that should be done: an update to the wiki, and fixing the hello example.