public function run(Command $cmd) { $command = $this->bin . ' ' . (string) $cmd; $this->logger->debug('Command : `' . $command . '``'); $proc = popen((string) $command, 'r'); while (($line = fgets($proc)) !== false) { foreach ($this->handler as $handler) { $handler->handle($line, $this, $cmd); } } $this->logger->info('Done.'); /** @var HandlerInterface[] $handlers */ return array_merge($this->handler, $this->ignoredHandler); }
public static function doRequest($url, array $postData = null, $method = Request::METHOD_GET) { $client = self::getClientInstance(); $client->resetParameters(); $client->setEncType(Client::ENC_URLENCODED); $client->setUri($url); $client->setMethod($method); if ($postData === null) { $postData = array(); } $postData['access_token'] = self::getSession()->accessToken; if ($method == Request::METHOD_POST && $postData !== null) { $client->setParameterPost($postData); } if (($method == Request::METHOD_GET || $method == Request::METHOD_DELETE) && $postData !== null) { $client->setParameterGet($postData); } $response = $client->send(); if ($response->isSuccess()) { return JsonDecoder::decode($response->getBody(), Json::TYPE_ARRAY); } else { $logger = new Logger(); $logger->addWriter(new Stream('data/logs/apiclient.log')); $logger->debug($response->getBody()); return FALSE; } }
public function log() { $mailLog = null; /** @var \Zend\Mail\Transport\Smtp $mailTransport */ $mailTransport = $this->sxMail->getTransport(); if ($mailTransport instanceof \Zend\Mail\Transport\Smtp || is_callable([$mailTransport, 'getConnection'])) { $mailLog = $mailTransport->getConnection()->getLog(); } if ($mailLog) { $this->logger->debug($mailLog); } }
/** * Log data into the exception log file. * * @param $title * @param $error */ public function error($title, $error) { $this->connectorLogger->debug($title, $error); }
/** * Perform a request to the API * * @param string $url * @param array $postData * @param Client $client * @return Zend\Http\Response * @author Christopher */ protected static function doRequest($url, array $postData = null, $method = Request::METHOD_GET) { $client = self::getClientInstance(); $client->setUri($url); $client->setMethod($method); if ($postData !== null) { $client->setParameterPost($postData); } $response = $client->send(); if ($response->isSuccess()) { return JsonDecoder::decode($response->getBody(), Json::TYPE_ARRAY); } else { $logger = new Logger(); $logger->addWriter(new Stream('data/logs/apiclient.log')); $logger->debug($response->getBody()); return FALSE; } }
public function loggingQuery($adapter) { $logger = new Logger(); $writer = new Stream(LOG_DIR . "/query/" . date('Y-m-d')); $logger->addWriter($writer); $profiler = new Profiler(); $adapter->setProfiler($profiler); $profiler->profilerStart(new StatementContainer()); register_shutdown_function(function () use($logger, $profiler) { $profilers = $profiler->getProfiles(); if ($profilers) { foreach ($profilers as $profile) { $logger->debug($profile['sql']); } } }); }
/** * @group ZF-9870 */ public function testLogWritesWithModifiedTimestampFormat() { $logger = new Logger($this->writer); $logger->setTimestampFormat('Y-m-d'); $logger->debug('ZF-9870'); rewind($this->log); $message = stream_get_contents($this->log); $this->assertEquals(date('Y-m-d'), substr($message, 0, 10)); }
public function log($text) { $this->logger->debug($text); }
/** * Perform a request to the API * * @param string $url * @param array $postData * @param Client $client * @return Zend\Http\Response */ protected static function doRequestAuth($url, $decodeType = Json::TYPE_OBJECT, array $postData = null, $method = Request::METHOD_GET) { $client = self::getClientInstance(); $client->setUri($url); $client->setMethod($method); if ($postData !== null) { $client->setParameterPost($postData); } $client->setHeaders(array('Accept' => 'application/vnd.music.v1+json', 'Content-Type' => 'application/json', 'Accept-Encoding' => 'UTF-8', 'Authorization' => self::$token->token_type . ' ' . self::$token->access_token)); if ($postData !== null) { $client->setRawBody(Json::encode($postData, true)); $client->setEncType('application/json'); } $response = $client->send(); if ($response->isSuccess()) { return JsonDecoder::decode($response->getBody(), $decodeType); } else { // FIXME: Remove on production $logger = new Logger(); $logger->addWriter(new Stream('data/logs/apiclient.log')); $logger->debug($response->getBody()); return $response->getBody(); } }
/** * Log a debug message. * * @param string $msg Message to log. * * @return void */ protected function debug($msg) { if ($this->logger) { $this->logger->debug($msg); } }
/** * Print a message if debug is enabled. * * @param string $msg Message to print * * @return void */ protected function debugPrint($msg) { if ($this->debug && $this->logger) { $this->logger->debug("{$msg}\n"); } }