]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - inc/3rdparty/libraries/PHPePub/Logger.php
3 * Simple log line aggregator.
5 * @author A. Grandt <php@grandt.com>
6 * @copyright 2012-2013 A. Grandt
7 * @license GNU LGPL, Attribution required for commercial implementations, requested for everything else.
17 private $isLogging = FALSE;
18 private $isDebugging = FALSE;
25 function __construct($name = NULL, $isLogging = FALSE) {
29 $this->name
= $name . " : ";
31 $this->isLogging
= $isLogging;
39 * @TODO make sure elements in the destructor match the current class elements
41 function __destruct() {
46 /* Prepare Logging. Just in case it's used. later */
47 if ($this->isLogging
) {
48 $this->tStart
= gettimeofday();
49 $this->tLast
= $this->tStart
;
50 $this->log
= "<h1>Log: " . $this->name
. "</h1>\n<pre>Started: " . gmdate("D, d M Y H:i:s T", $this->tStart
['sec']) . "\n Δ Start ; Δ Last ;";
51 $this->logLine("Start");
55 function dumpInstalledModules() {
56 if ($this->isLogging
) {
57 $isCurlInstalled = extension_loaded('curl') && function_exists('curl_version');
58 $isGdInstalled = extension_loaded('gd') && function_exists('gd_info');
59 $isExifInstalled = extension_loaded('exif') && function_exists('exif_imagetype');
60 $isFileGetContentsInstalled = function_exists('file_get_contents');
61 $isFileGetContentsExtInstalled = $isFileGetContentsInstalled && ini_get('allow_url_fopen');
63 $this->logLine("isCurlInstalled...............: " . ($isCurlInstalled ? "Yes" : "No"));
64 $this->logLine("isGdInstalled.................: " . ($isGdInstalled ? "Yes" : "No"));
65 $this->logLine("isExifInstalled...............: " . ($isExifInstalled ? "Yes" : "No"));
66 $this->logLine("isFileGetContentsInstalled....: " . ($isFileGetContentsInstalled ? "Yes" : "No"));
67 $this->logLine("isFileGetContentsExtInstalled.: " . ($isFileGetContentsExtInstalled ? "Yes" : "No"));
71 function logLine($line) {
72 if ($this->isLogging
) {
73 $tTemp = gettimeofday();
74 $tS = $this->tStart
['sec'] +
(((int)($this->tStart
['usec']/100))/10000);
75 $tL = $this->tLast
['sec'] +
(((int)($this->tLast
['usec']/100))/10000);
76 $tT = $tTemp['sec'] +
(((int)($tTemp['usec']/100))/10000);
78 $logline = sprintf("\n+%08.04f; +%08.04f; ", ($tT-$tS), ($tT-$tL)) . $this->name
. $line;
79 $this->log
.= $logline;
80 $this->tLast
= $tTemp;
82 if ($this->isDebugging
) {
83 echo "<pre>" . $logline . "\n</pre>\n";