Comparing version 1.0.2 to 1.0.3
@@ -61,2 +61,3 @@ /* | ||
log: [url, 'inputs', this.token].join('/'), | ||
bulk: [url, 'bulk', this.token].join('/'), | ||
api: 'https://' + [this.subdomain, 'loggly', 'com'].join('.') + '/' + api | ||
@@ -87,14 +88,23 @@ }; | ||
if (msg instanceof Object) { | ||
msg = this.json ? JSON.stringify(msg) : common.serialize(msg); | ||
} | ||
else { | ||
msg = this.json ? JSON.stringify({ message : msg }) : msg; | ||
} | ||
var self = this, | ||
logOptions; | ||
// | ||
// Remark: Have some extra logic for detecting if we want to make a bulk | ||
// request to loggly | ||
// | ||
var isBulk = Array.isArray(msg); | ||
function serialize (msg) { | ||
if (msg instanceof Object) { | ||
return self.json ? JSON.stringify(msg) : common.serialize(msg); | ||
} | ||
else { | ||
return self.json ? JSON.stringify({ message : msg }) : msg; | ||
} | ||
}; | ||
msg = isBulk ? msg.map(serialize).join('\n') : serialize(msg); | ||
logOptions = { | ||
uri: this.urls.log, | ||
uri: isBulk ? this.urls.bulk : this.urls.log, | ||
method: 'POST', | ||
@@ -101,0 +111,0 @@ body: msg, |
{ | ||
"name": "loggly", | ||
"description": "A client implementation for Loggly cloud Logging-as-a-Service API", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"author": "Nodejitsu Inc. <info@nodejitsu.com>", | ||
@@ -6,0 +6,0 @@ "maintainers": [ |
@@ -94,2 +94,9 @@ # node-loggly | ||
### Logging arrays | ||
It is possible to send arrays, which will result in one single request to Loggly. | ||
``` js | ||
input.log([ {iam:'number 1'}, {iam:'number 2'} ]) | ||
``` | ||
### Searching | ||
@@ -96,0 +103,0 @@ [Searching][search-api] with node-loggly is easy. All you have to do is use the search() method defined on each Loggly client: |
@@ -142,2 +142,23 @@ /* | ||
} | ||
}).addBatch({ | ||
"When using the node-loggly client without authentication": { | ||
"the log() method": { | ||
"takes an array": { | ||
"when not passed a callback": { | ||
topic: function () { | ||
logglyJSON.log([ | ||
{ work: 'it harder' }, | ||
{ make: 'it better' } | ||
]); | ||
logglyJSON.on('log', this.callback.bind(null, null)); | ||
}, | ||
"should log messages to loggly": function (err, result) { | ||
assert.isNull(err); | ||
assert.isObject(result); | ||
assert.equal(result.response, 'ok'); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}).export(module); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31632
861
166