Allow -d (debug logging) command line argument

This commit is contained in:
Zach Copley 2009-07-17 18:36:13 -07:00
parent 5d5401b371
commit 9e8bcff5dd
1 changed files with 13 additions and 7 deletions

View File

@ -25,19 +25,18 @@ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
define('MAXCHILDREN', 2); define('MAXCHILDREN', 2);
define('POLL_INTERVAL', 60); // in seconds define('POLL_INTERVAL', 60); // in seconds
$shortoptions = 'i::'; $shortoptions = 'di::';
$longoptions = array('id::'); $longoptions = array('id::', 'debug');
$helptext = <<<END_OF_TRIM_HELP $helptext = <<<END_OF_TRIM_HELP
Batch script for retrieving Twitter messages from foreign service. Batch script for retrieving Twitter messages from foreign service.
-i --id Identity (default 'generic') -i --id Identity (default 'generic')
-d --debug Debug (lots of log output)
END_OF_TRIM_HELP; END_OF_TRIM_HELP;
require_once INSTALLDIR .'/scripts/commandline.inc'; require_once INSTALLDIR .'/scripts/commandline.inc';
require_once INSTALLDIR . '/lib/common.php';
require_once INSTALLDIR . '/lib/daemon.php'; require_once INSTALLDIR . '/lib/daemon.php';
/** /**
@ -89,6 +88,11 @@ class TwitterStatusFetcher extends Daemon
function run() function run()
{ {
if (defined('SCRIPT_DEBUG')) {
common_debug($this->name() .
': debugging log output enabled.');
}
do { do {
$flinks = $this->refreshFlinks(); $flinks = $this->refreshFlinks();
@ -649,7 +653,9 @@ if (have_option('i')) {
$id = null; $id = null;
} }
common_debug("id set to $id"); if (have_option('d') || have_option('debug')) {
define('SCRIPT_DEBUG', true);
}
$fetcher = new TwitterStatusFetcher($id); $fetcher = new TwitterStatusFetcher($id);
$fetcher->runOnce(); $fetcher->runOnce();