/** * @param $databaseConfig * @param $masterParams * @return array */ private function mapSlavesConfig(Zend_Config $databaseConfig, $masterParams) { $slaves = $databaseConfig->get('slaves'); if (!$slaves || !$slaves instanceof Zend_Config || $slaves->count() === 0) { $slaves = array(); } $slavesParams = array(); foreach ($slaves as $slaveId) { $slaveConfig = $databaseConfig->get($slaveId); if (!$slaveConfig || !$slaveConfig instanceof Zend_Config) { $this->logger->warning(sprintf("Listed slave '%s' has no configuration. Skipping candidate slave.", $slaveId)); continue; } $slaveParams = $this->getParamsFromConfig($slaveConfig); if ($slaveParams['driver'] !== $masterParams['driver']) { $this->logger->warning(sprintf("Listed slave '%s' has different driver ('%s') than master ('%s'). This is not supported. " . 'Skipping candidate slave.', $slaveId, $slaveParams['driver'], $masterParams['driver'])); continue; } $slavesParams[] = $slaveParams; } if (empty($slavesParams)) { $this->logger->warning('No (properly) configured slaves, using master as slave.'); $slavesParams[] = $masterParams; } return $slavesParams; }
/** * @param $filename * @return mixed|void */ public function optimiseImage($filename) { if (file_exists($filename)) { $size = @getimagesize($filename); if (!is_array($size)) { if (null !== $this->logger) { $this->logger->error("Error reading file when attempting to optimize"); } return; } list($width, $height, $type, $attr) = $size; $commands = $this->getCommands($filename, $type = $this->getImageType($type)); foreach ($commands as $command) { try { $process = $this->execCommand($command); $successful = in_array($process->getExitCode(), $this->config->get('successStatuses')); if (null !== $this->logger && (!$successful || $this->config->get('debug'))) { // Do this so the log isn't treated as a web request in raven $requestMethod = $_SERVER['REQUEST_METHOD']; unset($_SERVER['REQUEST_METHOD']); $logType = $successful ? 'info' : 'error'; $this->logger->{$logType}("SilverStripe \"{$type}\" optimisation {$logType}", array('command' => $command, 'exitCode' => $process->getExitCode(), 'output' => $process->getOutput(), 'errorOutput' => $process->getErrorOutput())); $_SERVER['REQUEST_METHOD'] = $requestMethod; } } catch (\Exception $e) { if (null !== $this->logger) { $this->logger->error("SilverStripe \"{$type}\" optimisation exception", array('exception' => $e)); } } } } }
public function setUp() { $this->logger = new Logger('phpunit-logger'); $directoryLogOutput = self::$directoryV->url() . '/log'; if (!file_exists($directoryLogOutput)) { mkdir($directoryLogOutput, 0700, true); } $output = "%level_name% > %message% %context% %extra%\n"; $formatter = new LineFormatter($output); $handler = new StreamHandler($directoryLogOutput . '/phpunit.log', Logger::DEBUG, true, null, false); touch($directoryLogOutput . '/phpunit.log'); $handler->setFormatter($formatter); $this->logger->pushHandler($handler); $this->logger->info('Avviato test -> ' . $this->getName()); }
public function injectOverrides() { $fixture = new \OpenConext\Component\EngineBlockFixtures\SuperGlobalsFixture(new \OpenConext\Component\EngineBlockFixtures\DataStore\JsonDataStore(self::FILE)); $overrides = $fixture->getAll(); foreach ($overrides as $superGlobalName => $values) { $superGlobalName = '_' . $superGlobalName; global ${$superGlobalName}; $global =& ${$superGlobalName}; foreach ($values as $name => $value) { $this->_logger->notice(sprintf('Overwriting $%s[%s]', $superGlobalName, $name), array('super_global' => array('from' => $global[$name], 'to' => $value))); $global[$name] = $value; } } return true; }
/** * Logs an exception with the Logger class, if it exists. * * @param string $message * @param \Exception $exception * @return bool */ protected function logException($message, $exception) { if (!isset($this->logger)) { return false; } $this->logger->critical($message, array('exception' => $exception)); return true; }
/** * @param string $id * @param string $type * @param string $ietfLanguageTag * @return string */ private function getTypeForLang($id, $type, $ietfLanguageTag = 'en') { if (isset($this->definitions[$id][$type][$ietfLanguageTag])) { return $this->definitions[$id][$type][$ietfLanguageTag]; } $this->logger->notice("Attribute lookup failure '{$id}' has no '{$type}' for language '{$ietfLanguageTag}'"); return ''; }
/** * @param string $message * @param mixed $pattern * @param mixed $replacement */ protected function log(&$message, $pattern = array('/email=(.*[^&])&password=(.*[^&])&/'), $replacement = array('email=xxxxxx&password=yyyyyy&')) { if (null !== $this->logger) { if (null !== $pattern && null !== $replacement) { $message = preg_replace($pattern, $replacement, $message); } $this->logger->debug($message); } }
public function testNonScalarReplaceValuesAreNotInterpolated() { $variables = [new Esendex_Sms_Model_Variable('totalsales', 'total_sales'), new Esendex_Sms_Model_Variable('numorders', 'number_of_orders')]; $container = new Varien_Object(); $container->setData(['total_sales' => new stdClass(), 'number_of_orders' => 100]); $msg = 'Cannot replace placeholder with a non-scalar value (Eg, String, Integer). Got: "stdClass"'; $this->logger->expects($this->once())->method('error')->with($msg); $message = 'Your store has made $TOTALSALES$ through $NUMORDERS$ orders'; $result = $this->interpolator->interpolate($message, $container, $variables); $expected = 'Your store has made through 100 orders'; $this->assertSame($expected, $result); }
public function denormalize() { $this->_loadLogger(); $this->_loadAttributeDefinitions(); $newAttributes = array(); foreach ($this->_attributes as $attributeName => $attributeValues) { $newAttributes[$attributeName] = $attributeValues; // Not defined in SURFconext attributes... can't find any aliases. if (!isset($this->_definitions[$attributeName])) { $this->_logger->debug("Attribute Denormalization: Don't have a definition for '{$attributeName}', unable to add any aliases"); continue; } $aliases = $this->_getAliasesForAttribute($attributeName); // And add the values for those aliases foreach ($aliases as $aliasName) { $this->_logger->debug("Attribute Denormalization: Adding alias '{$aliasName}' for '{$attributeName}'"); $newAttributes[$aliasName] = $attributeValues; } } return $newAttributes; }
/** * Association d'un Intent et d'un paiement, avec envoie des evenements * @since 1.0.0 * @param mixed $intentId integer si intentId est false alors nous avons un payment orphelin. * @param Ecedi\Donate\CoreBundle\Entity\Payment $payment une instance de payment * @todo flush is not right here, it should be in the controller * */ public function attachPayment($intentId, Payment $payment) { $intentRepository = $this->getDoctrine()->getRepository('DonateCoreBundle:Intent'); $em = $this->getDoctrine()->getManager(); if ($intentId && ($intent = $intentRepository->find($intentId))) { $intent->addPayment($payment); $this->logger->debug('addPayment to intent'); if ($intent->getType() == Intent::TYPE_SPOT && $intent->getStatus() == Intent::STATUS_PENDING) { //Propagation de l'état du paiement vers l'intent $intent->setStatus(Intent::STATUS_DONE); $this->logger->debug('set intent status to DONE'); } else { //on reçoit plusieurs post-sale pour le même spot order... $this->logger->notice('another post sale for this intent'); } $em->persist($intent); } $this->dispatchPaymentStatusEvent($payment); $em->persist($payment); $em->flush(); }
/** * Create a neaw stream handler * * @param string $path * @param int $level * @param Boolean $bubble * * @return \Monolog\Handler\StreamHandler */ public function addStream($path, $level, $bubble = true) { $this->logger->pushHandler($handler = new StreamHandler($path, $this->parseLevel($level), $bubble)); $handler->setFormatter($this->getDefaultFormatter()); return $this; }
/** * Log addshoppers exceptions/error/info * @param [type] $message * @return [type] * @author edudeleon * @date 2015-08-11 */ private function _logAddshoppersMsg($message) { $this->_logger->addInfo("[AddShoppers] :: " . $message); }