michaelfox + debug   42

PHP Console - Google Chrome Extension
There is Lagger - flexible open-source PHP library for errors/exceptions/debugs handling in PHP http://code.google.com/p/lagger

Lightweight alternative of Lagger is class PhpConsole
http://code.google.com/p/php-console/source/browse/trunk/PhpConsole

PHP Console is extension that displays errors/exceptions/debug messages handled by class PhpConsole and Lagger in Google Chrome console and in notification popups.

Changelog http://code.google.com/p/php-console/wiki/Changelog
Report bugs and features http://code.google.com/p/php-console/issues
Author http://linkedin.com/in/barbushin
See also my JavaScript Errors Notifier extension http://goo.gl/uo9Ro

--- FEATURES ---

✔ No icons on Toolbar, only in Address bar (when enabled on server)
✔ Configure from context menu (just right click on web-page)
✔ Handle exceptions and all errors (even FATAL)
✔ Display debug and errors messages in Google Chrome console
✔ Display debug and errors messages in Notification popups
✔ First popup is displayed with 3 second lifetime
✔ All other popups are displayed with configured lifetime
✔ Popup is not hiding if mouse is over or if popup window is selected
✔ All popups can be closed by clicking on close icon (x) of any popup
✔ Display errors/exceptions backtrace in console (click on >Object)
✔ Display errors/exceptions backtrace in notification (click on #source_path link)
✔ Display JavaScript errors messages in Notification popups
✔ It does not overrides user-defined JavaScript errors handlers
✔ Errors source URLs in popup are clickable
✔ Ignore repeated errors
✔ Ignore Google Chrome extensions internal errors
✔ Catch messages from any sources
✔ Web page
✔ AJAX
✔ IFrame
✔ Make custom actions on errors and debug messages (with Lagger):
✔ Log to file
✔ Send Email
✔ Send SMS
✔ Send to STDOUT

--- HOW TO USE ---

### With PhpConsole class:

1. Install PHP Console extension
2. Download PhpConsole class - http://code.google.com/p/php-console/downloads
3. Test code:

require_once('PhpConsole.php');
PhpConsole::start();

// test
debug('test message');
debug('SELECT * FROM users', 'sql');
unkownFunction($unkownVar);

### With Yii Framework extension using class PhpConsole

http://www.yiiframework.com/extension/php-console

### With Symfony Framework plugin using class PhpConsole

http://www.symfony-project.org/plugins/stPhpConsolePlugin

### With WordPress plugin using class PhpConsole

http://wpengineer.com/2197/php-console-with-chrome-and-wordpress

### With Lagger:

1. Install PHP Console extension
2. Download Lagger - http://code.google.com/p/lagger/downloads
3. Test code:

define('LAGGER_BASE_DIR', '../library/');
function autoloadLaggerClasses($class) {
if(strpos($class, 'Lagger_') === 0) {
require_once (LAGGER_BASE_DIR . str_replace('_', '/', $class) . '.php');
}
}
spl_autoload_register('autoloadLaggerClasses');
$laggerES = new Lagger_Eventspace();
$debug = new Lagger_Handler_Debug($laggerES);
$errors = new Lagger_Handler_Errors($laggerES);
$exceptions = new Lagger_Handler_Exceptions($laggerES);
$chromeConsole = new Lagger_Action_ChromeConsole();
$debug->addAction($chromeConsole);
$errors->addAction($chromeConsole);
$exceptions->addAction($chromeConsole);

function debug($message, $tags = null) {
$GLOBALS['debug']->handle($message, $tags);
}

// test
debug('debug message', 'some,test,tags');
echo $unkownVar;
unkownFunction();

See video:
http://www.youtube.com/watch?v=hBCMB2Jiyvk
For all available Lagger features using see:
http://code.google.com/p/lagger/source/browse/trunk/examples/lagger_init.php
tools  browser  plugins  extensions  chrome  debug  php  console  logging 
june 2011 by michaelfox
tlrobinson.net / blog » Blog Archive » Automagically Wrapping JavaScript Callback Functions
One very nice thing about JavaScript is it’s support for first-class functions and closures. Crockford calls JavaScript “Lisp in C’s Clothing”. I’m no Lisper, but I enjoy I discovering new tricks or applications of functional programming in JavaScript.

I wanted to hook all the browser’s asynchronous JavaScript “entry points” : events, timers, asynchronous XMLHttpRequests, script tags, and “javascript:” URLs. This article deals with the first two, events and timers.

To do this, I figured I could somehow “wrap” all the callback functions passed to setTimeout(), setInterval(), and addEventListener(). By “wrapped” I mean another function that we specify calls the original function, rather than the original function getting called directly. This allows us do whatever we want right before and after calling the original function, including manipulating the arguments and return value, logging to the console, calling other functions, putting it in a try/catch, etc.
wrap  debug  breakout  hack  introspect  break  view  callback  functions  javascript 
october 2010 by michaelfox
Revitalizing Caching ✩ Mozilla Hacks – the Web developer blog
Apparently, there are only two hard problems in computer science: cache invalidation and the naming of things (or so Phil Karlton’s dictum goes). Earlier this month, we invited representatives of Twitter, Facebook, SproutCore, Palm’s webOS, Microsoft’s “Office On The Web”, Yahoo, and Google to talk to us about the former problem (amongst other things), though we also learned something about the latter.

Caching is an important issue to get right on the web, not least of all because of the proliferation of web applications on mobile devices. The goals of our caching summit were to identify use cases that would help us move forward with caching and with HTTP request efficiency. How desirable was rolling up our sleeves to look at HTTP/1.1 Pipelining in Firefox, for instance? What else was needed at the HTTP layer? And was the vaunted HTML5 AppCache, implemented in Firefox 3.5 onwards, actually useful to developers? What else needed to be exposed to web applications, either within content or via additional headers?

Developer feedback is invaluable, and is increasingly the basis of how we want to evolve the next integral pieces of the web platform. Web developers are one of our primary constituencies; going forward, we want them to help us prioritize what we should implement, and what we need to focus on with respect to web standards. We chose our attendees wisely; if any group of people could talk about web applications at scale, the current performance of the cache, and their wishlist for future browser caching behavior on the web platform, it was this group of people. And the feedback they gave us was copious and useful — our work is cut-out for us. Notably, we’ve got a few actions we’re going to follow-up on:
firefox  peformance  debug  profile  optimization  cache  caching  manifest 
october 2010 by michaelfox
John Resig - Browser Paint Events
A cool new browser event just recently landed in the latest Firefox nightlies: an event announcing when the browser re-draws a portion of the page.

This particular event, called MozAfterPaint fires whenever something is drawn to the screen.

The event object contains two properties: .clientRects and .boundingClientRect, both of which refer to the result of the associated DOM methods.

In a nutshell, boundingClientRect gives you a single rectangle encompassing the entire area in which a paint operation could've taken place whereas clientRects gives you a number of rectangles, each encompassing an individual area that was drawn.

To test this I created a quick demo using CNN.com (only works in the latest Firefox nightlies).
firefox  repaint  paint  peformance  bookmarklets  debug  profile  optimization  performance 
october 2010 by michaelfox
tlrobinson.net / blog » Blog Archive » Improved Browser Paint Events Bookmarklet
John Resig posted today about a nifty new feature available in Firefox nightlies, browser paint events. He also posted an example script and bookmarklet called TrackPaint. He goes into greater depth in his post, so I won’t bother here.

I wanted something more “real-time” and closer to the Quartz Debug utility included with the Mac OS X developer tools (which essentially provides this feature for all of OS X), so I present my modified bookmarklet and code:
firefox  repaint  paint  peformance  bookmarklets  debug  profile  optimization  performance 
october 2010 by michaelfox
Oxymoronical » Nightly Tester Tools
Nightly Tester Tools

This extension adds a few extras useful to those that regularly test nightly builds of Firefox, Thunderbird, Sunbird and Toolkit Seamonkey (Suiterunner).

Don’t forget that forcing an incompatible extension to install is risky. There are many cases where Firefox will stop working completely or behave incorrectly because an incompatible extension is being forced to work where the author never intended.

The following is a brief list of the extension’s features, for the full set of features please take a look at the features list.

* Extension compatibility fixing
* Titlebar customisation
* Build ID retrieval
* Screenshots
* Breakpad information
* Restoring tabs from previous session
* Leak log analysis
firefox  tools  peformance  debug  profile  optimization  performance  extension 
october 2010 by michaelfox
debugging painting with MozAfterPaint ✩ Mozilla Hacks – the Web developer blog
In addition, Thomas Robinson has created a very handy bookmarklet for debugging painting on a page you’ve loaded in the browser.

Due to popular demand, we’ve created a very experimental API for Firefox 3.5 to fire an event every time content is repainted. The event is is called MozAfterPaint and is fired at the document, bubbling up to the window. The event offers two attributes, clientRects and boundingClientRect, which tell you what was repainted, using the same objects and coordinate system as the getClientRects and getBoundingClientRect methods.

This is very useful for Firefox extensions and other “chrome” code that might be using the canvas.drawWindow method to capture the contents of windows. It might also be useful for tools like Firebug. But it’s also potentially useful for regular content, for example if you want to add some lightweight JS instrumentation to a page to measure what gets painted by Firefox, and when.

Caveats:

* This is Gecko-only. Do not use this for actual functionality on public Web pages – although I’m not sure why anyone would, so I don’t currently see this as a candidate for standardization.
* For security reasons, regular Web content is only notified of repainting that occurred in its own document – repainting caused by IFRAMEs is not reported to untrusted listeners attached to the IFRAME’s ancestors. (Listeners added by “trusted” content such as Firefox chrome are notified of all repaints to the window, however.)
* Currently the event might fire before the actual repainting happens. This shouldn’t matter much, and we’ll fix that at some point.
* If your event handler does anything that triggers repainting, such as changing the style of an element, you will probably trigger an infinite loop. The browser should stay responsive but your machine will contribute to global warming.
* Repainting of areas scrolled outside the viewport is reported, but repainting of areas scrolled outside overflow:auto elements and the like is not reported.
* Repainting in windowed plugins (i.e. most plugins in Windows and GTK) is not reported.
firefox  repaint  paint  peformance  bookmarklets  debug  profile  optimization  performance 
october 2010 by michaelfox
mrdoob's stats.js at master - GitHub
Stats.js
Javascript Performance Monitor

Flattr this

This class provides a simple info box that will help you monitor your code performance.

* FPS Frames rendered in the last second. The higher the number the better.
* MS Milliseconds needed to render a frame. The lower the number the better.
* MEM Mbytes of memory allocated. Make sure it doesn't keep incrementing. (Webkit-based browsers only)

Screenshots
javascript  performance  optimization  render  memory  debug  profile  tools  bookmarklets 
october 2010 by michaelfox
Two bookmarklets for debugging in IE / Stoyan's phpied.com
I saw this bookmarklet here and it's beautiful. When you start it, it puts a textarea at the bottom of your page and you can type javascript in it, then eval()-uate it. Perfect! Only ... it doesn't work in frames. So I did the same thing but when you have frames (works without frames as well). The way mine works is - you first select some text in a frame, then you click the bookmarklet. A new textarea, ready to execute javascript will be placed in this frame (or iframe) that you selected. Also in this case when you type document.something, it refers to the document in the frame, not the frameset.
If you don't select any text and click the bookmarklet, it will place the textarea in the topmost document, so it will work for frame-free pages as well.

So here's the bookmarklet.
textarea eval

And here's a page where you can test.
Bookmarklet 2 - dump anything

After having my beautiful textarea, I wanted to be able to dump variables, like print_r() or var_dump() but for Javascript. I googled and I found this little script. All I did then is to make it a bookmarklet. How it works? You select the bookmarklet, it gives you a prompt, where you type whatever you want to dump, like document.location for example. Then it shows you an alert with all properties of this thing you typed. (Don't try to dump document though, or something else that recurses, because the script won't handle the recursion and will freeze)
debug  debugging  ie  javascript  tools  resources  browser  troubleshooting  bookmarklets 
august 2010 by michaelfox
JavaScript Arguments
The arguments object in JavaScript is a local variable in any function that provides some nice features we can use in our code. Here is the list of its properties and related properties of the Function object.

arguments itself returns an object that looks like an array (but not really an array) of the arguments passed to the function.

Prior to JavaScript 1.4 the Function object also had a similar arguments property, which is now deprecated.

However the Function object comes with a few other useful properties that we can still use to get argument related data.
javascript  arguments  callee  caller  debugging  debug  trace  jquery 
june 2010 by michaelfox
Krumo: Version 2.0 of print_r(); and var_dump();
To put it simply, Krumo is a replacement for print_r() and var_dump(). By definition Krumo is a debugging tool (initially for PHP4/PHP5, now for PHP5 only), which displays structured information about any PHP variable.

A lot of developers use print_r() and var_dump() in the means of debugging tools. Although they were intended to present human readble information about a variable, we can all agree that in general they are not. Krumo is an alternative: it does the same job, but it presents the information beautified using CSS and DHTML.
debug  debugging  php  print_r  var_dump  troubleshooting  development  tools  environment 
april 2010 by michaelfox
Conditional Logging - GreaseSpot
An even simpler option, retaining all of Firebug's console routines, and not interfering with additional parameters.

const DEBUG = 1;
if (!DEBUG) {
var console = {
log: function() {},
info: function() {},
warn: function() {},
error: function() {},
};
}
greasemonkey  userscripts  javascript  debug  console  firebug  firefox  logging  webdev  tools  snippets  code  browser 
april 2010 by michaelfox

related tags

accelerators  admin  ajax  algorithms  apache  api  arguments  beautifier  bookmarklets  break  breakout  browser  bugs  buildsystems  cache  caching  callback  callee  caller  canary  chrome  chromium  cli  code  codeigniter  codesniffer  coding  compare  comparison  console  css  data  database  debug  debugger  debugging  detector  development  diff  documentation  DOM  dump  editor  environment  event  extension  extensions  fiddler  firebug  firefox  functions  generator  github  googlecode  greasemonkey  hack  howto  htaccess  html  html5  http  ide  ids  ie  ie6  ie7  inspector  introspect  ios  javascript  jquery  JSON  leak  library  log  logging  mac  mamp  manifest  memory  memoryleak  microsoft  mixedcontent  mobile  mod_rewrite  monitor  optimization  orm  osx  paint  peformance  performance  php  phpunit  plugin  plugins  print_r  profile  profiling  programming  proxy  reference  remote  render  repaint  repo  resources  reverseengineering  sass  scalability  scss  security  server  shell  sniffer  snippets  software  stack  styleguide  test  testing  tools  trace  troubleshooting  ui  unittesting  userscripts  utilities  utility  var_dump  view  visualization  web  webdev  webkit  wrap  xdebug  xhprof  yui 

Copy this bookmark:



description:


tags: