Compare commits
14 Commits
v0.6.0
...
node-0.8-r
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b49ba9f3d | ||
|
|
ed7462885f | ||
|
|
36c5175a55 | ||
|
|
22160f90b3 | ||
|
|
73437ecb40 | ||
|
|
107e33c0d1 | ||
|
|
6352632fb2 | ||
|
|
0544342e9f | ||
|
|
1d1153d32f | ||
|
|
e58cf201ca | ||
|
|
83271e47fc | ||
|
|
f3271a3997 | ||
|
|
4b7cf589a2 | ||
|
|
c8f401c47d |
@@ -1,3 +1,5 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- 0.10
|
- "0.10"
|
||||||
|
- "0.8"
|
||||||
|
|
||||||
|
|||||||
@@ -130,13 +130,13 @@ If you have already defined an absolute path for one of the FileAppenders in the
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
Documentation for most of the core appenders can be found on the [wiki](log4js-node/wiki/Appenders), otherwise take a look at the tests and the examples.
|
Documentation for most of the core appenders can be found on the [wiki](https://github.com/nomiddlename/log4js-node/wiki/Appenders), otherwise take a look at the tests and the examples.
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
See the [wiki](log4js-node/wiki). Improve the [wiki](log4js-node/wiki), please.
|
See the [wiki](https://github.com/nomiddlename/log4js-node/wiki). Improve the [wiki](https://github.com/nomiddlename/log4js-node/wiki), please.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
Contributions welcome, but take a look at the [rules](log4js-node/wiki/Contributing) first.
|
Contributions welcome, but take a look at the [rules](https://github.com/nomiddlename/log4js-node/wiki/Contributing) first.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
@@ -38,31 +38,30 @@ function logServer(config) {
|
|||||||
var actualAppender = config.actualAppender,
|
var actualAppender = config.actualAppender,
|
||||||
server = net.createServer(function serverCreated(clientSocket) {
|
server = net.createServer(function serverCreated(clientSocket) {
|
||||||
clientSocket.setEncoding('utf8');
|
clientSocket.setEncoding('utf8');
|
||||||
clientSocket.on('connect', function clientConnected() {
|
var logMessage = '';
|
||||||
var logMessage = '';
|
|
||||||
|
|
||||||
function logTheMessage(msg) {
|
function logTheMessage(msg) {
|
||||||
if (logMessage.length > 0) {
|
if (logMessage.length > 0) {
|
||||||
actualAppender(deserializeLoggingEvent(clientSocket, msg));
|
actualAppender(deserializeLoggingEvent(clientSocket, msg));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function chunkReceived(chunk) {
|
function chunkReceived(chunk) {
|
||||||
var event;
|
var event;
|
||||||
logMessage += chunk || '';
|
logMessage += chunk || '';
|
||||||
if (logMessage.indexOf(END_MSG) > -1) {
|
if (logMessage.indexOf(END_MSG) > -1) {
|
||||||
event = logMessage.substring(0, logMessage.indexOf(END_MSG));
|
event = logMessage.substring(0, logMessage.indexOf(END_MSG));
|
||||||
logTheMessage(event);
|
logTheMessage(event);
|
||||||
logMessage = logMessage.substring(event.length + END_MSG.length) || '';
|
logMessage = logMessage.substring(event.length + END_MSG.length) || '';
|
||||||
//check for more, maybe it was a big chunk
|
//check for more, maybe it was a big chunk
|
||||||
chunkReceived();
|
chunkReceived();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
clientSocket.on('data', chunkReceived);
|
clientSocket.on('data', chunkReceived);
|
||||||
clientSocket.on('end', chunkReceived);
|
clientSocket.on('end', chunkReceived);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(config.loggerPort || 5000, config.loggerHost || 'localhost');
|
server.listen(config.loggerPort || 5000, config.loggerHost || 'localhost');
|
||||||
|
|
||||||
return actualAppender;
|
return actualAppender;
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
var fs = require('fs'),
|
var fs = require('fs'),
|
||||||
stream = require('stream'),
|
stream,
|
||||||
util = require('util');
|
util = require('util'),
|
||||||
|
semver = require('semver');
|
||||||
|
|
||||||
function debug(message) {
|
if (semver.satisfies(process.version, '>=0.10.0')) {
|
||||||
// console.log(message);
|
stream = require('stream');
|
||||||
|
} else {
|
||||||
|
stream = require('readable-stream');
|
||||||
|
}
|
||||||
|
|
||||||
|
var debug;
|
||||||
|
if (process.env.NODE_DEBUG && /\blog4js\b/.test(process.env.NODE_DEBUG)) {
|
||||||
|
debug = function(message) { console.error('LOG4JS: (BaseRollingFileStream) %s', message); };
|
||||||
|
} else {
|
||||||
|
debug = function() { };
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = BaseRollingFileStream;
|
module.exports = BaseRollingFileStream;
|
||||||
@@ -66,7 +76,7 @@ BaseRollingFileStream.prototype.openTheStream = function(cb) {
|
|||||||
|
|
||||||
BaseRollingFileStream.prototype.closeTheStream = function(cb) {
|
BaseRollingFileStream.prototype.closeTheStream = function(cb) {
|
||||||
debug("closing the underlying stream");
|
debug("closing the underlying stream");
|
||||||
this.theStream.end(null, null, cb);
|
this.theStream.end(cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
BaseRollingFileStream.prototype.shouldRoll = function() {
|
BaseRollingFileStream.prototype.shouldRoll = function() {
|
||||||
|
|||||||
@@ -6,8 +6,11 @@ var BaseRollingFileStream = require('./BaseRollingFileStream'),
|
|||||||
|
|
||||||
module.exports = DateRollingFileStream;
|
module.exports = DateRollingFileStream;
|
||||||
|
|
||||||
function debug(message) {
|
var debug;
|
||||||
// console.log(message);
|
if (process.env.NODE_DEBUG && /\blog4js\b/.test(process.env.NODE_DEBUG)) {
|
||||||
|
debug = function(message) { console.error('LOG4JS: (DateRollingFileStream) %s', message); };
|
||||||
|
} else {
|
||||||
|
debug = function() { };
|
||||||
}
|
}
|
||||||
|
|
||||||
function DateRollingFileStream(filename, pattern, options, now) {
|
function DateRollingFileStream(filename, pattern, options, now) {
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ var BaseRollingFileStream = require('./BaseRollingFileStream'),
|
|||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
async = require('async');
|
async = require('async');
|
||||||
|
|
||||||
function debug() {
|
var debug;
|
||||||
// util.debug(message);
|
if (process.env.NODE_DEBUG && /\blog4js\b/.test(process.env.NODE_DEBUG)) {
|
||||||
// console.log.apply(console, arguments);
|
debug = function(message) { console.error('LOG4JS: (RollingFileStream) %s', message); };
|
||||||
|
} else {
|
||||||
|
debug = function() { };
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = RollingFileStream;
|
module.exports = RollingFileStream;
|
||||||
|
|||||||
76
package.json
76
package.json
@@ -1,38 +1,42 @@
|
|||||||
{
|
{
|
||||||
"name": "log4js",
|
"name": "log4js",
|
||||||
"version": "0.6.0",
|
"version": "0.6.2",
|
||||||
"description": "Port of Log4js to work with node.",
|
"description": "Port of Log4js to work with node.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"logging",
|
"logging",
|
||||||
"log",
|
"log",
|
||||||
"log4j",
|
"log4j",
|
||||||
"node"
|
"node"
|
||||||
],
|
],
|
||||||
"main": "./lib/log4js",
|
"main": "./lib/log4js",
|
||||||
"author": "Gareth Jones <gareth.jones@sensis.com.au>",
|
"author": "Gareth Jones <gareth.jones@sensis.com.au>",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/nomiddlename/log4js-node.git"
|
"url": "https://github.com/nomiddlename/log4js-node.git"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "http://github.com/nomiddlename/log4js-node/issues"
|
"url": "http://github.com/nomiddlename/log4js-node/issues"
|
||||||
},
|
},
|
||||||
"engines": [ "node >=0.10" ],
|
"engines": {
|
||||||
"scripts": {
|
"node": ">=0.8"
|
||||||
"test": "vows"
|
},
|
||||||
},
|
"scripts": {
|
||||||
"directories": {
|
"test": "vows"
|
||||||
"test": "test",
|
},
|
||||||
"lib": "lib"
|
"directories": {
|
||||||
},
|
"test": "test",
|
||||||
"dependencies": {
|
"lib": "lib"
|
||||||
"async": "0.1.15",
|
},
|
||||||
"dequeue": "1.0.3"
|
"dependencies": {
|
||||||
},
|
"async": "0.1.15",
|
||||||
"devDependencies": {
|
"dequeue": "1.0.3",
|
||||||
"vows": "0.7.0",
|
"semver": "~1.1.4",
|
||||||
"sandboxed-module": "0.1.3",
|
"readable-stream": "~1.0.2"
|
||||||
"hook.io": "0.8.10",
|
},
|
||||||
"underscore": "1.2.1"
|
"devDependencies": {
|
||||||
}
|
"vows": "0.7.0",
|
||||||
|
"sandboxed-module": "0.1.3",
|
||||||
|
"hook.io": "0.8.10",
|
||||||
|
"underscore": "1.2.1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,24 +30,24 @@ function makeFakeNet() {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
createServer: function(cb) {
|
createServer: function(cb) {
|
||||||
var fakeNet = this;
|
var fakeNet = this;
|
||||||
cb({
|
cb({
|
||||||
remoteAddress: '1.2.3.4',
|
remoteAddress: '1.2.3.4',
|
||||||
remotePort: '1234',
|
remotePort: '1234',
|
||||||
setEncoding: function(encoding) {
|
setEncoding: function(encoding) {
|
||||||
fakeNet.encoding = encoding;
|
fakeNet.encoding = encoding;
|
||||||
},
|
},
|
||||||
on: function(event, cb) {
|
on: function(event, cb) {
|
||||||
fakeNet.cbs[event] = cb;
|
fakeNet.cbs[event] = cb;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
listen: function(port, host) {
|
listen: function(port, host) {
|
||||||
fakeNet.port = port;
|
fakeNet.port = port;
|
||||||
fakeNet.host = host;
|
fakeNet.host = host;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -183,7 +183,6 @@ vows.describe('Multiprocess Appender').addBatch({
|
|||||||
topic: function(net) {
|
topic: function(net) {
|
||||||
var logString = JSON.stringify({ level: { level: 10000, levelStr: 'DEBUG' }, data: ['some debug']}) + '__LOG4JS__';
|
var logString = JSON.stringify({ level: { level: 10000, levelStr: 'DEBUG' }, data: ['some debug']}) + '__LOG4JS__';
|
||||||
|
|
||||||
net.cbs['connect']();
|
|
||||||
net.cbs['data'](JSON.stringify({ level: { level: 40000, levelStr: 'ERROR' }, data: ['an error message'] }) + '__LOG4JS__');
|
net.cbs['data'](JSON.stringify({ level: { level: 40000, levelStr: 'ERROR' }, data: ['an error message'] }) + '__LOG4JS__');
|
||||||
net.cbs['data'](logString.substring(0, 10));
|
net.cbs['data'](logString.substring(0, 10));
|
||||||
net.cbs['data'](logString.substring(10));
|
net.cbs['data'](logString.substring(10));
|
||||||
|
|||||||
@@ -1,10 +1,18 @@
|
|||||||
var vows = require('vows')
|
var vows = require('vows')
|
||||||
, assert = require('assert')
|
, assert = require('assert')
|
||||||
, streams = require('stream')
|
|
||||||
, fs = require('fs')
|
, fs = require('fs')
|
||||||
, DateRollingFileStream = require('../../lib/streams').DateRollingFileStream
|
, semver = require('semver')
|
||||||
|
, streams
|
||||||
|
, DateRollingFileStream
|
||||||
, testTime = new Date(2012, 8, 12, 10, 37, 11);
|
, testTime = new Date(2012, 8, 12, 10, 37, 11);
|
||||||
|
|
||||||
|
if (semver.satisfies(process.version, '>=0.10.0')) {
|
||||||
|
streams = require('stream');
|
||||||
|
} else {
|
||||||
|
streams = require('readable-stream');
|
||||||
|
}
|
||||||
|
DateRollingFileStream = require('../../lib/streams').DateRollingFileStream
|
||||||
|
|
||||||
function cleanUp(filename) {
|
function cleanUp(filename) {
|
||||||
return function() {
|
return function() {
|
||||||
fs.unlink(filename);
|
fs.unlink(filename);
|
||||||
|
|||||||
@@ -3,8 +3,16 @@ var vows = require('vows')
|
|||||||
, assert = require('assert')
|
, assert = require('assert')
|
||||||
, events = require('events')
|
, events = require('events')
|
||||||
, fs = require('fs')
|
, fs = require('fs')
|
||||||
, streams = require('stream')
|
, semver = require('semver')
|
||||||
, RollingFileStream = require('../../lib/streams').RollingFileStream;
|
, streams
|
||||||
|
, RollingFileStream;
|
||||||
|
|
||||||
|
if (semver.satisfies(process.version, '>=0.10.0')) {
|
||||||
|
streams = require('stream');
|
||||||
|
} else {
|
||||||
|
streams = require('readable-stream');
|
||||||
|
}
|
||||||
|
RollingFileStream = require('../../lib/streams').RollingFileStream;
|
||||||
|
|
||||||
function remove(filename) {
|
function remove(filename) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user