コード例 #1
0
ファイル: BaseTestStatus.php プロジェクト: ucsdmath/logger
 /**
  * Test that the storage number can be set and retrieved.
  */
 public function testSetGetStorageAsInteger()
 {
     $randNumber = rand(9999, 99999);
     $logger = new Logger();
     $logger->set('testNumber', $randNumber);
     $this->assertSame($randNumber, $logger->get('testNumber'));
 }
コード例 #2
0
ファイル: init.php プロジェクト: patschwork/TTRSS-Auth-LDAP
 private function _log($msg, $level = E_USER_NOTICE, $file = '', $line = '', $context = '')
 {
     $loggerFunction = Logger::get();
     if (is_object($loggerFunction)) {
         $loggerFunction->log_error($level, $msg, $file, $line, $context);
     } else {
         trigger_error($msg, $level);
     }
 }
コード例 #3
0
ファイル: cache.php プロジェクト: wardvanderput/SumoStore
 public function remove()
 {
     if ($this->request->server['REQUEST_METHOD'] == 'POST') {
         Cache::removeAll(true);
         Language::rebuildCacheFor($this->config->get('language_id'));
         $files = $this->scan(DIR_IMAGE . 'cache/*', array());
         $check = array();
         if (is_array($files)) {
             foreach ($files as $file) {
                 @unlink($file);
             }
         }
         $this->response->setOutput(json_encode(Logger::get('warning')));
     }
 }
コード例 #4
0
ファイル: TagHandler.php プロジェクト: vanity/vanity
 /**
  * Get the full description.
  *
  * @return string The description.
  */
 public function getDescription()
 {
     $output = array($this->docblock->getShortDescription() . ' ');
     $parsed_contents = $this->docblock->getLongDescription()->getParsedContents();
     if (is_array($parsed_contents) && count($parsed_contents) > 0) {
         foreach ($parsed_contents as $content) {
             if (is_string($content)) {
                 $output[] = $content;
             } elseif ($content instanceof DBTag) {
                 $dtag = new InlineTag($content, $this->ancestry);
                 $output[] = $dtag->determine()->process(ConfigStore::get('source.resolve_aliases'));
             } else {
                 Logger::get()->{ConfigStore::get('log.error')}('Unknown inline tag object:', array(__FILE__, print_r($content, true)));
             }
         }
     }
     return $output;
 }
コード例 #5
0
ファイル: errorhandler.php プロジェクト: Verisor/tt-rss
function ttrss_fatal_handler()
{
    global $logger;
    $error = error_get_last();
    if ($error !== NULL) {
        $errno = $error["type"];
        $file = $error["file"];
        $line = $error["line"];
        $errstr = $error["message"];
        if (!$errno) {
            return false;
        }
        $context = debug_backtrace();
        $file = substr(str_replace(dirname(dirname(__FILE__)), "", $file), 1);
        if (class_exists("Logger")) {
            return Logger::get()->log_error($errno, $errstr, $file, $line, $context);
        }
    }
    return false;
}
コード例 #6
0
ファイル: rpc.php プロジェクト: adrianpietka/bfrss
 function log()
 {
     $logmsg = $this->dbh->escape_string($_REQUEST['logmsg']);
     if ($logmsg) {
         Logger::get()->log_error(E_USER_WARNING, $logmsg, '[client-js]', 0, false);
     }
     echo json_encode(array("message" => "HOST_ERROR_LOGGED"));
 }
コード例 #7
0
ファイル: logger.php プロジェクト: jaz303/base-php
<?php

require '../configure.php';
define('LOGGER_DEFAULT_THRESHOLD', 2);
$logger = Logger::get();
$logger->debug("Test debug - shouldn't see me");
$logger->info("Test info");
$logger->warn("Test warn");
$logger->error("Test error");
コード例 #8
0
ファイル: Http.php プロジェクト: eix/core
 /**
  * Performs the actual request.
  *
  * @param  string $method
  * @param  string $url
  * @param  array  $parameters
  * @return string
  */
 protected function request($method, $url, $parameters = array())
 {
     Logger::get()->debug('HTTP: starting request...');
     $headers = $this->headers;
     // Add accepted content type header.
     $headers[] = 'Content-Type: ' . $this->contentType;
     $headers[] = 'Accept: ' . $this->acceptedContentType;
     $handler = curl_init();
     if (!is_null($this->user)) {
         curl_setopt($handler, CURLOPT_USERPWD, $this->user . ':' . $this->password);
     }
     Logger::get()->debug('HTTP: method is ' . $method);
     switch ($method) {
         case self::METHOD_DELETE:
             curl_setopt($handler, CURLOPT_URL, $url . '?' . http_build_query($parameters));
             curl_setopt($handler, CURLOPT_CUSTOMREQUEST, self::DELETE);
             break;
         case self::METHOD_POST:
             curl_setopt($handler, CURLOPT_URL, $url);
             curl_setopt($handler, CURLOPT_POST, true);
             curl_setopt($handler, CURLOPT_POSTFIELDS, $parameters);
             break;
         case self::METHOD_GET:
             curl_setopt($handler, CURLOPT_URL, $url . '?' . http_build_query($parameters));
             break;
     }
     curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($handler, CURLOPT_HTTPHEADER, $headers);
     Logger::get()->debug('HTTP: headers set.');
     // Send the request to the server.
     Logger::get()->debug("HTTP: requesting {$url}...");
     $output = curl_exec($handler);
     $errNo = curl_errno($handler);
     $error = curl_error($handler);
     // Obtain the status.
     Logger::get()->debug('HTTP: Done. Getting status...');
     $status = curl_getinfo($handler, CURLINFO_HTTP_CODE);
     // The handler is no longer needed.
     curl_close($handler);
     Logger::get()->debug('HTTP: request finished.');
     if ($errNo) {
         throw new Exception('HTTP: cURL failed: ' . $error, $errNo);
     }
     // If cURL had no errors itself, then there is an HTTP response.
     switch ($status) {
         case self::STATUS_OK:
         case self::STATUS_CREATED:
         case self::STATUS_ACCEPTED:
         case self::STATUS_NO_CONTENT:
             return $output;
         default:
             throw new Http\Exception("HTTP {$status}", $status);
     }
 }