Skip to content

Commit

Permalink
Add error property to server logs (#585)
Browse files Browse the repository at this point in the history
* Add error property to server logs

* Updated API documentation to reflect error property in ServerLog
  • Loading branch information
rankida authored and Marsup committed Mar 21, 2018
1 parent 93d6ed0 commit 30441d3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions API.md
Expand Up @@ -151,6 +151,7 @@ Event object associated with 'log' events.
- `timestamp` - JavaScript timestamp indicating when the 'log' event occurred.
- `tags` - array of strings representing any tags associated with the 'log' event.
- `data` - string or object passed via `server.log()` calls.
- `error` - error object, replacing `data` if only an error object is passed to `server.log()`
- `pid` - the current process id.

### `RequestError`
Expand Down
1 change: 1 addition & 0 deletions lib/utils.js
Expand Up @@ -23,6 +23,7 @@ class ServerLog {
this.tags = event.tags;
this.data = event.data;
this.pid = process.pid;
this.error = event.error;
}
}

Expand Down
19 changes: 19 additions & 0 deletions test/utils.js
Expand Up @@ -177,4 +177,23 @@ describe('utils', () => {
expect(parse.error).to.equal('An internal server error occurred');
});
});


describe('ServerLog()', () => {

it('accepts error on the event object when data is not present', { plan: 2 }, () => {

const errorInstance = new Error('This is a test');

const err = new Utils.ServerLog({
event: 'log',
timestamp: 1517592924723,
tags: ['log', 'error'],
error: errorInstance
});

expect(err.error).to.equal(errorInstance);
expect(err.data).to.be.undefined();
});
});
});

0 comments on commit 30441d3

Please sign in to comment.