gracenode
Advanced tools
Comparing version 0.3.10 to 0.3.11
# Change Log | ||
## Version 0.3.11 | ||
### Added | ||
None | ||
### Changed | ||
#### Critical buf fix in log module's file and remote | ||
The bug in log module's file write and remote send has been fixed. | ||
### Depricated | ||
None | ||
### Removed | ||
None | ||
# Future backward compatibility break | ||
We will be removing the current built-in module system. | ||
The current built-in modules will be all externalized and required to be included in your application's package.json. | ||
As of version 0.3.11, we still have the current module system and the new driver system. | ||
Planned removal of the built-in modules is version 1.0.0 | ||
*** | ||
## Version 0.3.10 | ||
@@ -4,0 +36,0 @@ |
@@ -36,5 +36,5 @@ var buff = { | ||
module.exports.setup = function (config) { | ||
if (config) { | ||
limit = config; | ||
module.exports.setup = function (size) { | ||
if (size) { | ||
limit = size; | ||
} | ||
@@ -41,0 +41,0 @@ }; |
@@ -33,3 +33,3 @@ var loggerSource = require('./logger'); | ||
module.exports.create = function (name) { | ||
return new loggerSource.Logger(prefix, name, config); | ||
return loggerSource.create(prefix, name, config); | ||
}; |
@@ -41,3 +41,3 @@ var fs = require('fs'); | ||
var stream = getWriteStream(levelName); | ||
stream.write(msg.message + '\n', cb); | ||
stream.write(msg + '\n', cb); | ||
}; | ||
@@ -44,0 +44,0 @@ |
@@ -30,4 +30,3 @@ var dgram = require('dgram'); | ||
name: levelName, | ||
message: msg.message, | ||
timestamp: msg.timestamp | ||
message: msg, | ||
}; | ||
@@ -34,0 +33,0 @@ data = new Buffer(JSON.stringify(data)); |
@@ -11,2 +11,5 @@ var async = require('async'); | ||
var address = null; | ||
// a list of logger objects for auto flush | ||
var loggers = []; | ||
// default is 5 seconds | ||
var autoFlushInterval = 5000; | ||
@@ -22,11 +25,27 @@ | ||
gracenode = gn; | ||
if (config && config.bufferFlushInterval) { | ||
if (config.bufferFlushInterval) { | ||
autoFlushInterval = config.buggerFlushInterval; | ||
} | ||
module.exports._timerFlush(); | ||
}; | ||
module.exports.Logger = Logger; | ||
module.exports.create = function (prefix, name, config) { | ||
var logger = new Logger(prefix, name, config); | ||
loggers.push(logger); | ||
return logger; | ||
}; | ||
module.exports.events = events; | ||
module.exports._timerFlush = function () { | ||
// auto flush buffered log data at x miliseconds | ||
// Node.js timer implementation should be effecient for handling lots of timers | ||
// https://github.com/joyent/node/blob/master/deps/uv/src/unix/timer.c #120 | ||
setTimeout(function () { | ||
async.eachSeries(loggers, function (logger, next) { | ||
logger._autoFlush(next); | ||
}, module.exports._timerFlush); | ||
}, autoFlushInterval); | ||
}; | ||
function Logger(prefix, name, config) { | ||
@@ -42,17 +61,4 @@ this.prefix = prefix; | ||
} | ||
this._timerFlush(); | ||
} | ||
Logger.prototype._timerFlush = function () { | ||
// auto flush buffered log data at x miliseconds | ||
// Node.js timer implementation should be effecient for handling lots of timers | ||
// https://github.com/joyent/node/blob/master/deps/uv/src/unix/timer.c #120 | ||
var that = this; | ||
setTimeout(function () { | ||
that._autoFlush(function () { | ||
that._timerFlush(); | ||
}); | ||
}, autoFlushInterval); | ||
}; | ||
Logger.prototype.verbose = function () { | ||
@@ -114,3 +120,3 @@ this._handleLog('verbose', arguments); | ||
if (this.config.remote) { | ||
remote.log(levelName, bufferedMsg.messages.join('\n')); | ||
remote.log(levelName, bufferedMsg.messages('\n')); | ||
} | ||
@@ -117,0 +123,0 @@ |
{ | ||
"name": "gracenode", | ||
"description": "Framework for node.js application with extendable module management system for fast and clean development.", | ||
"version": "0.3.10", | ||
"version": "0.3.11", | ||
"author": "Nobuyori Takahashi <voltrue2@yahoo.com>", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -14,4 +14,7 @@ { | ||
} | ||
}, | ||
"view": { | ||
} | ||
} | ||
} |
@@ -15,2 +15,5 @@ { | ||
}, | ||
"test": { | ||
}, | ||
"in-app-purchase": { | ||
@@ -82,4 +85,7 @@ "sandbox": true | ||
"options": null | ||
}, | ||
"gracenode-view": { | ||
} | ||
} | ||
} |
@@ -13,9 +13,5 @@ var gn = require('../'); | ||
gn.addModulePath(prefix + 'gracenode/test/modules/'); | ||
// test override | ||
gn.override('mysql'); | ||
gn.setup(function (error) { | ||
assert.equal(error, undefined); | ||
assert.equal(gn.mysql.test, 'test override'); | ||
done(); | ||
@@ -22,0 +18,0 @@ }); |
409412
10694