Skip to content

Commit

Permalink
Update examples following refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Shakeel Mohamed committed Nov 17, 2015
1 parent 4faf827 commit dab006b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 31 deletions.
8 changes: 2 additions & 6 deletions examples/all_batching.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@

/**
* This example shows how to batch events with the
* SplunkLogger with all available settings.
*
* By default autoFlush is enabled.
*
* By disabling autoFlush, events will be queued
* until flush() is called.
* SplunkLogger with all available settings:
* batchInterval, maxBatchCount, & maxBatchSize.
*/

// Change to require("splunk-logging").Logger;
Expand Down
9 changes: 4 additions & 5 deletions examples/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ var SplunkLogger = require("../index").Logger;
*/
var config = {
token: "your-token-here",
url: "https://localhost:8088",
maxBatchCount: 1 // Send events 1 at a time
url: "https://localhost:8088"
};

// Create a new logger
Expand All @@ -50,7 +49,7 @@ var payload = {
source: "chicken coop",
sourcetype: "httpevent",
index: "main",
host: "farm.local",
host: "farm.local"
},
// Severity is also optional
severity: "info"
Expand All @@ -59,8 +58,8 @@ var payload = {
console.log("Sending payload", payload);

/**
* Since maxBatchCount is set to 1, calling send
* will immediately send the payload.
* Since maxBatchCount is set to 1 by default,
* calling send will immediately send the payload.
*
* The underlying HTTP POST request is made to
*
Expand Down
27 changes: 15 additions & 12 deletions examples/custom_format.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ Logger.error = function(err, context) {
* be whatever was passed to Logger.send().
* Severity will always be a string.
*
* In this example, we're
* In this example, we're building up a string
* of key=value pairs if message is an object,
* otherwise the message value is as value for
* the message key.
* This string is prefixed with the event
* severity in square brackets.
*/
Logger.eventFormatter = function(message, severity) {
var event = "[" + severity + "]";
Expand All @@ -58,7 +63,7 @@ Logger.eventFormatter = function(message, severity) {
}
}
else {
event += "message=" + message + " ";
event += "message=" + message;
}

return event;
Expand All @@ -76,7 +81,7 @@ var payload = {
source: "chicken coop",
sourcetype: "httpevent",
index: "main",
host: "farm.local",
host: "farm.local"
},
// Severity is also optional
severity: "info"
Expand All @@ -85,8 +90,8 @@ var payload = {
console.log("Sending payload", payload);

/**
* Since maxBatchCount is set to 1, calling send
* will immediately send the payload.
* Since maxBatchCount is set to 1 by default,
* calling send will immediately send the payload.
*
* The underlying HTTP POST request is made to
*
Expand All @@ -95,13 +100,11 @@ console.log("Sending payload", payload);
* with the following body
*
* {
* "metadata": {
* "source": "chicken coop",
* "sourcetype": "httpevent",
* "index": "main",
* "host": "farm.local"
* },
* "event": "[info]temperature=70F, chickenCount=500"
* "source": "chicken coop",
* "sourcetype": "httpevent",
* "index": "main",
* "host": "farm.local",
* "event": "[info]temperature=70F chickenCount=500 "
* }
*
*/
Expand Down
11 changes: 5 additions & 6 deletions examples/manual_batching.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
/**
* This example shows how to batch events with the
* SplunkLogger by manually calling flush.
* By default autoFlush is enabled.
*
* By disabling autoFlush, events will be queued
* By setting maxbatchCount=0, events will be queued
* until flush() is called.
*/

Expand All @@ -29,12 +28,12 @@ var SplunkLogger = require("../index").Logger;
/**
* Only the token property is required.
*
* Here, autoFlush is set to false.
* Here, maxBatchCount is set to 0.
*/
var config = {
token: "your-token-here",
url: "https://localhost:8088",
autoFlush: false // Manually flush events
maxBatchCount: 0 // Manually flush events
};

// Create a new logger
Expand All @@ -57,7 +56,7 @@ var payload = {
source: "chicken coop",
sourcetype: "httpevent",
index: "main",
host: "farm.local",
host: "farm.local"
},
// Severity is also optional
severity: "info"
Expand All @@ -81,7 +80,7 @@ console.log("Queuing second payload", payload2);
Logger.send(payload2);

/**
* Since autoFlush is disabled, call flush manually.
* Call flush manually.
* This will send both payloads in a single
* HTTP request.
*
Expand Down
2 changes: 1 addition & 1 deletion examples/retry.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ var payload = {
source: "chicken coop",
sourcetype: "httpevent",
index: "main",
host: "farm.local",
host: "farm.local"
},
// Severity is also optional
severity: "info"
Expand Down
1 change: 0 additions & 1 deletion splunklogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ SplunkLogger.prototype._disableTimer = function() {
}
};

// TODO: update doc
/**
* Configures an interval timer to flush any events in
* <code>this.serializedContextQueue</code> at the specified interval.
Expand Down

0 comments on commit dab006b

Please sign in to comment.