Skip to content

Commit

Permalink
timestamp with ms; new versions for the travis
Browse files Browse the repository at this point in the history
  • Loading branch information
kkamkou committed Aug 25, 2020
1 parent 323f13f commit d26da56
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ node_js:
- "7.10"
- "8.16"
- "9.11"
- "10.16"
- "10.22"
- "11.15"
- "12.6"
- "12.18"
- "13.14"
- "14.8"
notifications:
slack:
on_success: never
Expand Down
4 changes: 2 additions & 2 deletions lib/gelf-pro.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ gelf.getAdapter = function () {

/**
* Converts an object to a string, adds custom fields
* @param {Object} message
* @param {Object} obj
* @returns {String}
*/
gelf.getStringFromObject = function (obj) {
var result = {
version: '1.1',
short_message: 'No message', // eslint-disable-line
timestamp: Date.now(),
timestamp: _.round(Date.now() / 1000, 3),
host: os.hostname()
};

Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gelf-pro",
"version": "1.3.3",
"version": "1.3.4",
"main": "./lib/gelf-pro.js",
"typings": "./typings/index.d.ts",
"author": "Kanstantsin Kamkou <kkamkou@gmail.com>",
Expand All @@ -26,8 +26,8 @@
"test": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec; ([ `node -v | cut -d'v' -f2 | cut -d. -f1` -gt 3 ] && (cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage) || true)"
},
"dependencies": {
"async": "2.6.2",
"lodash": "4.17.19"
"async": "~2.6.3",
"lodash": "~4.17.20"
},
"devDependencies": {
"coveralls": "^3.0.2",
Expand Down
9 changes: 8 additions & 1 deletion test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ module.exports = {
result.should.not.have.property('id');
},

'Validate timestamp': function () {
var gelf = _.cloneDeep(gelfOriginal);
sinon.spy(gelf, 'getStringFromObject');
gelf.info('Test message');
("" + JSON.parse(gelf.getStringFromObject.lastCall.returnValue).timestamp)
.should.match(/^\d{10}\.\d{3}$/);
},

'Normalize extra fields': function () {
var mock = sinon.mock(console);
mock.expects('warn').once().withExactArgs('the.first.value: the key format is not valid');
Expand Down Expand Up @@ -128,7 +136,6 @@ module.exports = {
result.should.have.property('_level1_key-with-dash').equal(1);
result.should.have.property('_level1_level2_value2').equal('value2');
result.should.have.property('_level1_level2_level3_value3').equal('value3');

},

'Avoid an empty message': function (done) {
Expand Down

0 comments on commit d26da56

Please sign in to comment.