Plugin Directory

Changeset 2019968


Ignore:
Timestamp:
01/27/2019 05:45:30 PM (7 years ago)
Author:
ChrisDennis
Message:

better debugging - no functional change

File:
1 edited

Legend:

Unmodified
Added
Removed
  • media-organiser/trunk/debug.php

    r1594304 r2019968  
    44// Debug to /wp-content/debug.log (see https://codex.wordpress.org/WP_DEBUG
    55// and settings in wp-config.php)
    6 # TODO this needs work...
    7 function debug (...$args) {
    8     if (!WP_DEBUG) {
    9         return;
     6if (!function_exists(NS . 'debug')) {       
     7
     8    function debug (...$args) {
     9        if (!WP_DEBUG) {
     10            return;
     11        }
     12        $text = '';
     13        foreach ($args as $arg) {
     14            $text .= ' ' . print_r($arg, true);
     15        }
     16        $trace = debug_backtrace(false);
     17        $file = $trace[0]['file'];
     18        $p = strrpos($file, '/wp-content/');
     19        if ($p !== False) {
     20            $file = substr($file, $p + 12);
     21        }
     22        $line = $trace[0]['line'];
     23        $func = $trace[1]['function'];
     24        if ($func == 'include'      or
     25            $func == 'include_once' or
     26            $func == 'require'      or
     27            $func == 'require_once'    ) {
     28            $func = '';
     29        } else {
     30            $func = '(' . $func . ')';
     31        }
     32        error_log($file . $func . ':' . $line . $text);
    1033    }
    11     list(, $caller) = debug_backtrace(false);
    12     #error_log('debug caller: ' . print_r($caller, true));
    13     $function = isset($caller['function']) ? $caller['function'] : '<unknown function>';
    14     $line = isset($caller['line']) ? ':'.$caller['line'] : '';
    15     $text = '';
    16     foreach ($args as $arg) {
    17         $text .= ' ' . print_r($arg, true);
    18     }
    19     error_log($function . $line . $text);
     34
    2035}
    2136
Note: See TracChangeset for help on using the changeset viewer.