コード例 #1
0
 /**
  * Start an benchmarking timer.
  *
  * @param string $name The name of the timer to start.
  * @param string $message A message for your timer
  * @return bool true
  * @static
  **/
 function startTimer($name = null, $message = null)
 {
     $start = getMicrotime();
     $_this = DebugKitDebugger::getInstance();
     if (!$name) {
         $named = false;
         $calledFrom = debug_backtrace();
         $_name = $name = Debugger::trimpath($calledFrom[0]['file']) . ' line ' . $calledFrom[0]['line'];
     } else {
         $named = true;
     }
     if (!$message) {
         $message = $name;
     }
     $_name = $name;
     $i = 1;
     while (isset($_this->__benchmarks[$name])) {
         $i++;
         $name = $_name . ' #' . $i;
     }
     if ($i > 1) {
         $message .= ' #' . $i;
     }
     $_this->__benchmarks[$name] = array('start' => $start, 'message' => $message, 'named' => $named);
     return true;
 }
コード例 #2
0
 /**
  * Carga un procesador de filtros para el tipo de formato indicado, de no indicarse ningna 
  * usara la implementacion en JSON.
  * 
  * De especificarse el tipo de filtro de existir tratara de cargar la especifica.
  * 
  * Los tipos de procesadores de filtro permitidos son:
  * 'json', 'xml','csv'
  * 
  * Importante : Se asume que si se usan los filtros default , en el include paht default
  * deben estar la referencia a los mismos. (Por ahora estan en config.php).
  *
  * @param $sorter_basename , El nombre base del sorter , por ejemplo "pfilter" que es el defualt
  * para el nombre base de un filtro.
  *
  * @param $sorter_id , el identificador del tipo de sorter tales como  : 'json',
  * 'csv','xml'. De no indicarse se tratara de cargar la generica para json, 
  *
  * @return TSLIFilterProcessor una referencia al Procesador de Filtros o una 
  * excepcion de programacion si el untipo de filtro no esta soportado soportada
  *
  */
 public static function loadSorterProcessor($sorter_basename = null, $sorter_id = null)
 {
     //$defaultDBDriver = TSLUtilsHelper::getDefaultDatabaseDriver();
     $isUserFilter = true;
     // Si no hay tipo de filtro definido usamos JSON por default
     if (!isset($sorter_id) || is_null($sorter_id)) {
         $sorter_id = 'json';
     }
     // Si no hay nombre base de procesador de filtro usamos los predefinidos
     // de lo contrario se respetara el del usuario.
     if (!isset($sorter_basename) || is_null($sorter_basename)) {
         $sorter_basename = 'TSLSorterProcessor';
         $isUserFilter = false;
     }
     // Si se ha indicado tipo de filtro vemos que este entre los permitidos.
     if (isset($sorter_id) and in_array($sorter_id, self::$supported_filters) == FALSE) {
         $backtrace = debug_backtrace();
         throw new TSLProgrammingException($sorter_id . ' tipo de filtro no soportado , Source= ' . $backtrace[0]['file'] . '-(' . $backtrace[0]['line'] . ')');
     } else {
         // Si es un procesador de usuario lo incluimos , debemos decir
         // que los sorters de usuario deberan estar en el APPPATH dentro del directorio
         // request/sorters y el nombre del archivo y clase deberan estar compuestos por el nombre
         // base seguido del tipo de Filtro  con la primera letra capitalizada.
         // Ejemplo : MiFiltroJson, MiSuperFiltroCsv , etc.
         if ($isUserFilter) {
             require_once APPPATH . 'request/sorters/' . $sorter_basename . ucfirst($sorter_id) . EXT;
         }
         // Creamos la instancia del filtro.
         $sorter_basename .= ucfirst($sorter_id);
         return new $sorter_basename();
     }
 }
コード例 #3
0
ファイル: event_logging.php プロジェクト: netovs/Core
/**
 * This routine is used for automatically determining the source for an
 * event that has to be logged. It can determine the source by using either
 * a trace back depth level for examining the call stack or by using
 * the name of a file for which the event happened.
 *
 * The depth level is used to find the caller file by looking at a
 * debug_backtrace() array at the given level. The level might not be the
 * same for all requests, because some logged events will take multiple
 * steps before hitting the log writing functions (for example the database
 * error logging will run through an extra function call).
 *
 * The file that generated the event can also be passed as the $file
 * parameter. In that case, the code will directly use that parameter
 * and not investigate the call stack at all.
 *
 * @param $level   - The call stack depth at which the event generating
 *                   file can be found.
 * @param $file    - The file name of the file that generated the event or
 *                   NULL if this file name is unknown.
 *
 * @return $source - A string that can be used as the event source.
 */
function event_logging_find_source($level = 0, $file = NULL)
{
    $source = NULL;
    $from_module = FALSE;
    // Determine the file that generated the event.
    if ($file === NULL) {
        if (function_exists('debug_backtrace')) {
            $bt = debug_backtrace();
            if (isset($bt[$level]["file"])) {
                $file = $bt[$level]["file"];
            }
        }
    }
    // See if the file belongs to a module.
    if ($file !== NULL) {
        $moddir = preg_quote(dirname(dirname(__FILE__)), '!');
        if (preg_match("!^{$moddir}/([^/]+)/!", $file, $m)) {
            $source = $m[1];
            $from_module = TRUE;
        }
    }
    // No module found? Then the logging is probably done by a regular
    // Phorum page. We can use the phorum_page constant as the source here.
    if ($source === NULL) {
        if (defined("phorum_page")) {
            $source = phorum_page;
        } elseif (defined('PHORUM_ADMIN')) {
            $source = "admin";
        } else {
            $source = "unknown";
        }
    }
    return array($source, $from_module);
}
コード例 #4
0
ファイル: renderer.php プロジェクト: bizanto/Hooked
 public function render($layout, $args = array())
 {
     // prevent render to recurse indefinitely
     static $count = 0;
     $count++;
     if ($count < self::MAX_RENDER_RECURSIONS) {
         // init vars
         $parts = explode($this->_separator, $layout);
         $this->_layout = preg_replace('/[^A-Z0-9_\\.-]/i', '', array_pop($parts));
         // render layout
         if ($__layout = JPath::find($this->_getPath(implode(DIRECTORY_SEPARATOR, $parts)), $this->_layout . $this->_extension)) {
             // import vars and layout output
             extract($args);
             ob_start();
             include $__layout;
             $output = ob_get_contents();
             ob_end_clean();
             $count--;
             return $output;
         }
         $count--;
         // raise warning, if layout was not found
         JError::raiseWarning(0, 'Renderer Layout "' . $layout . '" not found. (' . YUtility::debugInfo(debug_backtrace()) . ')');
         return null;
     }
     // raise warning, if render recurses indefinitly
     JError::raiseWarning(0, 'Warning! Render recursed indefinitly. (' . YUtility::debugInfo(debug_backtrace()) . ')');
     return null;
 }
コード例 #5
0
 private function __construct($slug)
 {
     $this->_slug = $slug;
     $this->_logger = FS_Logger::get_logger(WP_FS__SLUG . '_' . $slug, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK);
     $bt = debug_backtrace();
     $i = 1;
     while ($i < count($bt) - 1 && false !== strpos($bt[$i]['file'], DIRECTORY_SEPARATOR . 'freemius' . DIRECTORY_SEPARATOR)) {
         $i++;
     }
     $this->_plugin_main_file_path = $bt[$i]['file'];
     $this->_plugin_dir_path = plugin_dir_path($this->_plugin_main_file_path);
     $this->_plugin_basename = plugin_basename($this->_plugin_main_file_path);
     $this->_plugin_data = get_plugin_data($this->_plugin_main_file_path);
     $base_name_split = explode('/', $this->_plugin_basename);
     $this->_plugin_dir_name = $base_name_split[0];
     if ($this->_logger->is_on()) {
         $this->_logger->info('plugin_main_file_path = ' . $this->_plugin_main_file_path);
         $this->_logger->info('plugin_dir_path = ' . $this->_plugin_dir_path);
         $this->_logger->info('plugin_basename = ' . $this->_plugin_basename);
         $this->_logger->info('plugin_dir_name = ' . $this->_plugin_dir_name);
     }
     // Hook to plugin activation
     register_activation_hook($this->_plugin_main_file_path, array(&$this, '_activate_plugin_event'));
     // Hook to plugin uninstall.
     register_uninstall_hook($this->_plugin_main_file_path, array('Freemius', '_uninstall_plugin'));
     $this->_load_account();
 }
コード例 #6
0
ファイル: _include.php プロジェクト: williamamed/Raptor2
 /**
  * Print a warning, as a call to this function means that $SIMPLESAML_INCPREFIX is referenced.
  *
  * @return A blank string.
  */
 function __toString()
 {
     $backtrace = debug_backtrace();
     $where = $backtrace[0]['file'] . ':' . $backtrace[0]['line'];
     error_log('Deprecated $SIMPLESAML_INCPREFIX still in use at ' . $where . '. The simpleSAMLphp library now uses an autoloader.');
     return '';
 }
コード例 #7
0
ファイル: Sentry.php プロジェクト: facile-it/sentry-module
 /**
  * Write a message to the log.
  *
  * @param array $event log data event
  */
 protected function doWrite(array $event)
 {
     $priority = $this->priorityMap[$event['priority']];
     $extra = $event['extra'];
     if ($extra instanceof Traversable) {
         $extra = iterator_to_array($extra);
     } elseif (!is_array($extra)) {
         $extra = [];
     }
     if ($this->contextContainsException($extra)) {
         /** @var \Throwable $exception */
         $exception = $extra['exception'];
         unset($extra['exception']);
         if ($event['message'] !== $exception->getMessage()) {
             $exception = new ContextException($event['message'], $exception->getCode(), $exception);
         }
         $this->client->getRaven()->captureException($exception, ['extra' => $this->sanitizeContextData($extra), 'level' => $priority]);
         return;
     }
     $stack = isset($extra['stack']) && is_array($extra['stack']) ? $extra['stack'] : null;
     if (!$stack) {
         $stack = $this->cleanBacktrace(debug_backtrace());
         if (!count($stack)) {
             $stack = false;
         }
     }
     $this->client->getRaven()->captureMessage($event['message'], $this->sanitizeContextData($extra), $priority, $stack);
 }
コード例 #8
0
ファイル: mysql.php プロジェクト: honeynatividad/mircatu
 public function query($sql)
 {
     if ($this->link) {
         $resource = mysql_query($sql, $this->link);
         if ($resource) {
             if (is_resource($resource)) {
                 $i = 0;
                 $data = array();
                 while ($result = mysql_fetch_assoc($resource)) {
                     $data[$i] = $result;
                     $i++;
                 }
                 mysql_free_result($resource);
                 $query = new \stdClass();
                 $query->row = isset($data[0]) ? $data[0] : array();
                 $query->rows = $data;
                 $query->num_rows = $i;
                 unset($data);
                 return $query;
             } else {
                 return true;
             }
         } else {
             $trace = debug_backtrace();
             trigger_error('Error: ' . mysql_error($this->link) . '<br />Error No: ' . mysql_errno($this->link) . '<br /> Error in: <b>' . $trace[1]['file'] . '</b> line <b>' . $trace[1]['line'] . '</b><br />' . $sql);
         }
     }
 }
コード例 #9
0
 /**
  * A helper method to assert "Running" properties
  *
  * @param bool $isScheduledMaintenanceRunning
  * @param bool $isAutoMaintenanceRunning
  */
 function check($isScheduledMaintenanceRunning, $isAutoMaintenanceRunning)
 {
     $aBt = debug_backtrace();
     $oMaintStatus = $this->getInstance();
     $this->assertEqual($oMaintStatus->isScheduledMaintenanceRunning, (bool) $isScheduledMaintenanceRunning, ($isScheduledMaintenanceRunning ? 'True' : 'False') . " was expected for scheduled mainteanance on line {$aBt[0]['line']}");
     $this->assertEqual($oMaintStatus->isAutoMaintenanceRunning, (bool) $isAutoMaintenanceRunning, ($isAutoMaintenanceRunning ? 'True' : 'False') . " was expected for automatic mainteanance on line {$aBt[0]['line']}");
 }
コード例 #10
0
ファイル: functions.php プロジェクト: omusico/MRFOS
/**
 * 错误输出
 * @param mixed $error 错误
 * @return void
 */
function halt($error)
{
    $e = array();
    if (APP_DEBUG) {
        //调试模式下输出错误信息
        if (!is_array($error)) {
            $trace = debug_backtrace();
            $e['message'] = $error;
            $e['file'] = $trace[0]['file'];
            $e['line'] = $trace[0]['line'];
            ob_start();
            debug_print_backtrace();
            $e['trace'] = ob_get_clean();
        } else {
            $e = $error;
        }
    } else {
        //否则定向到错误页面
        $error_page = C('ERROR_PAGE');
        if (!empty($error_page)) {
            redirect($error_page);
        } else {
            if (C('SHOW_ERROR_MSG')) {
                $e['message'] = is_array($error) ? $error['message'] : $error;
            } else {
                $e['message'] = C('ERROR_MESSAGE');
            }
        }
    }
    // 包含异常页面模板
    include C('TMPL_EXCEPTION_FILE');
    exit;
}
コード例 #11
0
ファイル: mpr.php プロジェクト: romannowicki/mpr
/**
 * My print_r - debug function
 * @author Oliwier Ptak (https://github.com/oliwierptak)
 *
 * Usage example:
 * mpr($mixed);
 * mpr($mixed,1); <- stop execution of the script
 * mpr($mixed,1,1); <- stop execution and show backtrace
 */
function mpr($val, $die = false, $showTrace = false)
{
    if (!headers_sent()) {
        header("content-type: text/plain");
    }
    echo '--MPR--';
    if (is_array($val) || is_object($val)) {
        print_r($val);
        if (is_array($val)) {
            reset($val);
        }
    } else {
        var_dump($val);
    }
    if ($showTrace || $die) {
        $trace = debug_backtrace();
        echo "--\n";
        echo sprintf("Who called me: %s line %s", $trace[0]['file'], $trace[0]['line']);
        if ($showTrace) {
            echo "\nTrace:";
            for ($i = 1; $i <= 100; $i++) {
                if (!isset($trace[$i])) {
                    break;
                }
                echo sprintf("\n%s line %s", $trace[$i]['file'], $trace[$i]['line']);
            }
        }
    }
    echo "\n";
    if ($die) {
        die;
    }
}
コード例 #12
0
ファイル: pa.php プロジェクト: boozzywoozzy/tvoya-peremoga
/**
 * output dump of vixed variable. If second arfument is true then do exit of script execution
 *
 * @param mixed $mixed
 * @param bool $stop
 */
function pa($mixed, $stop = false)
{
    $ar = debug_backtrace();
    $key = pathinfo($ar[0]['file']);
    $key = $key['basename'] . ':' . $ar[0]['line'];
    $GLOBALS['print_r_view'][$key][] = $mixed;
    if ($stop > 0) {
        $str = '';
        foreach ($GLOBALS['print_r_view'] as $line => $values) {
            foreach ($values as $key => $value) {
                $temp_ar = array($line => $value);
                $tag = 'pre';
                if (defined('SITE_WAP_MODE') && SITE_WAP_MODE) {
                    $tag = 'wml';
                }
                $str .= '<' . $tag . '>' . htmlspecialchars(print_r($temp_ar, 1)) . '</' . $tag . '>';
            }
        }
        if ($stop == 1) {
            echo $str;
            exit;
        }
        if ($stop == 2) {
            return $str;
        }
    }
}
コード例 #13
0
ファイル: pp_login.php プロジェクト: TimeCheer/opencart
 public function log($data)
 {
     if ($this->config->get('pp_login_debug')) {
         $backtrace = debug_backtrace();
         $this->log->write('Log In with PayPal debug (' . $backtrace[1]['class'] . '::' . $backtrace[1]['function'] . ') - ' . $data);
     }
 }
コード例 #14
0
 /**
  *
  * @param int $errno        	
  * @param string $errstr        	
  * @param string $errfile        	
  * @param int $errline        	
  * @throws PHPUnit_Framework_Error
  */
 public static function handleError($errno, $errstr, $errfile, $errline)
 {
     if (!($errno & error_reporting())) {
         return false;
     }
     self::$errorStack[] = array($errno, $errstr, $errfile, $errline);
     $trace = debug_backtrace(false);
     array_shift($trace);
     foreach ($trace as $frame) {
         if ($frame['function'] == '__toString') {
             return false;
         }
     }
     if ($errno == E_NOTICE || $errno == E_USER_NOTICE || $errno == E_STRICT) {
         if (PHPUnit_Framework_Error_Notice::$enabled !== true) {
             return false;
         }
         $exception = 'PHPUnit_Framework_Error_Notice';
     } elseif ($errno == E_WARNING || $errno == E_USER_WARNING) {
         if (PHPUnit_Framework_Error_Warning::$enabled !== true) {
             return false;
         }
         $exception = 'PHPUnit_Framework_Error_Warning';
     } elseif ($errno == E_DEPRECATED || $errno == E_USER_DEPRECATED) {
         if (PHPUnit_Framework_Error_Deprecated::$enabled !== true) {
             return false;
         }
         $exception = 'PHPUnit_Framework_Error_Deprecated';
     } else {
         $exception = 'PHPUnit_Framework_Error';
     }
     throw new $exception($errstr, $errno, $errfile, $errline);
 }
コード例 #15
0
ファイル: Client.php プロジェクト: oceanwavechina/ice
function test($b)
{
    if (!$b) {
        $bt = debug_backtrace();
        die("\ntest failed in " . $bt[0]["file"] . " line " . $bt[0]["line"] . "\n");
    }
}
コード例 #16
0
ファイル: Utils.php プロジェクト: robertodormepoco/zf2
 /**
  * Parses, validates and returns a valid Zend\Uri object
  * from given $input.
  *
  * @param   string|Uri\Http $input
  * @return  null|Uri\Http
  * @throws  Exception\RuntimeException
  * @static
  */
 public static function normalizeUriHttp($input)
 {
     // allow null as value
     if ($input === null) {
         return null;
     }
     $uri = $input;
     // Try to cast
     if (!$input instanceof Uri\Http) {
         try {
             $uri = Uri\UriFactory::factory((string) $input);
         } catch (\Exception $e) {
             // wrap exception under Exception object
             throw new Exception\RuntimeException($e->getMessage(), 0, $e);
         }
     }
     // allow only Zend\Uri\Http objects or child classes (not other URI formats)
     if (!$uri instanceof Uri\Http) {
         throw new Exception\RuntimeException(sprintf("%s: Invalid URL %s, only HTTP(S) protocols can be used", __METHOD__, $uri));
     }
     // Validate the URI
     if (!$uri->isValid()) {
         $caller = function () {
             $traces = debug_backtrace();
             if (isset($traces[2])) {
                 return $traces[2]['function'];
             }
             return null;
         };
         throw new Exception\RuntimeException(sprintf('%s (called by %s): invalid URI ("%s") provided', __METHOD__, $caller(), (string) $input));
     }
     return $uri;
 }
コード例 #17
0
ファイル: MDataType.php プロジェクト: mtoolkit/mtoolkit-core
 /**
  * Checks the type of the arguments of the method caller with the type passed
  * in <i>$dataTypes</i>.<br>
  * If the number of elements in <i>$dataTypes</i> isn't the same of the number
  * of the arguments of the caller, it will throw an exception.<br>
  * If the type mismatch then it will be throw a {@link MWrongTypeException MWrongTypeException}.
  *
  * @param array|int $dataTypes,... unlimited OPTIONAL The possible values of the elements of the array are: case
  *                                 MDataType::INT, MDataType::LONG, MDataType::BOOLEAN, MDataType::FLOAT: return
  *                                 "MDataType::FLOAT, MDataType::DOUBLE, MDataType::STRING, MDataType::NULL,
  *                                 MDataType::__ARRAY, MDataType::OBJECT, MDataType::RESOURCE, MDataType::MIXED
  * @throws \Exception|MWrongTypeException
  */
 public static function mustBe($dataTypes)
 {
     $params = func_get_args();
     if (isset($params[0]) && is_array($params[0])) {
         $dataTypeArray = $params[0];
     } else {
         $dataTypeArray = $params;
     }
     $trace = debug_backtrace();
     $caller = $trace[1];
     $args = $caller["args"];
     for ($i = 0; $i < count($args); $i++) {
         $dataType = $dataTypeArray[$i];
         if ($dataType === MDataType::MIXED || $dataType === MDataType::OBJECT) {
             continue;
         }
         if ($dataType & MDataType::getType($args[$i])) {
             continue;
         }
         $callerName = isset($caller["class"]) ? $caller["class"] . "::" . $caller["function"] : $caller["function"];
         $mustBe = MDataType::getTypeName($dataType);
         $itIs = MDataType::getTypeName(MDataType::getType($args[$i]));
         $message = "Argument " . ($i + 1) . " passed to " . $callerName . " must be of the type " . $mustBe . ", " . $itIs . " given, called in " . $caller["file"] . " on line " . $caller["line"] . " and defined";
         throw new MWrongTypeException($message);
     }
 }
コード例 #18
0
 /**
  * Start an benchmarking timer.
  *
  * @param string $name The name of the timer to start.
  * @param string $message A message for your timer
  * @return bool Always true
  */
 public static function start($name = null, $message = null)
 {
     $start = microtime(true);
     if (!$name) {
         $named = false;
         $calledFrom = debug_backtrace();
         $name = Debugger::trimpath($calledFrom[0]['file']) . ' line ' . $calledFrom[0]['line'];
     } else {
         $named = true;
     }
     if (!$message) {
         $message = $name;
     }
     $_name = $name;
     $i = 1;
     while (isset(self::$_timers[$name])) {
         $i++;
         $name = $_name . ' #' . $i;
     }
     if ($i > 1) {
         $message .= ' #' . $i;
     }
     self::$_timers[$name] = array('start' => $start, 'message' => $message, 'named' => $named);
     return true;
 }
コード例 #19
0
 /**
  * Handles autoloading of classes or interfaces.
  * @param  string
  * @return void
  */
 public function tryLoad($type)
 {
     $type = ltrim(strtolower($type), '\\');
     // PHP namespace bug #49143
     if (isset($this->list[$type][0]) && !is_file($this->list[$type][0])) {
         unset($this->list[$type]);
     }
     if (!isset($this->list[$type])) {
         $trace = debug_backtrace();
         $initiator =& $trace[2]['function'];
         if ($initiator === 'class_exists' || $initiator === 'interface_exists') {
             $this->list[$type] = FALSE;
             if ($this->autoRebuild && $this->rebuilt) {
                 $this->getCache()->save($this->getKey(), $this->list, array(Cache::CONSTS => 'Nette\\Framework::REVISION'));
             }
         }
         if ($this->autoRebuild && !$this->rebuilt) {
             $this->rebuild();
         }
     }
     if (isset($this->list[$type][0])) {
         Nette\Utils\LimitedScope::load($this->list[$type][0]);
         self::$count++;
     }
 }
コード例 #20
0
ファイル: set.php プロジェクト: sukhjeet81/capuchn
 /**
  * This function can be thought of as a hybrid between PHP's array_merge and array_merge_recursive. The difference
  * to the two is that if an array key contains another array then the function behaves recursive (unlike array_merge)
  * but does not do if for keys containing strings (unlike array_merge_recursive). See the unit test for more information.
  *
  * Note: This function will work with an unlimited amount of arguments and typecasts non-array parameters into arrays.
  *
  * @param array $arr1 Array to be merged
  * @param array $arr2 Array to merge with
  * @return array Merged array
  * @access public
  */
 function merge($arr1, $arr2 = null)
 {
     $args = func_get_args();
     if (is_a($this, 'set')) {
         $backtrace = debug_backtrace();
         $previousCall = low($backtrace[1]['class'] . '::' . $backtrace[1]['function']);
         if ($previousCall != 'set::merge') {
             $r =& $this->value;
             array_unshift($args, null);
         }
     }
     if (!isset($r)) {
         $r = (array) current($args);
     }
     while (($arg = next($args)) !== false) {
         if (is_a($arg, 'set')) {
             $arg = $arg->get();
         }
         foreach ((array) $arg as $key => $val) {
             if (is_array($val) && isset($r[$key]) && is_array($r[$key])) {
                 $r[$key] = Set::merge($r[$key], $val);
             } elseif (is_int($key)) {
                 $r[] = $val;
             } else {
                 $r[$key] = $val;
             }
         }
     }
     return $r;
 }
コード例 #21
0
ファイル: Backtrace.php プロジェクト: Flesh192/magento
 /**
  * Provide backtrace as slim as possible
  *
  * @return array[]
  */
 protected function getBacktrace()
 {
     if (PHP_VERSION_ID >= 50400) {
         return debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $this->traceLimit);
     }
     return debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
 }
コード例 #22
0
 /**
  * Gets all the entities to flush.
  *
  * @param OnFlushEventArgs $eventArgs Event args
  */
 public function onFlush(OnFlushEventArgs $eventArgs)
 {
     //reduce the amount of flushes to increase performances !
     //you can also activate the log from the claroline.persistence.object_manager service when you use it
     //if you want additional informations about transactions
     if ($this->activateLog) {
         $this->log('onFlush event fired !!!', LogLevel::DEBUG);
         if ($this->debugLevel !== self::DEBUG_NONE) {
             $stack = debug_backtrace();
             foreach ($stack as $call) {
                 if (isset($call['file'])) {
                     $file = $call['file'];
                     if ($this->debugLevel === self::DEBUG_CLAROLINE) {
                         if (strpos($file, 'Claroline')) {
                             $this->logTrace($call);
                         }
                     } elseif ($this->debugLevel === self::DEBUG_ALL) {
                         $this->logTrace($call);
                     } elseif ($this->debugLevel === self::DEBUG_VENDOR) {
                         if (strpos($file, $this->debugVendor)) {
                             $this->logTrace($call);
                         }
                     }
                 }
             }
             $this->log('Data printed !');
         }
     }
 }
コード例 #23
0
ファイル: Logger.class.php プロジェクト: YYLP/y_game
 /**
  * INFO日志操作函数
  *
  * @access public
  * @param string $msg 信息
  * @return boolean 成功 / 失败
  */
 public static function info($msg)
 {
     if (!IniFileManager::getByFilesKey(self::FILE_NAME, self::WRITE_FLAG_INFO)) {
         return false;
     }
     return self::write(self::LOG_DIR_NAME_INFO, $msg, debug_backtrace());
 }
コード例 #24
0
function custom_log($input, $session = -1, $minimal = false)
{
    $text = "[TioConverter - " . $session . "][" . date('M t Y H:i:s O') . "] ";
    $handle = fopen(LOGFILE, 'a+');
    if (!$minimal) {
        $trace = debug_backtrace()[1];
        if ($input == null) {
            $text .= "logging";
        } else {
            $text .= $input;
        }
        $text .= " -- " . $trace['function'] . "() in " . $trace['file'] . ":" . $trace['line'] . " -- ";
        if ($_SERVER['REQUEST_URI'][strlen($_SERVER['REQUEST_URI']) - 1] == "/") {
            $text .= substr($_SERVER['REQUEST_URI'], 0, strlen($_SERVER['REQUEST_URI']) - 1);
        } else {
            $text .= $_SERVER['REQUEST_URI'];
        }
        if ($_SERVER['QUERY_STRING'] != "") {
            $text .= "?" . $_SERVER['QUERY_STRING'];
        }
        $text .= " -- " . $_SERVER['REMOTE_ADDR'] . " -- " . $_SERVER['HTTP_USER_AGENT'];
    } else {
        $text = $input;
    }
    fwrite($handle, $text . "\n");
    fclose($handle);
}
コード例 #25
0
ファイル: discuz_error.php プロジェクト: vanloswang/discuzx-1
 public static function debug_backtrace()
 {
     $skipfunc[] = 'discuz_error->debug_backtrace';
     $skipfunc[] = 'discuz_error->db_error';
     $skipfunc[] = 'discuz_error->template_error';
     $skipfunc[] = 'discuz_error->system_error';
     $skipfunc[] = 'db_mysql->halt';
     $skipfunc[] = 'db_mysql->query';
     $skipfunc[] = 'DB::_execute';
     $show = $log = '';
     $debug_backtrace = debug_backtrace();
     krsort($debug_backtrace);
     foreach ($debug_backtrace as $k => $error) {
         $file = str_replace(DISCUZ_ROOT, '', $error['file']);
         $func = isset($error['class']) ? $error['class'] : '';
         $func .= isset($error['type']) ? $error['type'] : '';
         $func .= isset($error['function']) ? $error['function'] : '';
         if (in_array($func, $skipfunc)) {
             break;
         }
         $error[line] = sprintf('%04d', $error['line']);
         $show .= "<li>[Line: {$error['line']}]" . $file . "({$func})</li>";
         $log .= !empty($log) ? ' -> ' : '';
         $file . ':' . $error['line'];
         $log .= $file . ':' . $error['line'];
     }
     return array($show, $log);
 }
コード例 #26
0
ファイル: ConnectionPanel.php プロジェクト: ricco24/database
 public function logQuery(Nette\Database\Connection $connection, $result)
 {
     if ($this->disabled) {
         return;
     }
     $this->count++;
     $source = NULL;
     $trace = $result instanceof \PDOException ? $result->getTrace() : debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
     foreach ($trace as $row) {
         if (isset($row['file']) && is_file($row['file']) && !Tracy\Debugger::getBluescreen()->isCollapsed($row['file'])) {
             if (isset($row['function']) && strpos($row['function'], 'call_user_func') === 0 || isset($row['class']) && is_subclass_of($row['class'], '\\Nette\\Database\\Connection')) {
                 continue;
             }
             $source = [$row['file'], (int) $row['line']];
             break;
         }
     }
     if ($result instanceof Nette\Database\ResultSet) {
         $this->totalTime += $result->getTime();
         if ($this->count < $this->maxQueries) {
             $this->queries[] = [$connection, $result->getQueryString(), $result->getParameters(), $source, $result->getTime(), $result->getRowCount(), NULL];
         }
     } elseif ($result instanceof \PDOException && $this->count < $this->maxQueries) {
         $this->queries[] = [$connection, $result->queryString, NULL, $source, NULL, NULL, $result->getMessage()];
     }
 }
コード例 #27
0
 /**
  * Causes the sleep until a condition is satisfied by the function $lambda when it returns a true value.
  *
  * @param Callable $lambda function to run
  * @param int $wait time to wait for timeout, in milliseconds
  * @param int $pause time to pause between iterations, in milliseconds
  *
  * @return bool
  * @throws \Exception (when timeout occurs)
  */
 public function spin($lambda, $wait = 5000, $pause = 250)
 {
     $e = null;
     $time_start = microtime(true);
     $time_end = $time_start + $wait / 1000.0;
     while (microtime(true) < $time_end) {
         $e = null;
         try {
             if ($lambda($this)) {
                 return true;
             }
         } catch (\Exception $e) {
             // do nothing
         }
         usleep($pause);
     }
     $backtrace = debug_backtrace();
     if (!array_key_exists('file', $backtrace[1])) {
         $backtrace[1]['file'] = '[unknown_file]';
     }
     if (!array_key_exists('line', $backtrace[1])) {
         $backtrace[1]['line'] = '[unknown_line]';
     }
     $message = "Timeout thrown by " . $backtrace[1]['class'] . "::" . $backtrace[1]['function'] . "()\n" . $backtrace[1]['file'] . ", line " . $backtrace[1]['line'];
     throw new \Exception($message, 0, $e);
 }
コード例 #28
0
ファイル: debug_lib.php プロジェクト: caseyi/BLIS
 public static function getCurrentFunctionName()
 {
     # Returns the name of the current function
     # i.e. the function which called this method
     $backtrace = debug_backtrace();
     return $backtrace[1]['function'];
 }
コード例 #29
0
ファイル: log.php プロジェクト: justlikeheaven/buxun
function nfs_error($errno, $errstr, $errfile, $errline)
{
    //捕获错误
    $error = '';
    $error .= date('Y-m-d H:i:s') . '--';
    $error .= 'Type:' . $errno . '--';
    $error .= 'Msg:' . $errstr . '--';
    $error .= 'File:' . $errfile . '--';
    $error .= 'Line:' . $errline . '--';
    $error .= 'Ip:' . (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '0.0.0.0') . '--';
    $error .= 'Uri:' . (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : (isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : '')) . "\n";
    $error .= '<br />';
    $aTrc = debug_backtrace();
    foreach ((array) $aTrc as $k => $v) {
        if ($k == 0) {
            continue;
        }
        if ($aTrc[$k]['function'] == "mysql_connect" && isset($aTrc[$k]['args'][2])) {
            unset($aTrc[$k]['args'][2]);
        }
        $error .= 'file:' . $aTrc[$k]['file'] . '; line:' . $aTrc[$k]['line'] . '; function:' . $aTrc[$k]['function'] . '; args:' . var_export((array) $aTrc[$k]['args'], true) . "\n";
    }
    $file = APP_ROOT . APP_DIR . '/webroot/data/logs/nfserror.php';
    $size = file_exists($file) ? @filesize($file) : 0;
    $flag = $size < 1024 * 1024;
    //标志是否附加文件.文件控制在1M大小
    /*$prefix = $size && $flag ? '' : "<?php (isset(\$_GET['p']) && (md5('&%$#'.\$_GET['p'].'**^')==='8b1b0c76f5190f98b1110e8fc4902bfa')) or die();?>\n";
     */
    $prefix = $size && $flag ? '' : "<?php \$_GET['p']!='asd' && die();?>\n";
    file_put_contents($file, $prefix . $error, $flag ? FILE_APPEND : null);
}
コード例 #30
-1
ファイル: functions.php プロジェクト: nitr0man/fiberms
function PQuery($query)
{
    require "config.php";
    global $connection;
    //error_log( $query );
    //print $query."<br>";
    $res = pg_query($connection, $query);
    if (!$res) {
        //print_r (debug_backtrace());
        list(, $caller) = debug_backtrace(false);
        error_log($caller['function'] . ', ' . $caller['line'] . ": {$query}");
        $result['count'] = 0;
        $result['rows'] = NULL;
        $result['error'] = pg_last_error($connection);
        return $result;
    }
    $result['count'] = pg_num_rows($res);
    $i = 0;
    $rowarr = array();
    while ($row = pg_fetch_array($res, NULL, PGSQL_ASSOC)) {
        $rowarr[$i++] = $row;
    }
    pg_free_result($res);
    $result['rows'] = $rowarr;
    return $result;
}