Some people are debuggers.
Stepping their way through the binary jungle, one hack at a time.
For those of you who are loggers, staring at the console for interesting events:
I had some time to write a small php script that will put a console.log for every method in a canjs controller.
Should save me loads of monotony when reverse engineering OPC ( other peoples code ).
Hope you find it useful:
<?php
if( !isset( $argv[1] ) )
$argv[1] = 'Storage.js';
$fileInfo = pathinfo( $argv[1] );
$outFile = $fileInfo['dirname'] . '/' . $fileInfo['filename'] . '_debug.' . $fileInfo['extension'];
$in = fopen($argv[1], 'r');
$out = fopen($outFile, 'w');
while( !feof( $in ) ){
$line = fgets($in);
if( preg_match('/:\W+function/', $line)){
preg_match("/\((.*)\)/", $line, $matches);
$function = explode(':', $line );
$functionName = trim($function[0]);
if( isset( $matches[1] ) && strlen($matches[1]) > 0 )
$line .= "\nconsole.log( '$fileInfo[filename]', '$functionName', $matches[1] )\n";
else
$line .= "\nconsole.log( '$fileInfo[filename]', '$functionName' )\n";
}
fputs($out, $line);
}
fclose($in);
fclose($out);