Skip to content

Commit

Permalink
Console like aliases, closes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
kkamkou committed Mar 1, 2016
1 parent 9eca654 commit 419a224
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ language: node_js
node_js:
- "0.11"
- "0.12"
- "1.0"
- "1.8"
- "2.0"
- "2.5"
- "3.0"
- "3.3"
- "4.0"
- "4.1"
- "4.3"
- "5.0"
- "5.7"
notifications:
slack:
on_success: never
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The Graylog Extended Log Format. Pro - because of code-quality.
## Installation
```
"dependencies": {
"gelf-pro": "~0.3"
"gelf-pro": "~0.4"
}
```
```npm install gelf-pro```
Expand Down Expand Up @@ -45,7 +45,7 @@ log.info(new Error('An error message'));
```

### Levels
```emergency```, ```alert```, ```critical```, ```error```, ```warning```, ```notice```, ```info```, ```debug```
`emergency`, `alert`, `critical`, `error`, `warning` (`warn`), `notice`, `info`, `debug` (`log`)

### Adapters

Expand Down
5 changes: 5 additions & 0 deletions lib/gelf-pro.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,9 @@ gelf.send = function (message, cb) {
};
}.bind(gelf));

// aliases for to be compatible with the console
_.forEach({log: 'debug', warn: 'warning'}, function (from, to) {
this[to] = this[from];
}.bind(gelf));

module.exports = gelf;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gelf-pro",
"version": "0.3.0",
"version": "0.4.0",
"main": "./lib/gelf-pro.js",
"author": "Kanstantsin Kamkou <[email protected]>",
"description": "The Graylog Extended Log Format for the Node.js",
Expand Down
16 changes: 15 additions & 1 deletion test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ var getAdapter = function (name) {
return require(path.join('..', 'lib', 'adapter', name));
};

// tests
module.exports = {
'Core functionality': {
'Default adapter functionality': function () {
Expand All @@ -32,6 +31,21 @@ module.exports = {
adapter.send.should.be.a.Function();
},

'Predefined levels': function () {
var levels = {
emergency: 0, alert: 1, critical: 2, error: 3, warning: 4, warn: 4, notice: 5, info: 6,
debug: 7, log: 7
};

var gelf = _.cloneDeep(gelfOriginal);
sinon.spy(gelf, 'getStringFromObject');

_.forEach(levels, function (lvl, fnc) {
gelf[fnc]('test');
JSON.parse(gelf.getStringFromObject.lastCall.returnValue).level.should.equal(lvl);
});
},

'Predefined fields': function () {
var gelf = _.cloneDeep(gelfOriginal),
mock = sinon.mock(gelf);
Expand Down

0 comments on commit 419a224

Please sign in to comment.