summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2018-11-30 08:34:29 +0300
committerAndrew Dolgov <[email protected]>2018-11-30 08:34:29 +0300
commitc10a43069ec1e71b6608574a81fb29c76919e132 (patch)
tree69b94003a2512b14e488b0553cf944e2bbdba2a8 /plugins
parent758752684c68efd179071cd77c92f78879e68f6d (diff)
debug logging system rework:
* support various logging levels per-message * remove hacks like debug_suppress, DAEMON_EXTENDED_DEBUG, etc * _debug() is kept as a compatibility shim for plugins
Diffstat (limited to 'plugins')
-rw-r--r--plugins/af_comics/filters/af_comics_pa.php7
-rw-r--r--plugins/af_psql_trgm/init.php4
-rwxr-xr-xplugins/af_redditimgur/init.php38
-rwxr-xr-xplugins/cache_starred_images/init.php6
-rwxr-xr-xplugins/import_export/init.php4
5 files changed, 26 insertions, 33 deletions
diff --git a/plugins/af_comics/filters/af_comics_pa.php b/plugins/af_comics/filters/af_comics_pa.php
index e6558d8de..7a60feabb 100644
--- a/plugins/af_comics/filters/af_comics_pa.php
+++ b/plugins/af_comics/filters/af_comics_pa.php
@@ -8,10 +8,6 @@ class Af_Comics_Pa extends Af_ComicFilter {
function process(&$article) {
if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "Comic:") !== FALSE) {
- /*if ($debug_enabled) {
- _debug("af_pennyarcade: Processing comic");
- }*/
-
$doc = new DOMDocument();
if ($doc->loadHTML(fetch_file_contents($article["link"]))) {
@@ -27,9 +23,6 @@ class Af_Comics_Pa extends Af_ComicFilter {
}
if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "News Post:") !== FALSE) {
- /*if ($debug_enabled) {
- _debug("af_pennyarcade: Processing news post");
- }*/
$doc = new DOMDocument();
if ($doc->loadHTML(fetch_file_contents($article["link"]))) {
diff --git a/plugins/af_psql_trgm/init.php b/plugins/af_psql_trgm/init.php
index 19653c0f3..fe5b1a959 100644
--- a/plugins/af_psql_trgm/init.php
+++ b/plugins/af_psql_trgm/init.php
@@ -287,7 +287,7 @@ class Af_Psql_Trgm extends Plugin {
$row = $sth->fetch();
$nequal = $row['nequal'];
- _debug("af_psql_trgm: num equals: $nequal");
+ Debug::log("af_psql_trgm: num equals: $nequal", Debug::$LOG_EXTENDED);
if ($nequal != 0) {
$article["force_catchup"] = true;
@@ -304,7 +304,7 @@ class Af_Psql_Trgm extends Plugin {
$row = $sth->fetch();
$similarity_result = $row['ms'];
- _debug("af_psql_trgm: similarity result: $similarity_result");
+ Debug::log("af_psql_trgm: similarity result: $similarity_result", Debug::$LOG_EXTENDED);
if ($similarity_result >= $similarity) {
$article["force_catchup"] = true;
diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php
index be3a5108e..2b8415dd0 100755
--- a/plugins/af_redditimgur/init.php
+++ b/plugins/af_redditimgur/init.php
@@ -82,7 +82,7 @@ class Af_RedditImgur extends Plugin {
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
- private function inline_stuff($article, &$doc, $xpath, $debug = false) {
+ private function inline_stuff($article, &$doc, $xpath) {
$entries = $xpath->query('(//a[@href]|//img[@src])');
$img_entries = $xpath->query("(//img[@src])");
@@ -93,12 +93,12 @@ class Af_RedditImgur extends Plugin {
foreach ($entries as $entry) {
if ($entry->hasAttribute("href") && strpos($entry->getAttribute("href"), "reddit.com") === FALSE) {
- _debug("processing href: " . $entry->getAttribute("href"), $debug);
+ Debug::log("processing href: " . $entry->getAttribute("href"), Debug::$LOG_VERBOSE);
$matches = array();
if (!$found && preg_match("/^https?:\/\/twitter.com\/(.*?)\/status\/(.*)/", $entry->getAttribute("href"), $matches)) {
- _debug("handling as twitter: " . $matches[1] . " " . $matches[2], $debug);
+ Debug::log("handling as twitter: " . $matches[1] . " " . $matches[2], Debug::$LOG_VERBOSE);
$oembed_result = fetch_file_contents("https://publish.twitter.com/oembed?url=" . urlencode($entry->getAttribute("href")));
@@ -130,7 +130,7 @@ class Af_RedditImgur extends Plugin {
if (!$found && preg_match("/https?:\/\/(www\.)?gfycat.com\/([a-z]+)$/i", $entry->getAttribute("href"), $matches)) {
- _debug("Handling as Gfycat", $debug);
+ Debug::log("Handling as Gfycat", Debug::$LOG_VERBOSE);
$source_stream = 'https://giant.gfycat.com/' . $matches[2] . '.mp4';
$poster_url = 'https://thumbs.gfycat.com/' . $matches[2] . '-mobile.jpg';
@@ -145,7 +145,7 @@ class Af_RedditImgur extends Plugin {
if (!$found && preg_match("/https?:\/\/v\.redd\.it\/(.*)$/i", $entry->getAttribute("href"), $matches)) {
- _debug("Handling as reddit inline video", $debug);
+ Debug::log("Handling as reddit inline video", Debug::$LOG_VERBOSE);
$img = $img_entries->item(0);
@@ -157,7 +157,7 @@ class Af_RedditImgur extends Plugin {
// Get original article URL from v.redd.it redirects
$source_article_url = $this->get_location($matches[0]);
- _debug("Resolved ".$matches[0]." to ".$source_article_url, $debug);
+ Debug::log("Resolved ".$matches[0]." to ".$source_article_url, Debug::$LOG_VERBOSE);
$source_stream = false;
@@ -190,7 +190,7 @@ class Af_RedditImgur extends Plugin {
if (!$found && preg_match("/https?:\/\/(www\.)?streamable.com\//i", $entry->getAttribute("href"))) {
- _debug("Handling as Streamable", $debug);
+ Debug::log("Handling as Streamable", Debug::$LOG_VERBOSE);
$tmp = fetch_file_contents($entry->getAttribute("href"));
@@ -216,21 +216,21 @@ class Af_RedditImgur extends Plugin {
// imgur .gif -> .gifv
if (!$found && preg_match("/i\.imgur\.com\/(.*?)\.gif$/i", $entry->getAttribute("href"))) {
- _debug("Handling as imgur gif (->gifv)", $debug);
+ Debug::log("Handling as imgur gif (->gifv)", Debug::$LOG_VERBOSE);
$entry->setAttribute("href",
str_replace(".gif", ".gifv", $entry->getAttribute("href")));
}
if (!$found && preg_match("/\.(gifv|mp4)$/i", $entry->getAttribute("href"))) {
- _debug("Handling as imgur gifv", $debug);
+ Debug::log("Handling as imgur gifv", Debug::$LOG_VERBOSE);
$source_stream = str_replace(".gifv", ".mp4", $entry->getAttribute("href"));
if (strpos($source_stream, "imgur.com") !== FALSE)
$poster_url = str_replace(".mp4", "h.jpg", $source_stream);
- $this->handle_as_video($doc, $entry, $source_stream, $poster_url, $debug);
+ $this->handle_as_video($doc, $entry, $source_stream, $poster_url);
$found = true;
}
@@ -243,7 +243,7 @@ class Af_RedditImgur extends Plugin {
$vid_id = $matches[1];
- _debug("Handling as youtube: $vid_id", $debug);
+ Debug::log("Handling as youtube: $vid_id", Debug::$LOG_VERBOSE);
$iframe = $doc->createElement("iframe");
$iframe->setAttribute("class", "youtube-player");
@@ -265,7 +265,7 @@ class Af_RedditImgur extends Plugin {
mb_strpos($entry->getAttribute("href"), "i.reddituploads.com") !== FALSE ||
mb_strpos($this->get_content_type($entry->getAttribute("href")), "image/") !== FALSE) {
- _debug("Handling as a picture", $debug);
+ Debug::log("Handling as a picture", Debug::$LOG_VERBOSE);
$img = $doc->createElement('img');
$img->setAttribute("src", $entry->getAttribute("href"));
@@ -281,7 +281,7 @@ class Af_RedditImgur extends Plugin {
if (!$found && preg_match("/^https?:\/\/gyazo\.com\/([^\.\/]+$)/", $entry->getAttribute("href"), $matches)) {
$img_id = $matches[1];
- _debug("handling as gyazo: $img_id", $debug);
+ Debug::log("handling as gyazo: $img_id", Debug::$LOG_VERBOSE);
$img = $doc->createElement('img');
$img->setAttribute("src", "https://i.gyazo.com/$img_id.jpg");
@@ -295,7 +295,7 @@ class Af_RedditImgur extends Plugin {
// let's try meta properties
if (!$found) {
- _debug("looking for meta og:image", $debug);
+ Debug::log("looking for meta og:image", Debug::$LOG_VERBOSE);
$content = fetch_file_contents(["url" => $entry->getAttribute("href"),
"http_accept" => "text/*"]);
@@ -415,9 +415,9 @@ class Af_RedditImgur extends Plugin {
return 2;
}
- private function handle_as_video($doc, $entry, $source_stream, $poster_url = false, $debug = false) {
+ private function handle_as_video($doc, $entry, $source_stream, $poster_url = false) {
- _debug("handle_as_video: $source_stream", $debug);
+ Debug::log("handle_as_video: $source_stream", Debug::$LOG_VERBOSE);
$video = $doc->createElement('video');
$video->setAttribute("autoplay", "1");
@@ -454,14 +454,14 @@ class Af_RedditImgur extends Plugin {
@$doc->loadHTML("<html><body><a href=\"$url\">[link]</a></body>");
$xpath = new DOMXPath($doc);
- $found = $this->inline_stuff([], $doc, $xpath, true);
+ $found = $this->inline_stuff([], $doc, $xpath);
print "Inline result: $found\n";
if (!$found) {
print "\nReadability result:\n";
- $article = $this->readability([], $url, $doc, $xpath, true);
+ $article = $this->readability([], $url, $doc, $xpath);
print_r($article);
} else {
@@ -523,7 +523,7 @@ class Af_RedditImgur extends Plugin {
"useragent" => $useragent_compat,
"http_accept" => "text/html"]);
- if ($debug) _debug("tmplen: " . mb_strlen($tmp));
+ Debug::log("tmplen: " . mb_strlen($tmp), Debug::$LOG_VERBOSE);
if ($tmp && mb_strlen($tmp) < 1024 * 500) {
diff --git a/plugins/cache_starred_images/init.php b/plugins/cache_starred_images/init.php
index ae0eaf56d..a1916e226 100755
--- a/plugins/cache_starred_images/init.php
+++ b/plugins/cache_starred_images/init.php
@@ -170,7 +170,7 @@ class Cache_Starred_Images extends Plugin implements IHandler {
$status_filename = $this->cache_dir . $article_id . "-" . sha1($site_url) . ".status";
- //_debug("status: $status_filename"); return;
+ Debug::log("status: $status_filename", Debug::$LOG_EXTENDED);
if (file_exists($status_filename))
$status = json_decode(file_get_contents($status_filename), true);
@@ -181,7 +181,7 @@ class Cache_Starred_Images extends Plugin implements IHandler {
// only allow several download attempts for article
if ($status["attempt"] > $this->max_cache_attempts) {
- _debug("too many attempts for $site_url");
+ Debug::log("too many attempts for $site_url", Debug::$LOG_VERBOSE);
return;
}
@@ -214,7 +214,7 @@ class Cache_Starred_Images extends Plugin implements IHandler {
$local_filename = $this->cache_dir . $article_id . "-" . sha1($src) . $extension;
- //_debug("cache_images: downloading: $src to $local_filename");
+ Debug::log("cache_images: downloading: $src to $local_filename", Debug::$LOG_VERBOSE);
if (!file_exists($local_filename)) {
$file_content = fetch_file_contents(["url" => $src, "max_size" => MAX_CACHE_FILE_SIZE]);
diff --git a/plugins/import_export/init.php b/plugins/import_export/init.php
index a3413f307..ef1e2db65 100755
--- a/plugins/import_export/init.php
+++ b/plugins/import_export/init.php
@@ -24,11 +24,11 @@ class Import_Export extends Plugin implements IHandler {
return;
}
- _debug("please enter your username:");
+ Debug::log("please enter your username:");
$username = trim(read_stdin());
- _debug("importing $filename for user $username...\n");
+ Debug::log("importing $filename for user $username...\n");
$sth = $this->pdo->prepare("SELECT id FROM ttrss_users WHERE login = ?");
$sth->execute($username);