Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Understanding parser plugins #13

Open
somewhere-or-other opened this issue Oct 19, 2016 · 3 comments
Open

Understanding parser plugins #13

somewhere-or-other opened this issue Oct 19, 2016 · 3 comments

Comments

@somewhere-or-other
Copy link

I'm playing around with this project for logfile parsing, and am struggling with having more than 1 parsing function, especially in more than 1 file. I'm not sure if I have something misconfigured, or if I just don't understand the underlying plugin design.

As an example, look at this simplified testcase

Essentially, I've created 2 files, with 2 dumb-as-can-be "parsing" functions in them. Each function prints out a simple debugging line, so we know what function is getting called.

Then I run using this syntax:

python parsible.py --batch-mode true --log-file <(echo "test line")

And I get this result:

DEBUGGING: function parse_test2 got line: test line

If I move the "parse_tes12.py" file aside, the same syntax gives me this result:

DEBUGGING: function parse_test4 got line: test line

So, I guess the question is this: Is this by design? Am I supposed to only have 1 parsing function total? Or do I have something misconfigured?

Thanks,
Lloyd

@somewhere-or-other
Copy link
Author

The same does not seem to be the case with processor plugins. At least I have successfully had 2 of them in the same file, and they both seem to be called. I haven't yet tried multiple files containing processors. That's why I wondered if I was doing something wrong.

@andrewgross
Copy link
Contributor

Hey,

It's been a while since I worked on this, however it looks like it just uses the first parse function it finds when importing[1], unless one has been specified using the --parser CLI switch[2]. For the processors it keeps a list of all of the ones it finds and runs them all.

  1. https://github.com/Yipit/parsible/blob/master/parsible.py#L35-L41
  2. https://github.com/Yipit/parsible/blob/master/parsible.py#L214-L219

@somewhere-or-other
Copy link
Author

Okay. Good to know.

In this specific case, I can make it work, just by using several regex matches in an if..elif..elif..else sort of structure. In the future, I may look at patching this to handle more than 1 parser, but I'm not sure I'm up for it at the moment.

Thanks for the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants