Pushing changes
This commit is contained in:
33
node_modules/log4js/test/tape/default-settings-test.js
generated
vendored
Normal file
33
node_modules/log4js/test/tape/default-settings-test.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
var test = require('tape')
|
||||
, sandbox = require('sandboxed-module');
|
||||
|
||||
test('default settings', function(t) {
|
||||
var output = []
|
||||
, log4js = sandbox.require(
|
||||
'../../lib/log4js',
|
||||
{
|
||||
requires: {
|
||||
'./appenders/stdout': {
|
||||
'name': 'stdout',
|
||||
'appender': function () {
|
||||
return function(evt) {
|
||||
output.push(evt);
|
||||
};
|
||||
},
|
||||
'configure': function (config) {
|
||||
return this.appender();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
, logger = log4js.getLogger("default-settings");
|
||||
|
||||
logger.info("This should go to stdout.");
|
||||
|
||||
t.plan(2);
|
||||
t.equal(output.length, 1, "It should log to stdout.");
|
||||
t.equal(output[0].data[0], "This should go to stdout.", "It should log the message.");
|
||||
t.end();
|
||||
});
|
37
node_modules/log4js/test/tape/file-sighup-test.js
generated
vendored
Normal file
37
node_modules/log4js/test/tape/file-sighup-test.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
var test = require('tape')
|
||||
, sandbox = require('sandboxed-module');
|
||||
|
||||
test('file appender SIGHUP', function(t) {
|
||||
var closeCalled = 0
|
||||
, openCalled = 0
|
||||
, appender = sandbox.require(
|
||||
'../../lib/appenders/file',
|
||||
{
|
||||
'requires': {
|
||||
'streamroller': {
|
||||
'RollingFileStream': function() {
|
||||
this.openTheStream = function() {
|
||||
openCalled++;
|
||||
};
|
||||
|
||||
this.closeTheStream = function(cb) {
|
||||
closeCalled++;
|
||||
cb();
|
||||
};
|
||||
|
||||
this.on = function() {};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
).appender('sighup-test-file');
|
||||
|
||||
process.kill(process.pid, 'SIGHUP');
|
||||
t.plan(2);
|
||||
setTimeout(function() {
|
||||
t.equal(openCalled, 1, 'open should be called once');
|
||||
t.equal(closeCalled, 1, 'close should be called once');
|
||||
t.end();
|
||||
}, 10);
|
||||
});
|
30
node_modules/log4js/test/tape/multiprocess-shutdown-test.js
generated
vendored
Normal file
30
node_modules/log4js/test/tape/multiprocess-shutdown-test.js
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
var test = require('tape')
|
||||
, log4js = require('../../lib/log4js')
|
||||
, net = require('net');
|
||||
|
||||
test('multiprocess appender shutdown (master)', function(t) {
|
||||
log4js.configure({
|
||||
appenders: [
|
||||
{
|
||||
type: "multiprocess",
|
||||
mode: "master",
|
||||
loggerPort: 12345,
|
||||
appender: { type: "stdout" }
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
t.timeoutAfter(1000, "shutdown did not happen within 1000ms");
|
||||
setTimeout(function() {
|
||||
log4js.shutdown(function() {
|
||||
var connection = net.connect({ port: 12345 }, function() {
|
||||
t.fail("connection should not still work");
|
||||
t.end();
|
||||
}).on('error', function(err) {
|
||||
t.ok(err, 'we got a connection error');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
}, 500);
|
||||
});
|
33
node_modules/log4js/test/tape/reload-shutdown-test.js
generated
vendored
Normal file
33
node_modules/log4js/test/tape/reload-shutdown-test.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
var test = require('tape')
|
||||
, path = require('path')
|
||||
, sandbox = require('sandboxed-module');
|
||||
|
||||
test('Reload configuration shutdown hook', function(t) {
|
||||
var timerId
|
||||
, log4js = sandbox.require(
|
||||
'../../lib/log4js',
|
||||
{
|
||||
globals: {
|
||||
clearInterval: function(id) {
|
||||
timerId = id;
|
||||
},
|
||||
setInterval: function(fn, time) {
|
||||
return "1234";
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
log4js.configure(
|
||||
path.join(__dirname, 'test-config.json'),
|
||||
{ reloadSecs: 30 }
|
||||
);
|
||||
|
||||
t.plan(1);
|
||||
log4js.shutdown(function() {
|
||||
t.equal(timerId, "1234", "Shutdown should clear the reload timer");
|
||||
t.end();
|
||||
});
|
||||
|
||||
});
|
22
node_modules/log4js/test/tape/stderrAppender-test.js
generated
vendored
Normal file
22
node_modules/log4js/test/tape/stderrAppender-test.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
var test = require('tape')
|
||||
, layouts = require('../../lib/layouts')
|
||||
, sandbox = require('sandboxed-module');
|
||||
|
||||
test('stderr appender', function(t) {
|
||||
var output = []
|
||||
, appender = sandbox.require(
|
||||
'../../lib/appenders/stderr',
|
||||
{
|
||||
globals: {
|
||||
process: { stderr: { write : function(data) { output.push(data); } } }
|
||||
}
|
||||
}
|
||||
).appender(layouts.messagePassThroughLayout);
|
||||
|
||||
appender({ data: ["biscuits"] });
|
||||
t.plan(2);
|
||||
t.equal(output.length, 1, 'There should be one message.');
|
||||
t.equal(output[0], 'biscuits\n', 'The message should be biscuits.');
|
||||
t.end();
|
||||
});
|
22
node_modules/log4js/test/tape/stdoutAppender-test.js
generated
vendored
Normal file
22
node_modules/log4js/test/tape/stdoutAppender-test.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
var test = require('tape')
|
||||
, layouts = require('../../lib/layouts')
|
||||
, sandbox = require('sandboxed-module');
|
||||
|
||||
test('stdout appender', function(t) {
|
||||
var output = []
|
||||
, appender = sandbox.require(
|
||||
'../../lib/appenders/stdout',
|
||||
{
|
||||
globals: {
|
||||
process: { stdout: { write : function(data) { output.push(data); } } }
|
||||
}
|
||||
}
|
||||
).appender(layouts.messagePassThroughLayout);
|
||||
|
||||
appender({ data: ["cheese"] });
|
||||
t.plan(2);
|
||||
t.equal(output.length, 1, 'There should be one message.');
|
||||
t.equal(output[0], 'cheese\n', 'The message should be cheese.');
|
||||
t.end();
|
||||
});
|
5
node_modules/log4js/test/tape/test-config.json
generated
vendored
Normal file
5
node_modules/log4js/test/tape/test-config.json
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"appenders": [
|
||||
{ "type": "stdout" }
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user