From fee0cdbb6f30d8d7729c29e8f401ed9e211ae1a2 Mon Sep 17 00:00:00 2001 From: Kanstantsin Kamkou Date: Mon, 4 Apr 2016 10:34:39 +0200 Subject: [PATCH] accept-encoding: the key format is not valid, closes #11; closes #12 --- README.md | 1 + lib/gelf-pro.js | 2 +- package.json | 8 ++++---- test/tests.js | 7 ++++++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index bb90da1..7f3f7cf 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ log.info(new Error('An error message')); ##### Extra In case `extra` [is a plain object](https://lodash.com/docs#isPlainObject), the library converts it to a readable format. Other values [are converted to string](https://lodash.com/docs#toString). +Acceptable format is: `^[\w.-]$` ```javascript log.info( 'a new msg goes here', diff --git a/lib/gelf-pro.js b/lib/gelf-pro.js index 0808879..74defaf 100644 --- a/lib/gelf-pro.js +++ b/lib/gelf-pro.js @@ -84,7 +84,7 @@ gelf.getStringFromObject = function (obj) { // recursion function for key-value aggregation var recursion = function (input, prefix) { _.forOwn(input, function (value, key) { - if ((/[^\w]/).test(key)) { + if ((/[^\w.-]/).test(key)) { console.warn(key + ': the key format is not valid'); } if (_.isPlainObject(value)) { diff --git a/package.json b/package.json index 6f94095..32e8b74 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gelf-pro", - "version": "0.6.2", + "version": "0.6.3", "main": "./lib/gelf-pro.js", "author": "Kanstantsin Kamkou ", "description": "The Graylog Extended Log Format for the Node.js", @@ -22,15 +22,15 @@ "test": "./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage" }, "dependencies": { - "lodash": "~4.5", + "lodash": "~4.7", "async": "~1.5" }, "devDependencies": { "istanbul": "~0.4.2", - "should": "~8.2", + "should": "~8.3", "mocha": "~2.4", "mocha-lcov-reporter": "~1.2.0", - "coveralls": "~2.11.8", + "coveralls": "~2.11", "sinon": "~1.17" } } diff --git a/test/tests.js b/test/tests.js index 179d0ad..fb0d039 100644 --- a/test/tests.js +++ b/test/tests.js @@ -94,7 +94,9 @@ module.exports = { level2: { level3: {value3: 'value3'}, value2: 'value2' - } + }, + 'key.with.dot': 1, + 'key-with-dash': 1 } }); @@ -103,8 +105,11 @@ module.exports = { result = JSON.parse(result); result.should.have.property('_value0').equal('value0'); result.should.have.property('_level1_value1').equal('value1'); + result.should.have.property('_level1_key.with.dot').equal(1); + 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'); + }, 'Work with dates': function () {