Skip to content

Commit c1fe002

Browse files
authored
Merge pull request #203 from Simounet/feat/jsonld-logger-infos
Logger infos added for JsonLd parsing
2 parents c7fcea0 + e2314b6 commit c1fe002

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Extractor/ContentExtractor.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,21 +1163,25 @@ private function extractJsonLdInformation($html)
11631163
// just in case datePublished isn't defined, we use the modified one at first
11641164
if (isset($data['dateModified'])) {
11651165
$this->date = $data['dateModified'];
1166+
$this->logger->info('date matched from JsonLd: {date}', ['date' => $this->date]);
11661167
}
11671168

11681169
if (isset($data['datePublished'])) {
11691170
$this->date = $data['datePublished'];
1171+
$this->logger->info('date matched from JsonLd: {date}', ['date' => $this->date]);
11701172
}
11711173

11721174
// sometimes the date is an array
11731175
if (\is_array($this->date)) {
11741176
$this->date = reset($this->date);
1177+
$this->logger->info('date matched from JsonLd: {date}', ['date' => $this->date]);
11751178
}
11761179

11771180
// body should be a DOMNode
11781181
if (isset($data['articlebody'])) {
11791182
$dom = new \DOMDocument('1.0', 'utf-8');
11801183
$this->body = $dom->createElement('p', htmlspecialchars(trim($data['articlebody'])));
1184+
$this->logger->info('body matched from JsonLd: {body}', ['body' => $this->body]);
11811185
}
11821186

11831187
if (isset($data['headline'])) {
@@ -1197,6 +1201,7 @@ private function extractJsonLdInformation($html)
11971201

11981202
foreach ($authors as $author) {
11991203
$this->addAuthor($author);
1204+
$this->logger->info('author matched from JsonLd: {author}', ['author' => $author]);
12001205
}
12011206
}
12021207
}
@@ -1205,6 +1210,7 @@ private function extractJsonLdInformation($html)
12051210
foreach ($candidateNames as $name) {
12061211
if (!\in_array($name, $ignoreNames, true)) {
12071212
$this->title = $name;
1213+
$this->logger->info('title matched from JsonLd: {{title}}', ['title' => $name]);
12081214
}
12091215
}
12101216
}

0 commit comments

Comments
 (0)