src/Koldy/Log/Adapter/AbstractLogAdapter.php
public function dump(): void
    {
        $dump = $this->config['dump'] ?? [];

        if (is_array($dump) && count($dump) > 0) {
            // 'speed', 'included_files', 'include_path', 'whitespace'
            $dump = array_flip($dump);

            $url = isset($_SERVER['REQUEST_METHOD']) ? ($_SERVER['REQUEST_METHOD'] . '=' . Application::getCurrentURL()) : ('CLI=' . Application::getCliName());

            if (array_key_exists('speed', $dump)) {
                $executedIn = Application::getRequestExecutionTime();
                $count = count(get_included_files());
                $this->logMessage(new Message('notice', "{$url} EXECUTED IN {$executedIn}ms, used {$count} files"));
            }

            if (array_key_exists('memory', $dump)) {
                $memory = memory_get_usage();
                $peak = memory_get_peak_usage();
                $allocatedMemory = memory_get_peak_usage(true);
                $memoryLimit = ini_get('memory_limit') ?? -1;

                $memoryKb = round($memory / 1024, 2);
                $peakKb = round($peak / 1024, 2);
                $allocatedMemoryKb = round($allocatedMemory / 1024, 2);

                $limit = '';
                $peakSpent = '';

                if ($memoryLimit > 0) {
                    $limitInt = Convert::stringToBytes($memoryLimit);
                    $limit = ", limit: {$memoryLimit}";

                    $spent = round($peak / $limitInt * 100, 2);
                    $peakSpent = " ({$spent}% of limit)";
                }

                $this->logMessage(new Message('notice', "{$url} CONSUMED MEM: current: {$memoryKb}kb, peak: {$peakKb}kb{$peakSpent}, allocated: {$allocatedMemoryKb}kb{$limit}"));
            }

            if (array_key_exists('included_files', $dump)) {
                $this->logMessage(new Message('notice', 'Included files: ' . print_r(get_included_files(), true)));
            }

            if (array_key_exists('whitespace', $dump)) {
                $this->logMessage(new Message('notice', "END OF {$url}\n" . str_repeat('#', 120) . "\n\n"));
            }
        }
    }
public function dump(): void
    {
        $dump = $this->config['dump'] ?? [];

        if (is_array($dump) && count($dump) > 0) {
            // 'speed', 'included_files', 'include_path', 'whitespace'
            $dump = array_flip($dump);

            $url = isset($_SERVER['REQUEST_METHOD']) ? ($_SERVER['REQUEST_METHOD'] . '=' . Application::getCurrentURL()) : ('CLI=' . Application::getCliName());

            if (array_key_exists('speed', $dump)) {
                $executedIn = Application::getRequestExecutionTime();
                $count = count(get_included_files());
                $this->logMessage(new Message('notice', "{$url} EXECUTED IN {$executedIn}ms, used {$count} files"));
            }

            if (array_key_exists('memory', $dump)) {
                $memory = memory_get_usage();
                $peak = memory_get_peak_usage();
                $allocatedMemory = memory_get_peak_usage(true);
                $memoryLimit = ini_get('memory_limit') ?? -1;

                $memoryKb = round($memory / 1024, 2);
                $peakKb = round($peak / 1024, 2);
                $allocatedMemoryKb = round($allocatedMemory / 1024, 2);

                $limit = '';
                $peakSpent = '';

                if ($memoryLimit > 0) {
                    $limitInt = Convert::stringToBytes($memoryLimit);
                    $limit = ", limit: {$memoryLimit}";

                    $spent = round($peak / $limitInt * 100, 2);
                    $peakSpent = " ({$spent}% of limit)";
                }

                $this->logMessage(new Message('notice', "{$url} CONSUMED MEM: current: {$memoryKb}kb, peak: {$peakKb}kb{$peakSpent}, allocated: {$allocatedMemoryKb}kb{$limit}"));
            }

            if (array_key_exists('included_files', $dump)) {
                $this->logMessage(new Message('notice', 'Included files: ' . print_r(get_included_files(), true)));
            }

            if (array_key_exists('whitespace', $dump)) {
                $this->logMessage(new Message('notice', "END OF {$url}\n" . str_repeat('#', 120) . "\n\n"));
            }
        }
    }
public function dump ( ) : void { $ dump = $ this -> config [ 'dump' ] ?? [ ] ; if ( is_array ( $ dump ) && count ( $ dump ) > 0 ) { // 'speed', 'included_files', 'include_path', 'whitespace' $ dump = array_flip ( $ dump ) ; $ url = isset ( $ _SERVER [ 'REQUEST_METHOD' ] ) ? ( $ _SERVER [ 'REQUEST_METHOD' ] . '=' . Application :: getCurrentURL ( ) ) : ( 'CLI=' . Application :: getCliName ( ) ) ; if ( array_key_exists ( 'speed' , $ dump ) ) { $ executedIn = Application :: getRequestExecutionTime ( ) ; $ count = count ( get_included_files ( ) ) ; $ this -> logMessage ( new Message ( 'notice' , "{$url} EXECUTED IN {$executedIn}ms, used {$count} files" ) ) ; } if ( array_key_exists ( 'memory' , $ dump ) ) { $ memory = memory_get_usage ( ) ; $ peak = memory_get_peak_usage ( ) ; $ allocatedMemory = memory_get_peak_usage ( true ) ; $ memoryLimit = ini_get ( 'memory_limit' ) ?? - 1 ; $ memoryKb = round ( $ memory / 1024 , 2 ) ; $ peakKb = round ( $ peak / 1024 , 2 ) ; $ allocatedMemoryKb = round ( $ allocatedMemory / 1024 , 2 ) ; $ limit = '' ; $ peakSpent = '' ; if ( $ memoryLimit > 0 ) { $ limitInt = Convert :: stringToBytes ( $ memoryLimit ) ; $ limit = ", limit: {$memoryLimit}" ; $ spent = round ( $ peak / $ limitInt * 100 , 2 ) ; $ peakSpent = " ({$spent}% of limit)" ; } $ this -> logMessage ( new Message ( 'notice' , "{$url} CONSUMED MEM: current: {$memoryKb}kb, peak: {$peakKb}kb{$peakSpent}, allocated: {$allocatedMemoryKb}kb{$limit}" ) ) ; } if ( array_key_exists ( 'included_files' , $ dump ) ) { $ this -> logMessage ( new Message ( 'notice' , 'Included files: ' . print_r ( get_included_files ( ) , true ) ) ) ; } if ( array_key_exists ( 'whitespace' , $ dump ) ) { $ this -> logMessage ( new Message ( 'notice' , "END OF {$url}\n" . str_repeat ( '#' , 120 ) . "\n\n" ) ) ; } } }
Dump some common stuff into log according to config

@throws Convert\Exception
@throws \Koldy\Exception
Dump some common stuff into log according to config