]> git.wh0rd.org Git - tt-rss.git/commitdiff
add timestamps to daemon debug output
authorAndrew Dolgov <fox@madoka.spb.ru>
Thu, 8 Mar 2007 17:36:42 +0000 (18:36 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Thu, 8 Mar 2007 17:36:42 +0000 (18:36 +0100)
functions.php
update_daemon.php

index f051513692e2b5eca4104aefd416c969bb89a09a..ee22621ff60b38510f1234b01323dba3ff26756c 100644 (file)
        require_once "magpierss/rss_fetch.inc";
        require_once 'magpierss/rss_utils.inc';
 
+       function _debug($msg) {
+               $ts = strftime("%H:%M:%S", time());
+               print "[$ts] $msg\n";
+       }
+
        function purge_feed($link, $feed_id, $purge_interval, $debug = false) {
 
                $rows = -1;
@@ -90,7 +95,7 @@
                }
 
                if ($debug) {
-                       print "Purged feed $feed_id ($purge_interval): deleted $rows articles\n";
+                       _debug("Purged feed $feed_id ($purge_interval): deleted $rows articles");
                }
        }
 
index 77660f09d3cc0bbb201217cd8cd130a4ddc4a562..6327950193957b1b57edb9bf945d8dabe149b05c 100644 (file)
@@ -59,7 +59,7 @@
        while (true) {
 
                if (time() - $last_purge > PURGE_INTERVAL) {
-                       print "Purging old posts (random 30 feeds)...\n";
+                       _debug("Purging old posts (random 30 feeds)...");
                        global_purge_old_posts($link, true, 30);
                        $last_purge = time();
                }
 
                $user_prefs_cache = array();
 
-               printf("Scheduled %d feeds to update...\n", db_num_rows($result));
+               _debug(sprintf("Scheduled %d feeds to update...\n", db_num_rows($result)));
                
                while ($line = db_fetch_assoc($result)) {
        
                                continue; 
                        }
        
-                       print "Feed: " . $line["feed_url"] . ": ";
+                       _debug("Feed: " . $line["feed_url"]);
 
-                       printf("(%d/%d, %d) ", time() - strtotime($line["last_updated"]),
-                               $upd_intl*60, $user_id);
+//                     _debug(sprintf("\tLU: %d, INTL: %d, UID: %d) ", 
+//                             time() - strtotime($line["last_updated"]), $upd_intl*60, $user_id));
        
                        if (!$line["last_updated"] || 
                                time() - strtotime($line["last_updated"]) > ($upd_intl * 60)) {
-       
-                               print "Updating...\n";  
+
+                               _debug("\tUpdating...");
+
                                update_rss_feed($link, $line["feed_url"], $line["id"], true);   
                                sleep(1); // prevent flood (FIXME make this an option?)
                        } else {
-                               print "Update not needed.\n";
+                               _debug("\tUpdate not needed.");
                        }
                }
 
                if (DAEMON_SENDS_DIGESTS) send_headlines_digests($link);
 
-               print "Sleeping for " . DAEMON_SLEEP_INTERVAL . " seconds...\n";
+               _debug("Sleeping for " . DAEMON_SLEEP_INTERVAL . " seconds...");
                
                sleep(DAEMON_SLEEP_INTERVAL);
        }