Pass in all appender parameters to the Hook constructor so a port can be specified
This commit is contained in:
parent
07e920cc1b
commit
ced570413c
@ -157,6 +157,7 @@ This was mainly created for [cluster](https://github.com/LearnBoost/cluster), bu
|
|||||||
.use(cluster.pidfiles('run/pids'))
|
.use(cluster.pidfiles('run/pids'))
|
||||||
.listen(3000);
|
.listen(3000);
|
||||||
</pre>
|
</pre>
|
||||||
|
log4js-master/worker.json hookio appender parameters will be passed into the Hook constructor directly, so you can specify hook-port, hook-host etc.
|
||||||
*NOTE* hook.io appender will currently (and probably indefinitely) explode if you enable hook.io debug because of the way log4js overrides console.log
|
*NOTE* hook.io appender will currently (and probably indefinitely) explode if you enable hook.io debug because of the way log4js overrides console.log
|
||||||
|
|
||||||
## author (of this node version)
|
## author (of this node version)
|
||||||
|
@ -23,14 +23,14 @@ function deserializeLoggingEvent(loggingEvent) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function createAppender(hookioOptions, actualAppender) {
|
function createAppender(hookioOptions) {
|
||||||
var loggerHook;
|
var loggerHook;
|
||||||
if (hookioOptions.mode === 'master') {
|
if (hookioOptions.mode === 'master') {
|
||||||
// Start the master hook, handling the actual logging
|
// Start the master hook, handling the actual logging
|
||||||
loggerHook = new Logger({ name: hookioOptions.name, debug: hookioOptions.debug, actualAppender: actualAppender });
|
loggerHook = new Logger(hookioOptions);
|
||||||
} else {
|
} else {
|
||||||
// Start a worker, just emitting events for a master
|
// Start a worker, just emitting events for a master
|
||||||
loggerHook = new Hook({ name: hookioOptions.name, debug: hookioOptions.debug });
|
loggerHook = new Hook(hookioOptions);
|
||||||
}
|
}
|
||||||
loggerHook.start();
|
loggerHook.start();
|
||||||
|
|
||||||
@ -45,10 +45,9 @@ function configure(config) {
|
|||||||
if (config.appender && config.mode === 'master') {
|
if (config.appender && config.mode === 'master') {
|
||||||
log4js.loadAppender(config.appender.type);
|
log4js.loadAppender(config.appender.type);
|
||||||
actualAppender = log4js.appenderMakers[config.appender.type](config.appender);
|
actualAppender = log4js.appenderMakers[config.appender.type](config.appender);
|
||||||
|
config.actualAppender = actualAppender;
|
||||||
}
|
}
|
||||||
delete config.appender;
|
return createAppender(config);
|
||||||
delete config.type;
|
|
||||||
return createAppender(config, actualAppender);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.name = 'hookio';
|
exports.name = 'hookio';
|
||||||
|
@ -3,7 +3,7 @@ var assert = require('assert');
|
|||||||
var sandbox = require('sandboxed-module');
|
var sandbox = require('sandboxed-module');
|
||||||
|
|
||||||
function fancyResultingHookioAppender(opts) {
|
function fancyResultingHookioAppender(opts) {
|
||||||
var result = { ons: {}, emissions: {}, logged: [] };
|
var result = { ons: {}, emissions: {}, logged: [], configs: [] };
|
||||||
|
|
||||||
var fakeLog4Js = {
|
var fakeLog4Js = {
|
||||||
appenderMakers: {}
|
appenderMakers: {}
|
||||||
@ -17,7 +17,7 @@ function fancyResultingHookioAppender(opts) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
var fakeHookIo = { Hook: function() { } };
|
var fakeHookIo = { Hook: function(config) { result.configs.push(config); } };
|
||||||
fakeHookIo.Hook.prototype.start = function () {
|
fakeHookIo.Hook.prototype.start = function () {
|
||||||
result.startCalled = true;
|
result.startCalled = true;
|
||||||
};
|
};
|
||||||
@ -52,7 +52,7 @@ vows.describe('log4js hookioAppender').addBatch({
|
|||||||
'master': {
|
'master': {
|
||||||
topic: function() {
|
topic: function() {
|
||||||
var fancy = fancyResultingHookioAppender();
|
var fancy = fancyResultingHookioAppender();
|
||||||
var logger = fancy.theModule.configure({ name: 'ohno', mode: 'master', appender: { type: 'file' } });
|
var logger = fancy.theModule.configure({ name: 'ohno', mode: 'master', 'hook-port': 5001, appender: { type: 'file' } });
|
||||||
logger({ level: { levelStr: 'INFO' }, data: "ALRIGHTY THEN", startTime: '2011-10-27T03:53:16.031Z' });
|
logger({ level: { levelStr: 'INFO' }, data: "ALRIGHTY THEN", startTime: '2011-10-27T03:53:16.031Z' });
|
||||||
logger({ level: { levelStr: 'DEBUG' }, data: "OH WOW", startTime: '2011-10-27T04:53:16.031Z'});
|
logger({ level: { levelStr: 'DEBUG' }, data: "OH WOW", startTime: '2011-10-27T04:53:16.031Z'});
|
||||||
return fancy.theResult;
|
return fancy.theResult;
|
||||||
@ -60,6 +60,8 @@ vows.describe('log4js hookioAppender').addBatch({
|
|||||||
|
|
||||||
'should write to the actual appender': function (result) {
|
'should write to the actual appender': function (result) {
|
||||||
assert.isTrue(result.startCalled);
|
assert.isTrue(result.startCalled);
|
||||||
|
assert.equal(result.configs.length, 1);
|
||||||
|
assert.equal(result.configs[0]['hook-port'], 5001);
|
||||||
assert.equal(result.logged.length, 2);
|
assert.equal(result.logged.length, 2);
|
||||||
assert.equal(result.emissions['ohno::log'].length, 2);
|
assert.equal(result.emissions['ohno::log'].length, 2);
|
||||||
assert.equal(result.ons['*::ohno::log'].callingCount, 2);
|
assert.equal(result.ons['*::ohno::log'].callingCount, 2);
|
||||||
|
Loading…
Reference in New Issue
Block a user