Skip to content

Commit

Permalink
HUE-146. dbug.* methods don't work with string formatting
Browse files Browse the repository at this point in the history
* fixed the invocation of the dbug method (instead of just calling the method, need to apply the arguments);
* added a parser for when messages that have functions, arrays, etc as arguments
  • Loading branch information
anutron committed Aug 12, 2010
1 parent 8cb0439 commit 328a297
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 8 deletions.
71 changes: 64 additions & 7 deletions desktop/core/static/js/Source/CCS/CCS.Desktop.Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
---
description: Desktop Configuration
provides: [CCS.Desktop.Config]
requires: [/CCS.Desktop, clientcide/StickyWin.Drag, Widgets/ART.Popup, Widgets/ART.Glyphs, Core/Selectors, More/HtmlTable.Select]
requires: [/CCS.Desktop, clientcide/StickyWin.Drag, Widgets/ART.Popup, Widgets/ART.Glyphs, Core/Selectors, More/HtmlTable.Select, Core/JSON]
script: CCS.Desktop.Config.js
...
Expand Down Expand Up @@ -219,35 +219,92 @@ if (Browser.Engine.trident) {
// crush the server either with too-many or too-frequent messages, so we only send every 5 seconds,
// unless there are more than 100 messages in the message queue.
(function(info, warn, error) {
var parse = function(){
var str = '';
for (var i = 0; i < arguments.length; i++) {
var value = arguments[i];
switch ($type(value)) {
case 'element':
var el = document.id(value);
str += el.get('tag');
if (el.get('id')) str += '#' + el.get('id');
if (el.get('class')) str += el.get('class').split(' ').join('.');
break;

case 'array': case 'collection':
str +='[';
var results = [];
for (var index = 0; index < value.length; index++) {
results.push(parse(value[index]));
}
str += results.join(', ') + ']';
break;

case 'object':
var objs = [];
for (name in value) {
if ($type(value[name]) != 'object') {
objs.push(name + ': ' + parse(value[name]));
} else {
objs.push(name + ': (object)');
}
}
str += '{' + objs.join(', ') + '}';
break;

case 'function':
str += '(function)';
break;

case 'boolean':
str += String(value);
break;

default: str += value;
}
if (i != (arguments.length - 1)) str += ', ';
}
return str;
};

var monkeyPatchDbugFunction = function(dbugMethod, level) {
var messageQueue = [];
var messageQueue = [],
timer;

var startTimer = function(){
$clear(timer);
timer = sendQueuedMessages.delay(5000);
};

var sendQueuedMessages = function() {
$clear(timer);
if (window.sendDbug && messageQueue.length > 0) {
new Request.JSON({
url: '/log_frontend_event',
data: {
message: JSON.encode(messageQueue),
level: level
}
},
onComplete: startTimer
}).post();
// Immediately clear the queue after we try to send it.
// If the send fails, oh well.
messageQueue.empty();
} else {
startTimer();
}
};

// Poll the message queue every 5 seconds to see if it has messages to send.
sendQueuedMessages.periodical(5000);
startTimer();

return function(message) {
messageQueue.push(message);
return function() {
messageQueue.push(parse.apply(parse, arguments));
// Immediately send the message queue if it's getting too big.
if (messageQueue.length > 100) {
sendQueuedMessages();
}
dbugMethod(message);
dbugMethod.apply(dbug, arguments);
};
};

Expand Down
5 changes: 5 additions & 0 deletions ext/thirdparty/js/art-widgets.hash.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<<<<<<< HEAD:ext/thirdparty/js/art-widgets.hash
b035b450505874fb34b13b37ecf17fde621ef25e
=======
16fe75ad3972f44bb916ab7db573b2c7ac784921
>>>>>>> HUE-66. beeswax create table UI mess:ext/thirdparty/js/art-widgets.hash
2 changes: 1 addition & 1 deletion ext/thirdparty/js/clientcide.hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1891f4651f8bb935da42cd8ae4596c08a9a98018
9fa2051ff94233efd798eb0882a903a77f99505a

0 comments on commit 328a297

Please sign in to comment.