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

Fix undefined issue while logging from node-loggly-bulk library #11

Merged
merged 3 commits into from
Jun 6, 2017

Conversation

Shwetajain148
Copy link

I debugged code with node-loggly-bulk library and found that type of msg is a string which should be an object(winston-loggly-bulk library is sending log data to node-loggly-bulk in object form). That's why the value of msg.message object was undefined.

From node version 7.0.0, node will throw an error when we will pass invalid input to Buffer.byteLength.

Ref: https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V7.md#7.0.0
Merged PR: nodejs/node#8946

In this PR I have put a condition to check if the msg is a string (If we are logging using node-loggly-bulk) and then converting to an object. So both library will work correctly.

It will fix the issue #10.

@Shwetajain148
Copy link
Author

I have tested below scenarios with both node-loggly-bulk and winston-loggly-bulk libraries.

log type node-loggly-bulk winston-loggly-bulk
Sending string Working fine Working fine
Sending JSON Working fine Working fine
Event Truncation Working fine Working fine

@mostlyjason
Copy link

When you test sending JSON, does Loggly parse the JSON automatically?

@Shwetajain148
Copy link
Author

@mostlyjason Yes, Loggly parsed the JSON with both node-loggly-bulk and winston-loggly-bulk libraries. See the below examples with parsed JSON screenshots.

winston-loggly-bulk library:

I am sending JSON data:

var source = {
    foo: 1,
    bar: 2,
    buzz: {
      sheep: 'jumped',
      times: 10
    }
  };

winston.log('info', source);

JSON parsed result on Loggly:

winston-loggly-bulk-json-parsing

node-loggly-bulk library:

I am sending JSON data:

var source = {
    foo: 1,
    bar: 2,
    buzz: {
      sheep: 'jumped',
      times: 10
    }
  };

input.log(source);

JSON parsed result on Loggly:

node-loggly-bulk-json-parsing

@mchaudhary mchaudhary merged commit 210f451 into loggly:master Jun 6, 2017
@Shwetajain148 Shwetajain148 deleted the resolve-TypeError branch June 7, 2017 10:57
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 this pull request may close these issues.

3 participants