Skip to content

Commit

Permalink
moves useTextAsTitle from transport.options to transport to reduce ne…
Browse files Browse the repository at this point in the history
…twork out
  • Loading branch information
sparkida committed Nov 27, 2017
1 parent 32a79c1 commit bc32d1c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ logger.on('DatadogResult', (res) => {
### Event Options
```javascript
var ddTransport = new Datadog({ ... });
//set the new title to use
//have the text be used in place of title (default: false)
ddTransport.useTextAsTitle = true;
//or...set the new title to use
ddTransport.options.title = 'My Custom Title';
//or...optionally use text as title (default: false)
ddTransport.options.useTextAsTitle = true;
//set the new tags to use
ddTransport.options.tags = ['env:local', 'version:1', 'region:us-west-1'];

Expand Down Expand Up @@ -117,7 +117,6 @@ Options
Each Datadog Transport instance will expose the following options via `ddTransport.options`

- **title** ***[default=LOG]*** - The event title. Limited to 100 characters.
- **useTextAsTitle** ***[default=false]*** - Set to force transport to use the text as the title, [see PR#2](https://github.com/sparkida/winston-datadog/pull/2)
- **date_happened** ***[optional, default=now]*** - POSIX timestamp of the event.
- **priority** ***[optional, default='normal']*** - The priority of the event ('normal' or 'low').
- **host** ***[optional, default=os.hostname()]*** - Host name to associate with the event.
Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class Transport { //jshint ignore:line
var paths = Transport.API_ENDPOINT.split('/').filter(Boolean);
api.name = 'Datadog';
api.attachResults = false;
//set to true to force transport to use text in place of the title
api.useTextAsTitle = false;
api.requestOptions = {
port: paths[0] === 'https:' ? 443 : 80,
hostname: paths[1],
Expand Down Expand Up @@ -93,7 +95,7 @@ class Transport { //jshint ignore:line
var opts = api.options;
opts.alert_type = loglevel;

if (opts.useTextAsTitle) {
if (api.useTextAsTitle) {
opts.title = text;
}

Expand Down Expand Up @@ -141,7 +143,6 @@ class TransportOptions {
var opts = this;
return {
title: opts.title,
useTextAsTitle: opts.useTextAsTitle,
priority: opts.priority,
date_happened: opts.date_happened,
host: opts.host,
Expand All @@ -153,7 +154,6 @@ class TransportOptions {
}
}
TransportOptions.prototype.title = 'LOG';
TransportOptions.prototype.useTextAsTitle = false;
TransportOptions.prototype.priority = 'normal'; // or low
TransportOptions.prototype.date_happened = null;
TransportOptions.prototype.host = hostname;
Expand Down

0 comments on commit bc32d1c

Please sign in to comment.