Skip to content

Instantly share code, notes, and snippets.

@eabait
Created April 20, 2012 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eabait/2427905 to your computer and use it in GitHub Desktop.
Save eabait/2427905 to your computer and use it in GitHub Desktop.
Simple remote debugging for web mobile development
$debugFile = dirname(__FILE__) . '/debug.log';
$date = date('Y:m:d G:i:s') . "\n";
$line = str_repeat('-', 80);
//log request
$message = print_r($_REQUEST, true);
$message = "\n" . $line . "\n" . $date . "\n" . $message . "\n" . $line;
$file = fopen($debugFile,'a');
fwrite($file, $message);
fclose($file);
echo "request written to: $debugFile";
/*
* Taken from Alberto's Miranda post: http://metacodigo.com.ar/?p=412
* The main idea is to change console.log for an
* ajax call to the server which logs the
* message in a file
*/
console.log = function(msg){
//set your remote debugging server ip and path here
var debuggerUrl = 'http://192.168.0.200/debug.php';
$.ajax({
url: debuggerUrl,
type: 'POST',
data: {
message: msg
},
error: function(response){
alert('Oops... unable to write log!');
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment