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

Handle undefined tags #40

Merged
merged 1 commit into from Jul 31, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Handle undefined tags

  • Loading branch information
Shweta Jain
Shweta Jain committed Jul 20, 2018
commit 2d4ef58282976a84b2e7278698e5e90ea5498525
@@ -172,9 +172,12 @@ Loggly.prototype.log = function (msg, tags, callback) {
: this.tags;

//
// Optionally send `X-LOGGLY-TAG` if we have them
// Optionally send `X-LOGGLY-TAG` if we have them.
// Set the 'X-LOGGLY-TAG' only when we have actually some tag value.
// The library receives "400 Bad Request" in response when the
// value of 'X-LOGGLY-TAG' is empty string in request header.
//
if (tags) {
if (tags && tags.length) {

This comment has been minimized.

@Shwetajain148

Shwetajain148 Jul 23, 2018
Author

Set the headers['X-LOGGLY-TAG'] property only when we have some actual tag defined into the tag array not undefined.

// Decide whether to add tags as http headers or add them to the URI.
if (this.useTagHeader) {
logOptions.headers['X-LOGGLY-TAG'] = tags.join(',');
@@ -227,7 +230,7 @@ Loggly.prototype.tagFilter = function (tags) {
//
// Remark: length may need to use Buffer.byteLength?
//
return isSolid.test(tag) && tag.length <= 64;
return tag && isSolid.test(tag) && tag.length <= 64;

This comment has been minimized.

@Shwetajain148

Shwetajain148 Jul 23, 2018
Author

Calculate the tag's length only when tag actually has some value otherwise return.

});
};

@@ -147,7 +147,7 @@ common.loggly = function () {
}
}
var requestOptions = {
uri: isBulk ? uri + '/tag/' + headers['X-LOGGLY-TAG'] : uri,
uri: (isBulk && headers['X-LOGGLY-TAG']) ? uri + '/tag/' + headers['X-LOGGLY-TAG'] : uri,

This comment has been minimized.

@Shwetajain148

Shwetajain148 Jul 23, 2018
Author

Add headers['X-LOGGLY-TAG'] property into the request header only when the logging mode is Bulk and headers['X-LOGGLY-TAG'] contains some value. This will prevent logs sending from the undefined tag name.

method: method,
headers: isBulk ? {} : headers || {}, // Set headers empty for bulk
proxy: proxy
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.