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

getPattern and loadDefault misbehaving #18

Open
dankearns opened this issue Feb 14, 2017 · 1 comment
Open

getPattern and loadDefault misbehaving #18

dankearns opened this issue Feb 14, 2017 · 1 comment

Comments

@dankearns
Copy link

I have some sample code which seems like it should work, but does not:

'use strict';
const grok = require('node-grok');
const patterns = grok.loadDefaultSync(["grok-patterns","linux-syslog"]);
const test = "<34>1 2003-10-11T22:14:15.003Z mymachine.example.com su - ID47 - message"
const pattern = patterns.getPattern('SYSLOG5424LINE');
const parsed = pattern.parseSync(test);
console.log(parsed); // "null"

If I make this change, it works. Is it a bug or pilot error?

index 0de33ff..353e506 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -171,7 +171,7 @@ function GrokCollection() {
     };

     t.getPattern = function (id) {
-        return patterns.get(id);
+        return resolvePattern(patterns.get(id));
     };
@michaelb87
Copy link

This helped me a lot. Appears to be a bug in the library..

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

Successfully merging a pull request may close this issue.

2 participants