Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use winston 3.x by default #53

Merged
merged 17 commits into from Feb 12, 2019

Modified test suite and updated deps.

  • Loading branch information
OtterCode authored and Filip Elias committed Jan 24, 2019
commit e3866c9dacad192dfcb5b33b51edbd2708bb06fc

Some generated files are not rendered by default. Learn more.

@@ -28,6 +28,7 @@
],
"dependencies": {
"node-loggly-bulk": "2.2.3-beta",
"clone": "^2.1.1",
"winston": "^3.0",
"winston-transport": "^4.2.0"
},
@@ -0,0 +1,70 @@
const winston = require('winston');
module.exports.testLevels = function (transport, assertMsg, assertFn) {
var tests = {};
const levels = winston.config.npm.levels;

Object.keys(levels).forEach(function (level) {
var test = {
topic: function () {
transport.log(level, 'test message', {}, this.callback.bind(this, null));
}
};

test[assertMsg] = assertFn;
tests['with the ' + level + ' level'] = test;
});

var metadatatest = {
topic: function () {
transport.log('info', 'test message', { metadata: true }, this.callback.bind(this, null));
}
};

metadatatest[assertMsg] = assertFn;
tests['when passed metadata'] = metadatatest;

var primmetadatatest = {
topic: function () {
transport.log('info', 'test message', 'metadata', this.callback.bind(this, null));
}
};

primmetadatatest[assertMsg] = assertFn;
tests['when passed primitive metadata'] = primmetadatatest;

// circular references aren't supportded by regular JSON, and it's not supported
// by node-loggly-bulk. I'm omitting it for now. If it wants to be fixed, then
// node-loggly-bulk needs an update.
/*
var circmetadata = { };
circmetadata['metadata'] = circmetadata;
var circmetadatatest = {
topic: function () {
transport.log('info', 'circular message', circmetadata, this.callback.bind(this, null));
}
};
circmetadatatest[assertMsg] = assertFn;
tests['when passed circular metadata'] = circmetadatatest;
var circerror = new Error("message!");
var foo = {};
var circerrordatatest;
foo.bar = foo;
circerror.foo = foo;
circerror.stack = 'Some stacktrace';
circerrordatatest = {
topic: function () {
transport.log('info', 'circular error', circerror, this.callback.bind(this, null));
}
};
circerrordatatest[assertMsg] = assertFn;
tests['when passed circular error as metadata'] = circerrordatatest;
*/

return tests;
};
@@ -6,11 +6,9 @@
*
*/

var path = require('path'),
vows = require('vows'),
var vows = require('vows'),
assert = require('assert'),
winston = require('winston'),
helpers = require('winston/test/helpers'),
helpers = require('./helpers.js'),
Loggly = require('../lib/winston-loggly').Loggly;

var tokenTransport,
@@ -20,8 +18,8 @@ try {
config = require('./config');
}
catch (ex) {
console.log('Error reading test/config.json.')
console.log('Are you sure it exists?\n');
console.error('Error reading test/config.json.')
console.error('Are you sure it exists?\n');
console.dir(ex);
process.exit(1);
}
@@ -31,6 +29,9 @@ tokenTransport = new (Loggly)({
token: config.transports.loggly.token
});

tokenTransport.log('warning', 'test message', {}, (_err, _res) => {
})

function assertLoggly(transport) {
assert.instanceOf(transport, Loggly);
assert.isFunction(transport.log);
@@ -42,10 +43,10 @@ vows.describe('winston-loggly').addBatch({
"should have the proper methods defined": function () {
assertLoggly(tokenTransport);
},
"the log() method": helpers.testNpmLevels(tokenTransport, "should log messages to loggly", function (ign, err, logged) {
"the log() method": helpers.testLevels(tokenTransport, "should log messages to loggly", function (ign, err, logged) {
assert.isNull(err);
assert.isTrue(logged);
})
}
}
}).export(module);
}).export(module);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.