diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2016-11-10 20:52:35 +0100 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2016-11-10 20:52:35 +0100 |
| commit | 696fcd7ce4d495e356667019493bf312e2a6e47b (patch) | |
| tree | 3e8d60dad08dbe31660f2532d8ce893d35d50130 /bin | |
| parent | 9ff01ebe8cde0a07ad2a480d1a45eb1a29cb113d (diff) | |
| download | phinde-696fcd7ce4d495e356667019493bf312e2a6e47b.tar.gz phinde-696fcd7ce4d495e356667019493bf312e2a6e47b.zip | |
add log class
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/phinde-worker.php | 9 | ||||
| -rwxr-xr-x | bin/process.php | 8 | ||||
| -rwxr-xr-x | bin/setup.php | 2 |
3 files changed, 10 insertions, 9 deletions
diff --git a/bin/phinde-worker.php b/bin/phinde-worker.php index 9f8c35a..9b65e32 100755 --- a/bin/phinde-worker.php +++ b/bin/phinde-worker.php @@ -13,9 +13,10 @@ $gmworker->addFunction( $GLOBALS['phinde']['queuePrefix'] . 'phinde_process', function(\GearmanJob $job) { $data = unserialize($job->workload()); - echo "-- Processing " . $data['url'] + Log::info( + "-- Processing " . $data['url'] . ' (' . implode(',', $data['actions']) . ')' - . "\n"; + ); passthru( './process.php ' . escapeshellarg($data['url']) . ' ' . implode(' ', $data['actions']) @@ -26,7 +27,7 @@ $gmworker->addFunction( $gmworker->addFunction( $GLOBALS['phinde']['queuePrefix'] . 'phinde_quit', function(\GearmanJob $job) { - echo "Got exit job\n"; + Log::info('Got exit job'); $job->sendComplete(''); exit(0); } @@ -34,7 +35,7 @@ $gmworker->addFunction( while ($gmworker->work()) { if ($gmworker->returnCode() != GEARMAN_SUCCESS) { - echo 'Error running job: ' . $gmworker->returnCode() . "\n"; + Log::error('Error running job: ' . $gmworker->returnCode()); break; } } diff --git a/bin/process.php b/bin/process.php index ababb03..1bae7c4 100755 --- a/bin/process.php +++ b/bin/process.php @@ -54,7 +54,7 @@ $url = Helper::addSchema($url); $urlObj = new \Net_URL2($url); $url = $urlObj->getNormalizedURL(); if (!Helper::isUrlAllowed($url)) { - echo "Domain is not allowed; not crawling\n"; + Log::error("Domain is not allowed; not crawling"); exit(2); } @@ -78,7 +78,7 @@ try { $update = false; foreach ($actions as $key => $action) { - echo "step: $key\n"; + Log::info("step: $key"); $update |= $action->run($retrieved); } @@ -86,10 +86,10 @@ try { //FIXME: update index if it exists already $fetcher->storeDoc($retrieved->url, $retrieved->esDoc); } else { - echo "Not updating\n"; + Log::info("Not updating"); } } catch (\Exception $e) { - echo $e->getMessage() . "\n"; + Log::error($e->getMessage()); exit(10); } ?>
\ No newline at end of file diff --git a/bin/setup.php b/bin/setup.php index 27c5c46..ba97493 100755 --- a/bin/setup.php +++ b/bin/setup.php @@ -9,7 +9,7 @@ require_once __DIR__ . '/../src/init.php'; $json = file_get_contents(__DIR__ . '/../data/elasticsearch-mapping.json'); if (json_decode($json) === null) { - echo "Error: Schema JSON is broken\n"; + Log::error("Error: Schema JSON is broken"); chdir(__DIR__ . '/../'); passthru('json_pp -t null < data/elasticsearch-mapping.json'); exit(1); |
