Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #96 from Souler/master
Browse files Browse the repository at this point in the history
Support Winston 2 log levels
  • Loading branch information
bathos committed Jan 24, 2016
2 parents 6b7c193 + 648505e commit db4e77a
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 6 deletions.
15 changes: 15 additions & 0 deletions npm-shrinkwrap.json

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

11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"babel-runtime": "5.4.7",
"codependency": "0.1.4",
"json-stringify-safe": "5.0.1",
"lodash": "3.9.3"
"lodash": "3.9.3",
"semver": "^5.1.0"
},
"devDependencies": {
"babel-eslint": "^3.1.23",
Expand All @@ -59,9 +60,13 @@
"mitm": "^1.1.0",
"tap-spec": "^3.0.0",
"tape": "^4.0.0",
"winston": "^1.0.0"
"winston": "^1.0.0",
"winston1": "^1.1.2",
"winston2x": "^2.1.1"
},
"optionalPeerDependencies": {
"winston": "*"
"winston": "*",
"winston1": "*",
"winston2x": "*"
}
}
22 changes: 19 additions & 3 deletions src/node_modules/logger.js

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

90 changes: 90 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ var Logger = require('../lib/node_modules/logger.js');
var mitm = require('mitm');
var tape = require('tape');
var winston = require('winston');
var winston1 = require('winston1');
var winston2 = require('winston2x');

// FAKE TOKEN //////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -585,6 +587,94 @@ tape("Winston supports json logging.", function(t) {
logger.warn("msg", {foo: "bar"});
});

tape('Winston@1.1.2 integration is provided.', function(t) {
t.plan(4);
t.timeoutAfter(2000);

t.true(winston1.transports.Logentries,
'provisioned constructor automatically');

t.doesNotThrow(function() {
winston1.add(winston1.transports.Logentries, { token: x });
}, 'transport can be added');

winston1.remove(winston1.transports.Console);

mockTest(function(data) {
t.pass('winston log transmits');
t.equal(data, x + ' warn mysterious radiation\n', 'msg as expected');
});

winston1.warn('mysterious radiation');
});

tape("Winston@1.1.2 supports json logging.", function(t) {
t.plan(2);
t.timeoutAfter(2000);

var logger = new (winston1.Logger)({
transports: [
new (winston1.transports.Logentries)({ token: x, json: true })
]
});

mockTest(function(data) {
t.pass("winston logs in json format");
var expect = {
message: "msg",
foo: "bar",
level: "warn"
};
t.equal(data, x + " " + JSON.stringify(expect) + '\n', 'json as expected');
});

logger.warn("msg", {foo: "bar"});
});

tape('Winston@2.1.1 integration is provided.', function(t) {
t.plan(4);
t.timeoutAfter(2000);

t.true(winston2.transports.Logentries,
'provisioned constructor automatically');

t.doesNotThrow(function() {
winston2.add(winston2.transports.Logentries, { token: x });
}, 'transport can be added');

winston2.remove(winston2.transports.Console);

mockTest(function(data) {
t.pass('winston log transmits');
t.equal(data, x + ' warn mysterious radiation\n', 'msg as expected');
});

winston2.warn('mysterious radiation');
});

tape("Winston@2.1.1 supports json logging.", function(t) {
t.plan(2);
t.timeoutAfter(2000);

var logger = new (winston2.Logger)({
transports: [
new (winston2.transports.Logentries)({ token: x, json: true })
]
});

mockTest(function(data) {
t.pass("winston logs in json format");
var expect = {
message: "msg",
foo: "bar",
level: "warn"
};
t.equal(data, x + " " + JSON.stringify(expect) + '\n', 'json as expected');
});

logger.warn("msg", {foo: "bar"});
});

// BUNYAN STREAM ///////////////////////////////////////////////////////////////

tape('Bunyan integration is provided.', function(t) {
Expand Down

0 comments on commit db4e77a

Please sign in to comment.