zblueslip: Store more_info and stack as well in the logs.

Now, the get_test_logs() returns an array of objects instead
of an array of strings as follows:

[{
  message: "something",
  more_info: {},
  stack: {},
}]
This commit is contained in:
Rohitt Vashishtha
2018-07-10 12:58:25 +05:30
committed by showell
parent 61f8a6fd55
commit e14dbecdd1
3 changed files with 6 additions and 6 deletions

View File

@@ -267,7 +267,7 @@ run_test('retry', () => {
}); });
assert.equal(blueslip.get_test_logs('log').length, 1); assert.equal(blueslip.get_test_logs('log').length, 1);
assert.equal(blueslip.get_test_logs('log')[0], 'Retrying idempotent[object Object]'); assert.equal(blueslip.get_test_logs('log')[0].message, 'Retrying idempotent[object Object]');
blueslip.clear_test_data(); blueslip.clear_test_data();
}, },
}); });

View File

@@ -27,7 +27,7 @@ run_test('report_late_add', () => {
reload.is_in_progress = true; reload.is_in_progress = true;
people.report_late_add(55, 'foo@example.com'); people.report_late_add(55, 'foo@example.com');
assert.equal(blueslip.get_test_logs('log').length, 1); assert.equal(blueslip.get_test_logs('log').length, 1);
assert.equal(blueslip.get_test_logs('log')[0], 'Added user late: user_id=55 email=foo@example.com'); assert.equal(blueslip.get_test_logs('log')[0].message, 'Added user late: user_id=55 email=foo@example.com');
assert.equal(blueslip.get_test_logs('error').length, 0); assert.equal(blueslip.get_test_logs('error').length, 0);
blueslip.clear_test_data(); blueslip.clear_test_data();
}); });

View File

@@ -60,13 +60,13 @@ exports.make_zblueslip = function (opts) {
Object.keys(opts).forEach(name => { Object.keys(opts).forEach(name => {
if (!opts[name]) { if (!opts[name]) {
// should just log the message. // should just log the message.
lib[name] = function (message) { lib[name] = function (message, more_info, stack) {
lib.test_logs[name].push(message); lib.test_logs[name].push({message, more_info, stack});
}; };
return; return;
} }
lib[name] = function (message) { lib[name] = function (message, more_info, stack) {
lib.test_logs[name].push(message); lib.test_logs[name].push({message, more_info, stack});
const exact_match_fail = lib.test_data[name].indexOf(message) === -1; const exact_match_fail = lib.test_data[name].indexOf(message) === -1;
const string_match_fail = lib.test_data[name].indexOf(message.toString()) === -1; const string_match_fail = lib.test_data[name].indexOf(message.toString()) === -1;
if (exact_match_fail && string_match_fail) { if (exact_match_fail && string_match_fail) {