Skip to content

Commit bcdbca0

Browse files
committed
show secure icon in panel heading when secure
and "missing" object property icons
1 parent 85fa24a commit bcdbca0

4 files changed

Lines changed: 55 additions & 33 deletions

File tree

readme.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ Debug/log information is sent completely "out-of-bounds" via websockets. Since
77

88
All [PHPDebugConsole](https://github.com/bkdotcom/PHPDebugConsole) methods are supported.
99

10-
using a combination of [PHPDebugConsole](https://github.com/bkdotcom/PHPDebugConsole) and [WampPublisher](https://github.com/bkdotcom/WampPublisher)
1110

1211
### Overview
1312
There are 3 parts to this logging solution.
1413

1514
* This client. Think of this as an undocked (separate-windowed) browser console. Instead of viewing javascript info, it's PHP stuff<sup>†</sup>.
1615
* The PHP application thats "publishing" log messages (via [PHPDebugConsole](https://github.com/bkdotcom/PHPDebugConsole))
17-
* A WAMP (websockets protocol) router that serves as a middle man between this client and the PHP application
16+
* [A WAMP (websockets protocol) router](http://wamp-proto.org/implementations/#routers) that serves as a middle man between this client and the PHP application
1817

1918
All 3 components *can* be be running on the same server/environment, or be on 3 separate servers, it doesn't matter. I imagine in most cases, this client and the router will be installed on a local dev environment... aka your laptop.
2019

@@ -23,7 +22,7 @@ All 3 components *can* be be running on the same server/environment, or be on 3
2322

2423
### Installation
2524

26-
Download Composer (if not already installed) [more info](https://getcomposer.org/doc/00-intro.md#downloading-the-composer-executable)
25+
Download Composer (if not already installed) [more info](https://getcomposer.org/doc/00-intro.md#downloading-the-composer-executable)
2726
`$ curl -sS https://getcomposer.org/installer | php`
2827

2928
**create a project directory in your webroot**
@@ -35,12 +34,12 @@ Download Composer (if not already installed) [more info](https://getcomposer.org
3534
`$ php composer.phar require bdk/debug-wamp-client`
3635

3736
**Install a WAMP router** (if you don't already have one)
38-
If you don't already have a WAMP router up and running, you might as well install a PHP-based one here in the same folder *(but again, it could be installed anywhere)*
39-
One client+router install can support many PHPDebugConsole projects
37+
If you don't already have a WAMP router up and running, you might as well install a PHP-based one here in the same folder *(but again, it could be installed anywhere, or be a node based router)*
38+
One client+router install can support many PHPDebugConsole projects
4039
`$ php composer.phar require voryx/thruway`
4140

4241
**Start the WAMP router.**
43-
`$ php vendor/voryx/thruway/Examples/SimpleWsRouter.php`
42+
`$ php vendor/voryx/thruway/Examples/SimpleWsRouter.php`
4443
*(note that the router doesn't play well with x-debug. You will likely need to disable x-debug for this process)*
4544

4645
**Create an `index.php` for the client**

src/css/WampClient.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ body { padding-top:50px; }
5656
.panel-heading * { font-size:inherit; }
5757
.panel-heading > i { float: left; }
5858
.panel-heading .label { padding: .1em .6em .2em; }
59+
.panel-heading .http-host { opacity: 0.6; }
5960
.label-default { background-color: rgba(119, 119, 119, 0.3); color: inherit; }
6061

6162
.btn-remove-session {

src/js/DumpObject.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,10 @@ var logDumper = (function($, module){
164164
html += '<dd class="magic-method info">This object has a <code>__get()</code> method</dd>' + "\n";
165165
}
166166
$.each(properties, function(k, info) {
167-
// console.warn('dump', module.dump.toString());
167+
// console.info('property info', info);
168168
var viaDebugInfo = info.viaDebugInfo;
169-
html += '<dd class="property visibility-' + info.visibility + ' ' + (viaDebugInfo ? 'debug-value' : '') + '">' +
169+
var isPrivateAncestor = info['visibility'] == 'private' && info['inheritedFrom'];
170+
var $dd = $('<dd class="property">' +
170171
'<span class="t_modifier">' + info.visibility + '</span>' +
171172
(info.type
172173
? ' <span class="t_type">[' + info.type + ']</span>'
@@ -180,7 +181,16 @@ var logDumper = (function($, module){
180181
'>' + k + '</span>' +
181182
' <span class="t_operator">=</span> ' +
182183
module.dump(info.value) +
183-
'</dd>' + "\n";
184+
'</dd>'
185+
);
186+
$dd.addClass("visibility-" + info.visibility);
187+
if (viaDebugInfo) {
188+
$dd.addClass("debug-value");
189+
}
190+
if (isPrivateAncestor) {
191+
$dd.addClass("private-ancestor");
192+
}
193+
html += $dd[0].outerHTML;
184194
});
185195
return html;
186196
}
@@ -191,9 +201,11 @@ var logDumper = (function($, module){
191201
: 'no methods';
192202
var html = '<dt class="methods">' + label + '</dt>';
193203
$.each(methods, function(k, info) {
204+
// console.info('method info', info);
194205
var paramStr = dumpMethodParams(info.params);
195206
var modifiers = [];
196207
var returnType = '';
208+
var $dd;
197209
if (info.isFinal) {
198210
modifiers.push('<span class="t_modifier">final</span>');
199211
}
@@ -209,7 +221,7 @@ var logDumper = (function($, module){
209221
) +
210222
'>' + info.phpDoc.return[0].type + '</span>';
211223
}
212-
html += '<dd class="method visibility-' + info.visibility + '">' +
224+
$dd = $('<dd class="method">' +
213225
modifiers.join(' ') +
214226
returnType +
215227
' <span class="method-name"' +
@@ -223,7 +235,13 @@ var logDumper = (function($, module){
223235
? '<br /><span class="indent">' + module.dump(info.returnValue, true) + '</span>'
224236
: ''
225237
) +
226-
'</dd>' + "\n";
238+
'</dd>'
239+
);
240+
$dd.addClass("visibility-" + info.visibility);
241+
if (info.isDeprecated) {
242+
$dd.addClass("deprecated");
243+
}
244+
html += $dd[0].outerHTML;
227245
});
228246
return html;
229247
}

src/js/LogDumper.js

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -312,24 +312,7 @@ var logDumper = (function($, module) {
312312
}
313313
args[i] = atob(arg);
314314
});
315-
$container.find(".panel-heading .panel-heading-body .pull-right").remove();
316-
// console.log('args', args);
317-
if (args.REQUEST_METHOD) {
318-
$container
319-
.find(".panel-heading .panel-heading-body .panel-title")
320-
.html(args.REQUEST_METHOD);
321-
}
322-
if (args.REQUEST_URI) {
323-
$container
324-
.find(".panel-heading .panel-heading-body .panel-title")
325-
.append(' ' + args.REQUEST_URI);
326-
}
327-
if (args.REQUEST_TIME) {
328-
var date = (new Date(args.REQUEST_TIME * 1000)).toString().replace(/[A-Z]{3}-\d+/, '');
329-
$container
330-
.find(".panel-heading .panel-heading-body")
331-
.prepend('<span class="pull-right">'+date+'</span>');
332-
}
315+
methodMeta($container, args);
333316
} else if (method === "table") {
334317
// console.log('table', args[1], args[0]);
335318
$.each(args[2], function(i,col) {
@@ -400,6 +383,29 @@ var logDumper = (function($, module) {
400383
}
401384
};
402385

386+
function methodMeta($container, args) {
387+
$container.find(".panel-heading .panel-heading-body .pull-right").remove();
388+
var $title = $container.find(".panel-heading .panel-heading-body .panel-title").html('');
389+
if (args.HTTPS === "on") {
390+
$title.append('<i class="fa fa-lock fa-lg"></i> ');
391+
}
392+
if (args.REQUEST_METHOD) {
393+
$title.append(args.REQUEST_METHOD + ' ');
394+
}
395+
if (args.HTTP_HOST) {
396+
$title.append('<span class="http-host">' + args.HTTP_HOST + '</span>');
397+
}
398+
if (args.REQUEST_URI) {
399+
$title.append('<span class="request-uri">' + args.REQUEST_URI + '</span>');
400+
}
401+
if (args.REQUEST_TIME) {
402+
var date = (new Date(args.REQUEST_TIME * 1000)).toString().replace(/[A-Z]{3}-\d+/, '');
403+
$container
404+
.find(".panel-heading .panel-heading-body")
405+
.prepend('<span class="pull-right">'+date+'</span>');
406+
}
407+
}
408+
403409
function checkTimestamp(val)
404410
{
405411
var secs = 86400 * 90; // 90 days worth o seconds
@@ -494,8 +500,7 @@ var logDumper = (function($, module) {
494500
return html;
495501
}
496502

497-
function processSubstitutions(args)
498-
{
503+
function processSubstitutions(args) {
499504
var subRegex = '%' +
500505
'(?:' +
501506
'[coO]|' + // c: css, o: obj with max info, O: obj w generic info
@@ -591,8 +596,7 @@ var logDumper = (function($, module) {
591596
*
592597
* @return string
593598
*/
594-
function substitutionAsString(val)
595-
{
599+
function substitutionAsString(val) {
596600
var type = module.getType(val);
597601
// var count;
598602
if (type == 'string') {

0 commit comments

Comments
 (0)