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

@Shwetajain148 Shwetajain148 commented May 26, 2017

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

@Shwetajain148 Shwetajain148 commented May 30, 2017

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

@mostlyjason mostlyjason commented May 30, 2017

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

@Shwetajain148
Copy link
Author

@Shwetajain148 Shwetajain148 commented May 31, 2017

@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 Shwetajain148:resolve-TypeError branch Jun 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.