]> git.mxchange.org Git - friendica.git/blobdiff - src/App/Page.php
Merge pull request #11647 from Quix0r/fixes/type-error-exception
[friendica.git] / src / App / Page.php
index 14f0101ef07eb6f49d0207ec7620274c917a62c7..d38757687c99929bd62b8055fa7d78be1ac6a317 100644 (file)
@@ -30,6 +30,7 @@ use Friendica\Core\Config\Capability\IManageConfigValues;
 use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
 use Friendica\Core\Hook;
 use Friendica\Core\L10n;
+use Friendica\Core\Logger;
 use Friendica\Core\Renderer;
 use Friendica\Core\System;
 use Friendica\Core\Theme;
@@ -78,14 +79,37 @@ class Page implements ArrayAccess
         */
        private $basePath;
 
+       private $timestamp = 0;
+       private $command   = '';
+       private $method    = '';
+
        /**
         * @param string $basepath The Page basepath
         */
        public function __construct(string $basepath)
        {
+               $this->timestamp = microtime(true);
                $this->basePath = $basepath;
        }
 
+       public function setLogging(string $command, string $method)
+       {
+               $this->command = $command;
+               $this->method  = $method;
+       }
+
+       public function logRuntime(IManageConfigValues $config, string $origin = '')
+       {
+               if (in_array($this->command, $config->get('system', 'runtime_ignore'))) {
+                       return;
+               }
+
+               $runtime = number_format(microtime(true) - $this->timestamp, 3);
+               if ($runtime > $config->get('system', 'runtime_loglimit')) {
+                       Logger::debug('Runtime', ['method' => $this->method, 'command' => $this->command, 'runtime' => $runtime, 'origin' => $origin]);
+               }
+       }
+
        /**
         * Whether a offset exists
         *
@@ -421,6 +445,9 @@ class Page implements ArrayAccess
        {
                $moduleName = $args->getModuleName();
 
+               $this->command = $moduleName;
+               $this->method  = $args->getMethod();
+
                /* Create the page content.
                 * Calls all hooks which are including content operations
                 *