Exemplo n.º 1
0
/**
 * libphutil log function for development debugging. Takes any argument and
 * forwards it to registered listeners. This is essentially a more powerful
 * version of ##error_log()##.
 *
 * @param wild Any value you want printed to the error log or other registered
 *             logs/consoles.
 * @param ...  Other values to be logged.
 * @return wild Passed $value.
 */
function phlog($value)
{
    // Get the caller information
    $trace = debug_backtrace();
    $metadata = array('file' => $trace[0]['file'], 'line' => $trace[0]['line'], 'trace' => $trace);
    foreach (func_get_args() as $event) {
        PhutilErrorHandler::dispatchErrorMessage($event instanceof Exception ? PhutilErrorHandler::EXCEPTION : PhutilErrorHandler::PHLOG, $event, $metadata);
    }
    return $value;
}
Exemplo n.º 2
0
/**
 * libphutil log function for development debugging. Takes any argument and
 * forwards it to registered listeners. This is essentially a more powerful
 * version of ##error_log()##.
 *
 * NOTE: You must call ##PhutilErrorHandler::initialize()## before this will do
 * anything.
 *
 * @param wild Any value you want printed to the error log or other registered
 *             logs/consoles.
 * @return wild Passed $value.
 * @group error
 */
function phlog($value)
{
    if (!PhutilErrorHandler::hasInitialized()) {
        throw new Exception("Call to phlog() before PhutilErrorHandler::initialize()!");
    }
    // Get the caller information
    $trace = debug_backtrace();
    $file = $trace[0]['file'];
    $line = $trace[0]['line'];
    PhutilErrorHandler::dispatchErrorMessage($value instanceof Exception ? PhutilErrorHandler::EXCEPTION : PhutilErrorHandler::PHLOG, $value, array('file' => $file, 'line' => $line, 'trace' => $trace));
    return $value;
}
Exemplo n.º 3
0
/**
 * libphutil log function for development debugging. Takes any argument and
 * forwards it to registered listeners. This is essentially a more powerful
 * version of `error_log()`.
 *
 * @param  wild  Any value you want printed to the error log or other registered
 *               logs/consoles.
 * @param  ...   Other values to be logged.
 * @return wild  Passed $value.
 */
function phlog($value)
{
    // Get the caller information.
    $trace = debug_backtrace();
    $metadata = array('file' => $trace[0]['file'], 'line' => $trace[0]['line'], 'trace' => $trace);
    foreach (func_get_args() as $event) {
        $data = $metadata;
        if ($event instanceof Exception) {
            $type = PhutilErrorHandler::EXCEPTION;
            // If this is an exception, proxy it and generate a composite trace which
            // shows both where the phlog() was called and where the exception was
            // originally thrown from.
            $proxy = new PhutilProxyException('', $event);
            $trace = PhutilErrorHandler::getExceptionTrace($proxy);
            $data['trace'] = $trace;
        } else {
            $type = PhutilErrorHandler::PHLOG;
        }
        PhutilErrorHandler::dispatchErrorMessage($type, $event, $data);
    }
    return $value;
}
Exemplo n.º 4
0
/**
 * Warns about use of deprecated behavior.
 */
function phutil_deprecated($what, $why)
{
    PhutilErrorHandler::dispatchErrorMessage(PhutilErrorHandler::DEPRECATED, $what, array('why' => $why));
}