Skip to content

Commit

Permalink
Loggly: Add documentation/formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
TomFrost committed Jun 20, 2014
1 parent 4586c4f commit 8309641
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,35 @@ Outputs:
event: bootstrap:welcome
```

#### Available formatters
### Available formatters
- **human:** Multi-line messages suitable for humans during development
- **json:** One line per message, valid json
- **syslog:** Syslog-compliant format, single-line
- **commonInfoModel:** Common Info Model format, friendly to many log
aggregators. More human-readable than JSON with similar benefits. One
line per message.

### Available targets
#### console
Outputs directly to stdout using console.log() to ensure writes are blocking
and synchronous. This is _excellent_ for debugging, but is not recommended in
production as this is not performant. There are no options for this target.

#### file
Streams output to a file using a logrotate-friendly WriteStream. Required
options:
- **file** *string:* The full path to the file to be created or opened

#### loggly
Pushes new messages directly to the Loggly API. Required options:
- **token** *string:* Your loggly token
- **subdomain** *string:* Your registered Loggly subdomain
- **username** *string:* Loggly username
- **password** *string:* Loggly password

Optional:
- **tags** *Array|string:* Global Loggly tags

### Severity levels
By default, Bristol provides *error*, *warn*, *info*, *debug*, and *trace*
severity levels. These can be called as function names from the log object,
Expand Down
9 changes: 4 additions & 5 deletions lib/targets/loggly.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ var logglyClients = {};

function getLogglyClient(token, subdomain, username, password, tags) {
var cid = token + subdomain;

if (!logglyClients[cid]) {
var opts = {
token: token,
Expand All @@ -27,7 +26,6 @@ function getLogglyClient(token, subdomain, username, password, tags) {
}
logglyClients[cid] = loggly.createClient(opts);
}

return logglyClients[cid];
}

Expand All @@ -38,16 +36,17 @@ function getLogglyClient(token, subdomain, username, password, tags) {
* @param {string} options.subdomain Loggly subdomain
* @param {string} options.username Loggly username
* @param {string} options.password Loggly password
* @param {Array|string} options.tags Global Loggly tags
* @param {Array|string} [options.tags] Global Loggly tags
* @param {string} severity The severity of the log message
* @param {Date} date The date of the log message
* @param {string} message The message to be pushed to loggly
*/
function log(options, severity, date, message) {
var client = getLogglyClient(options.token, options.subdomain, options.username, options.password, options.tags),
var client = getLogglyClient(options.token, options.subdomain,
options.username, options.password, options.tags),
tags = options.tags || null;

client.log(message, tags, function(err, result) {
client.log(message, tags, function(err) {
if (err) {
console.log("Error publishing log message to Loggly: " + err +
"Message was: " + message);
Expand Down

0 comments on commit 8309641

Please sign in to comment.