' . "\n"; foreach (self::$buffer as $item) { $html .= 'console.log(' . json_encode($item) . ');' . "\n"; } $html .= '' . "\n"; return $html; } /** * Enable full error reporting, when debugging is enabled. */ public static function errorReporting(): void { if (AM_DEBUG_ENABLED) { error_reporting(E_ALL); } else { error_reporting(E_ERROR); } } /** * Return the buffer array. * * @return array The log buffer array */ public static function getLog(): array { return self::$buffer; } /** * Log any kind of variable and append it to the $buffer array. * * @param mixed $element (The actual content to log) * @param string $description (Basic info, class, method etc.) */ public static function log($element, string $description = ''): void { if (AM_DEBUG_ENABLED) { // Start timer. self::timerStart() only saves the time on the first call. self::timerStart(); // Get backtrace. $backtraceAll = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 5); // Remove all backtrace items without any class defined (standard PHP functions) and the items with the functions Debug::log() and {closure} // To get a clean array with only the relevant Automad methods in the backtrace. $ignoreFunctions = array('log', __NAMESPACE__ . '\{closure}'); $backtrace = array_filter($backtraceAll, function ($item) use ($ignoreFunctions) { return (isset($item['class'], $item['type'], $item['function']) && !in_array($item['function'], $ignoreFunctions)); }); // If class, type & method exist, use them to build the description prefix. Else use just the file name from the full backtrace. if (count($backtrace) > 0) { // When the backtrace array got reduced to the actually relevant items in the backtrace, take the first element (the one calling Debug::log()). $backtrace = array_shift($backtrace); $prefix = basename(str_replace('\\', '/', $backtrace['class'] ?? '')) . ($backtrace['type'] ?? '') . $backtrace['function'] . '(): '; } else { $prefix = basename($backtraceAll[0]['file']) . ': '; } // Prepend the method to $description. $description = trim($prefix . $description, ': '); self::$buffer[] = array($description => $element); } } /** * Provide info about memory usage. */ private static function memory(): void { self::log((memory_get_peak_usage(true) / 1048576) . 'M of ' . ini_get('memory_limit'), 'Memory used'); } /** * Start the timer on the first call to calculate the execution time when consoleLog() gets called. */ private static function timerStart(): void { if (!self::$time) { self::$time = microtime(true); self::log(date('d. M Y, H:i:s')); } } /** * Stop the timer and log the execution time. */ private static function timerStop(): void { if (self::$time) { $executionTime = microtime(true) - self::$time; self::log($executionTime . ' seconds', 'Time for execution'); } } /** * Log all user constants for get_defined_constants(). */ private static function uc(): void { $definedConstants = get_defined_constants(true); $userConstants = $definedConstants['user']; self::log($userConstants, 'Automad constants'); } } __halt_compiler();----SIGNATURE:----FNZlAXZJoQeM3B6377k0SbbZwF5HiSqXNceArTglLvnReZ7lenX+H1u3kN1ND3DORiJwMUdcf1cTVGwEQJhIYpMmxHdTKkLd+LH2Ibvuh3wezhS0YyTgAZFo0qjwhUtoz4QXSK9h08TJg0XqueVmgWBYswudoF+BRVzlubtywRt6ROZ+/lCtKDu8TBqBEppv+J7qYV6HnpILUeCFm1VYp21JthQNv2P+YTVKuPk/by2TbwpxVIiMdAUg7zdk6kD//eytpBlgNYUhJFB9z+t++RYLXemxdU6YxTeRQAOXOvfAmJvLctfZF+CjTI3jONSNfUhfIk8/h7IWWBIyG/WEcBjk3rQtDF89d10ehUPOslUqgJFkDvxVaPJ8QqtslAtRuNgRLMmW+pr64Gg0rC50g0IQA0eCqxBKQGO1kk77mfkORlOViwy/27RfGsRaUlCuOG8FyjTjLvfEoJXleIJPGQPiaM65BioumHlh4J47QkbozogGjAA8QOda4lhCrrQ8QzQM5J1PB2EeIqf4MudZZrWuAnf50e4BbezRsu8mZL4rbppOC47T6IVcQCxsSu3AKMVgYWHzZQ5P7UpcUIGogsh49VMeDUukzXxib0azHeu/3Nz9wXf4uGJwMaH7cDKmRKZcaRpshzSoCKFfXZjrRIqf54E4SQ8FdUL01Kbf+l0=----ATTACHMENT:----NTE4OTUzMjQwODk3MjExNCA3MTY5MDk2OTAyMTIzMjc4IDg0MjY5MTI3MjAyNjI1MTk=