1 | <?php |
||
9 | class CrawlLogger implements CrawlObserver |
||
10 | { |
||
11 | const UNRESPONSIVE_HOST = 'Host did not respond'; |
||
12 | |||
13 | /** |
||
14 | * @var \Symfony\Component\Console\Output\OutputInterface |
||
15 | */ |
||
16 | protected $output; |
||
17 | |||
18 | /** |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $crawledUrls = []; |
||
22 | |||
23 | /** |
||
24 | * @var string|null |
||
25 | */ |
||
26 | protected $outputFile = null; |
||
27 | |||
28 | /** |
||
29 | * @var bool |
||
30 | */ |
||
31 | protected $overwriteOutputFile = false; |
||
32 | |||
33 | /** |
||
34 | * @param \Symfony\Component\Console\Output\OutputInterface $output |
||
35 | */ |
||
36 | public function __construct(OutputInterface $output) |
||
40 | |||
41 | /** |
||
42 | * Called when the crawl will crawl the url. |
||
43 | * |
||
44 | * @param \Spatie\Crawler\Url $url |
||
45 | */ |
||
46 | public function willCrawl(Url $url) |
||
49 | |||
50 | /** |
||
51 | * Called when the crawler has crawled the given url. |
||
52 | * |
||
53 | * @param \Spatie\Crawler\Url $url |
||
54 | * @param \Psr\Http\Message\ResponseInterface|null $response |
||
55 | * @param \Spatie\Crawler\Url $foundOn |
||
56 | */ |
||
57 | public function hasBeenCrawled(Url $url, $response, Url $foundOn = null) |
||
77 | |||
78 | /** |
||
79 | * Called when the crawl has ended. |
||
80 | */ |
||
81 | public function finishedCrawling() |
||
124 | |||
125 | protected function getColorTagForStatusCode(string $code): string |
||
137 | |||
138 | /** |
||
139 | * @param string|null $haystack |
||
140 | * @param string|array $needles |
||
141 | * |
||
142 | * @return bool |
||
143 | */ |
||
144 | public function startsWith($haystack, $needles): bool |
||
154 | |||
155 | /** |
||
156 | * Set the filename to write the output log. |
||
157 | * |
||
158 | * @param string $filename |
||
159 | */ |
||
160 | public function setOutputFile($filename) |
||
164 | |||
165 | /** |
||
166 | * Set the state indicating if the output file should be overwritten. |
||
167 | * |
||
168 | * @param bool $flag |
||
169 | */ |
||
170 | public function setOverwriteOutputFile($flag) |
||
174 | } |
||
175 |