Пример #1
0
 /**
  * @param string|Settings $settings
  */
 public function __construct($settings = null)
 {
     parent::__construct($settings);
     if ($this->settings->logQueries) {
         $this->log(Log::getInstance($this->settings->logQueries));
     }
 }
Пример #2
0
 public function __construct($id, Closure $apply, Closure $rollback = null, $hasInternalState = false)
 {
     $this->id = $id;
     $this->applyCallable = $apply;
     $this->rollbackCallable = $rollback;
     $this->hasInternalState = $hasInternalState;
     $this->log = Log::nil();
 }
Пример #3
0
 public function run(Log $log = null)
 {
     /** @var \Yaoi\Database\Definition\Table[] $tables */
     $tables = array(Symbol::table(), Run::table(), RelatedStat::table(), SymbolStat::table(), Project::table(), Tag::table(), Aggregate::table(), ReportAggregate::table(), TagGroup::table());
     if (null === $log) {
         $log = Log::nil();
     }
     foreach ($tables as $table) {
         $table->migration()->setLog($log)->apply();
     }
 }
Пример #4
0
<?php

namespace PHPerf;

use Yaoi\Database;
use Yaoi\Http\Auth;
use Yaoi\Http\Auth\Settings;
use Yaoi\Log;
use Yaoi\Storage;
date_default_timezone_set('Europe/Moscow');
header("Content-Type: text/html; charset=utf8");
error_reporting(E_ALL);
ini_set('display_errors', 'on');
umask('0002');
Auth::register(function () {
    $dsn = new Settings();
    $dsn->title = 'Developers Only Area';
    $dsn->salt = '<random-string>';
    $dsn->users = array('<login>' => '<password-hash>');
    return $dsn;
}, 'dev');
Storage::register(new Storage\PhpVar(), 'debug_log');
Log::register('storage:///?storage=debug_log', 'debug_log');
Database::register(function () {
    $database = new Database('mysqli://root@localhost/phperf_result');
    $database->log(Log::getInstance('debug_log'));
    return $database;
});
Пример #5
0
 /**
  * @param $mock
  * @param $driver
  * @param $self
  * @return mixed
  * @throws Client\Exception
  * @throws \Exception
  */
 private function performFetch($mock, $driver, $self)
 {
     try {
         list($response, $this->responseHeaders) = $mock->branch('responseData')->get(null, function () use($driver, $self, $mock) {
             $driver->fetch();
             $response = $driver->getResponseContent();
             $responseHeaders = $driver->getResponseHeaders();
             if (!$self->skipBadRequestException && false === $response) {
                 $e = new Client\Exception('Bad request', Client\Exception::BAD_REQUEST);
                 $e->request = $driver->getRequest();
                 $e->responseHeaders = $self->responseHeaders;
                 $e->url = $self->url;
                 throw $e;
             }
             return array($response, $responseHeaders);
         });
         return $response;
     } catch (Client\Exception $e) {
         if ($this->logError) {
             $this->logError->push($e->getMessage() . ', request: ' . print_r($driver->getRequest(), 1) . ', serialize: ' . base64_encode(serialize($driver->getRequest())));
         }
         throw $e;
     }
     return $response;
 }
Пример #6
0
 public function setLog(Log $log = null)
 {
     if (null === $log) {
         $log = Log::void();
     }
     $this->log = $log;
     return $this;
 }
Пример #7
0
 /**
  * @param string $identifier
  * @return Log
  */
 static function log($identifier = Service::PRIMARY)
 {
     return Log::getInstance($identifier);
 }