mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
minor tweaks to log format
This commit is contained in:
@@ -188,23 +188,21 @@ Log.format = function (obj, options) {
|
||||
|
||||
var appInfo = '';
|
||||
if (appName) appInfo += appName;
|
||||
if (originApp && originApp !== appName) appInfo += ':' + originApp;
|
||||
if (appInfo) appInfo = ' [' + appInfo + ']';
|
||||
if (originApp && originApp !== appName) appInfo += ' via ' + originApp;
|
||||
if (appInfo) appInfo = '[' + appInfo + '] ';
|
||||
|
||||
var sourceInfo = (file && lineNumber) ?
|
||||
['(', (program ? program + ':' : ''), file, ':', lineNumber, ')'].join('')
|
||||
['(', (program ? program + ':' : ''), file, ':', lineNumber, ') '].join('')
|
||||
: '';
|
||||
if (sourceInfo && !appInfo)
|
||||
sourceInfo = ' ' + sourceInfo;
|
||||
|
||||
var stderrIndicator = stderr ? ' (STDERR)' : '';
|
||||
var stderrIndicator = stderr ? '(STDERR) ' : '';
|
||||
|
||||
var metaPrefix = [
|
||||
level.charAt(0).toUpperCase(),
|
||||
dateStamp,
|
||||
'-',
|
||||
timeStamp,
|
||||
timeInexact ? '?' : '',
|
||||
timeInexact ? '?' : ' ',
|
||||
appInfo,
|
||||
sourceInfo,
|
||||
stderrIndicator].join('');
|
||||
@@ -215,7 +213,6 @@ Log.format = function (obj, options) {
|
||||
};
|
||||
|
||||
return prettify(metaPrefix, META_COLOR)
|
||||
+ ' '
|
||||
+ prettify(message, LEVEL_COLORS[level]);
|
||||
};
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ Tinytest.add("logging - format", function (test) {
|
||||
|
||||
test.equal(
|
||||
Log.format({message: "message", time: time, timeInexact: true, level: level}),
|
||||
level.charAt(0).toUpperCase() + "20120908-07:06:05.004? message");
|
||||
level.charAt(0).toUpperCase() + "20120908-07:06:05.004?message");
|
||||
|
||||
test.equal(
|
||||
Log.format({foo1: "bar1", foo2: "bar2", time: time, level: level}),
|
||||
@@ -89,7 +89,7 @@ Tinytest.add("logging - format", function (test) {
|
||||
// Has everything except stderr field
|
||||
test.equal(
|
||||
Log.format({message: "message", foo: "bar", time: time, level: level, file: "app.js", line:42, app: "myApp", originApp: "proxy", program: "server"}),
|
||||
level.charAt(0).toUpperCase() + '20120908-07:06:05.004 [myApp:proxy](server:app.js:42) message {\"foo\":\"bar\"}');
|
||||
level.charAt(0).toUpperCase() + '20120908-07:06:05.004 [myApp via proxy] (server:app.js:42) message {\"foo\":\"bar\"}');
|
||||
|
||||
// stderr
|
||||
test.equal(
|
||||
@@ -102,7 +102,7 @@ Tinytest.add("logging - format", function (test) {
|
||||
level.charAt(0).toUpperCase() + '20120908-07:06:05.004 [app] message');
|
||||
test.equal(
|
||||
Log.format({message: "message", time: time, level: level, app: "app", originApp: "proxy"}),
|
||||
level.charAt(0).toUpperCase() + '20120908-07:06:05.004 [app:proxy] message');
|
||||
level.charAt(0).toUpperCase() + '20120908-07:06:05.004 [app via proxy] message');
|
||||
|
||||
// source info
|
||||
test.equal(
|
||||
|
||||
Reference in New Issue
Block a user