put 'level' field earlier in record

This commit is contained in:
Trent Mick 2012-02-22 10:53:12 -08:00
parent b52b1b60df
commit 0f02707429
2 changed files with 5 additions and 2 deletions

View file

@ -2,7 +2,10 @@
## bunyan 0.6.5 (not yet released) ## bunyan 0.6.5 (not yet released)
(nothing yet) - Add 'level' field to log record before custom fields for that record. This just
means that the raw record JSON will show the 'level' field earlier, which is a bit
nicer for raw reading.
## bunyan 0.6.4 ## bunyan 0.6.4

View file

@ -600,6 +600,7 @@ Logger.prototype._mkRecord = function (fields, level, msgArgs) {
*/ */
Logger.prototype._emit = function (rec) { Logger.prototype._emit = function (rec) {
var obj = objCopy(rec[0]); var obj = objCopy(rec[0]);
var level = obj.level = rec[2];
var recFields = rec[1]; var recFields = rec[1];
if (recFields) { if (recFields) {
if (this.serializers) { if (this.serializers) {
@ -609,7 +610,6 @@ Logger.prototype._emit = function (rec) {
obj[k] = recFields[k]; obj[k] = recFields[k];
}); });
} }
var level = obj.level = rec[2];
xxx("Record:", rec) xxx("Record:", rec)
obj.msg = format.apply(this, rec[3]); obj.msg = format.apply(this, rec[3]);
if (!obj.time) { if (!obj.time) {