本文整理汇总了PHP中Monolog\Logger::error方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::error方法的具体用法?PHP Logger::error怎么用?PHP Logger::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monolog\Logger
的用法示例。
在下文中一共展示了Logger::error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* {@inheritdoc}
*/
public function execute(AMQPMessage $msg)
{
$msgBody = json_decode($msg->body, true);
// Log as error to also print it in console when running consumer
$this->logger->error('RabbitMQ message_logger :: ' . $msgBody['messageData']);
return true;
}
示例2: init
protected function init($jobId)
{
$this->jobMapper = $this->getContainer()->get('syrup.elasticsearch.current_component_job_mapper');
// Get job from ES
$this->job = $this->jobMapper->get($jobId);
if ($this->job == null) {
$this->logger->error("Job id '" . $jobId . "' not found.");
return self::STATUS_ERROR;
}
// SAPI init
/** @var ObjectEncryptor $encryptor */
$encryptor = $this->getContainer()->get('syrup.object_encryptor');
$this->sapiClient = new SapiClient(['token' => $encryptor->decrypt($this->job->getToken()['token']), 'url' => $this->getContainer()->getParameter('storage_api.url'), 'userAgent' => $this->job->getComponent()]);
$this->sapiClient->setRunId($this->job->getRunId());
/** @var \Keboola\Syrup\Service\StorageApi\StorageApiService $storageApiService */
$storageApiService = $this->getContainer()->get('syrup.storage_api');
$storageApiService->setClient($this->sapiClient);
$this->storageApiService = $storageApiService;
/** @var \Keboola\Syrup\Monolog\Processor\JobProcessor $logProcessor */
$logProcessor = $this->getContainer()->get('syrup.monolog.job_processor');
$logProcessor->setJob($this->job);
/** @var \Keboola\Syrup\Monolog\Processor\SyslogProcessor $logProcessor */
$logProcessor = $this->getContainer()->get('syrup.monolog.syslog_processor');
$logProcessor->setRunId($this->job->getRunId());
$logProcessor->setTokenData($storageApiService->getTokenData());
// Lock DB
/** @var Connection $conn */
$conn = $this->getContainer()->get('doctrine.dbal.lock_connection');
$conn->exec('SET wait_timeout = 31536000;');
$this->lock = new Lock($conn, $this->job->getLockName());
}
示例3: onDispatchError
/**
* @param MvcEvent $e
*/
public function onDispatchError(MvcEvent $e)
{
$exception = $e->getParam('exception');
if (!$exception instanceof \Exception) {
return;
}
$this->logger->error($exception->getTraceAsString());
}
示例4: doTask
public function doTask($console = false)
{
if ($console) {
$this->info('Processing withdrawals');
}
$txn_log = new Logger('TXN');
$txn_log->pushHandler(new StreamHandler(storage_path() . '/logs/withdrawals_cron.log', Logger::INFO));
$bar = null;
if ($console) {
$total_transactions = WalletsWithdrawal::whereNull('wallets_transaction_id')->where(function (Builder $query) {
$query->where('need_approve', 0)->orWhere('approved', 1);
})->count();
$bar = $this->output->createProgressBar($total_transactions);
}
WalletsWithdrawal::whereNull('wallets_transaction_id')->where(function (Builder $query) {
$query->where('need_approve', 0)->orWhere('approved', 1);
})->chunk(1000, function ($withdrawals) use($bar, $console, $txn_log) {
foreach ($withdrawals as $withdrawal) {
$balance = $withdrawal->wallet->command('getbalance');
if (empty($balance->error)) {
if ($balance * 0.2 >= $withdrawal->amount || $withdrawal->approved == 1) {
$amount = $withdrawal->amount - $withdrawal->wallet->transaction_fee;
$txn = $withdrawal->wallet->command('sendtoaddress', [$withdrawal->address, $amount]);
if (empty($txn->error)) {
$wallet_transaction = new WalletsTransaction();
$wallet_transaction->txid = $txn;
$wallet_transaction->user_id = $withdrawal->user_id;
$wallet_transaction->wallet_id = $withdrawal->wallet_id;
$wallet_transaction->amount = -$withdrawal->amount;
$wallet_transaction->confirmed = false;
$wallet_transaction->save();
$withdrawal->wallets_transaction_id = $wallet_transaction->id;
$withdrawal->save();
$txn_log->error('Txn success (wal#' . $withdrawal->wallet->short . ')', (array) $txn);
} else {
$txn_log->error('Txn error (wal#' . $withdrawal->wallet->short . ')', (array) $txn);
}
} else {
$withdrawal->need_approve = true;
$withdrawal->save();
$txn_log->error('Too big txn need approve (wal#' . $withdrawal->wallet->short . ') amount:' . $withdrawal->amount, (array) $balance);
Cache::flush('need_approve_count');
}
} else {
$txn_log->error('Getting balance(wal#' . $withdrawal->wallet->short . ') error', (array) $balance);
}
if ($console) {
$bar->advance();
}
}
});
if ($console) {
$bar->finish();
echo PHP_EOL;
$this->info('done');
}
}
示例5: onError
public function onError(ErrorEvent $event)
{
if ($event->getResponse()) {
$this->log->error('guzzle_error: ' . $event->getException()->getMessage());
} else {
$ex = $event->getException();
$this->log->error($ex->getMessage() . ' -- ' . $ex->getTraceAsString(), [$ex->getCode(), $ex->getLine(), $ex->getFile()]);
}
$event->stopPropagation();
}
示例6: execute
public function execute()
{
try {
$this->install->install();
} catch (\Exception $e) {
$this->logger->error($e->getTraceAsString());
echo $e->getMessage();
}
$this->response->redirect('/');
}
示例7: __construct
public function __construct($orchestrate_api_key, Logger $logger)
{
try {
$this->orchestrate = new Client($orchestrate_api_key);
$this->logger = $logger;
} catch (Exception $e) {
$logger->error($e->getMessage());
} catch (ClientException $e) {
$logger->error($e->getMessage());
}
}
示例8: buildForPreprocessor
public function buildForPreprocessor(Request $request, Route $preprocessorRoute)
{
// Localhost case
if ($preprocessorRoute->getDefault('_http_host') === $request->getHttpHost()) {
$this->logger->info("InternalForwarder built for preprocessor: Localhost forwarder.", ['host' => $request->getHttpHost()]);
return $this->container->get('prestashop.public_writer.protocol.internal_forwarder.localhost');
}
// Error case: localhost case was not matching, but there is no other forwarder available.
$this->logger->error("InternalForwarder built for preprocessor: NO forwarder found to reach distant host.", ['host' => $request->getHttpHost()]);
throw new \ErrorException("InternalForwarder building for preprocessor: NO forwarder found to reach distant host: " . $request->getHttpHost());
}
示例9: safeBatchInsert
public function safeBatchInsert($db, $collection, array $data, array $options = [])
{
try {
return $this->mongo->{$db}->{$collection}->batchInsert($data, $options);
} catch (\MongoException $e) {
if ($this->monolog) {
$this->monolog->error('Mongo error', ['class' => __CLASS__, 'message' => $e->getMessage()]);
}
return false;
}
}
示例10: handle
/**
* @param \Exception $e
* @param $code
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
public function handle(\Exception $e, $code)
{
switch ($code) {
case 404:
$data = array('success' => false, 'code' => '404', 'message' => 'The requested page could not be found.');
break;
default:
$data = array('success' => false, 'code' => $code, 'message' => $e->getMessage());
}
$this->logger->error(sprintf('%s: %s', get_class($e), $e->getMessage()));
return new JsonResponse($data, $code);
}
示例11: request
/**
* @param $method
* @param $endPoint
* @param array $formParams
*
* @throws \Exception
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function request($method, $endPoint, array $formParams = [])
{
$options = ['headers' => ['Accept' => 'application/json'], 'form_params' => $formParams];
$requestUrl = $this->formatRequestUrl($endPoint);
$this->logger->info('Remote request: ', ['method' => $method, 'url' => $requestUrl, 'options' => $options]);
try {
$response = $this->httpClient->{$method}($requestUrl, $options);
} catch (\Exception $e) {
$this->logger->error('Api request error.', ['exception' => $e->getMessage()]);
throw $e;
}
$this->logger->info('Remote response: ', ['statusCode' => $response->getStatusCode(), 'headers' => $response->getHeaders(), 'body' => $response->getBody()]);
return $response;
}
示例12: sendRequest
/**
* Sending request to Celium Node for run action
* @param string $request
* @throws \Exception
* @return string Key of request. That's need for find results.
*/
public function sendRequest($request)
{
$requestKey = md5($request);
$request = json_decode($request, true);
$request['key'] = $requestKey;
$request = json_encode($request);
$b = $this->rabbit->write($request, $this->name . '_request');
if (!$b) {
$this->logger->error('Request to the node failed', ['nodeName' => $this->name, 'requestBody' => $request, 'requestKey' => $requestKey, 'tags' => ['client-request-failed']]);
throw new \Exception("Failed to add the request to the queue");
}
$this->logger->info('Request was sent to the node', ['nodeName' => $this->name, 'requestBody' => $request, 'requestKey' => $requestKey, 'tags' => ['client-request']]);
return $requestKey;
}
示例13: clearPast
/**
* Clears Up the images folder
* Old files are unlinked
*/
public function clearPast()
{
// # DirecotryIterator on image folder
$chartsIterator = new \DirectoryIterator($this->PM->getProperty("basePath") . "/imagedata/");
$isDirEmpty = !$chartsIterator->valid();
// # Check if it is already empty
if (!$isDirEmpty) {
$this->log->error("Unlinking old files i've found");
// # Unlink 'em all
foreach ($chartsIterator as $file) {
if ($file->isFile()) {
@unlink($this->PM->getProperty("basePath") . "/imagedata/" . $file->getFilename());
}
}
}
}
示例14: notify
public function notify(Service\Record $record, DOMDocument $config, Logger $logger)
{
$permissions = $config->getElementsByTagName('permissions')->item(0);
if ($permissions !== null) {
$logger->info('Create user permissions');
try {
$namespace = str_replace('\\', '_', strtolower($record->namespace));
$pos = strpos($namespace, '_');
$namespace = substr($namespace, $pos !== false ? $pos + 1 : 0);
// remove vendor part
$perms = $permissions->childNodes;
for ($i = 0; $i < $perms->length; $i++) {
$perm = $perms->item($i);
if (!$perm instanceof DOMElement) {
continue;
}
if ($perm->nodeName == 'perm') {
$name = $perm->getAttribute('name');
$desc = $perm->getAttribute('description');
if (!empty($name) && !empty($desc)) {
$name = $namespace . '_' . $name;
$this->sql->insert($this->registry['table.user_right'], array('serviceId' => $record->id, 'name' => $name, 'description' => $desc));
$logger->info('> Created permission "' . $name . '"');
}
}
}
} catch (\Exception $e) {
$logger->error($e->getMessage());
}
}
}
示例15: callAsync
protected function callAsync($function, array $data, $log = false)
{
if (strtolower($function) == 'login') {
$this->wrapperLog->error('Login can not be called asynchronously!');
throw new APIException('Login can not be called asynchronously!');
}
if (!empty($this->hash)) {
$data['hash'] = $this->hash;
}
$socket = fsockopen(parse_url($this->apiAddress, PHP_URL_HOST), 80, $errno, $errstr);
if ($socket === false) {
$this->wrapperLog->critical('Error while opening asynchronous socket: ' . $errstr, array('code' => $errno));
throw new ConnectionException('Error while opening asynchronous socket: ' . $errstr, $errno);
}
$data = 'data=' . urlencode(json_encode($data));
$msg = 'POST /' . $this->qbankAddress . '/' . $function . ' HTTP/1.1' . "\r\n";
$msg .= 'Host:' . parse_url($this->apiAddress, PHP_URL_HOST) . "\r\n";
$msg .= 'Content-type: application/x-www-form-urlencoded' . "\r\n";
$msg .= 'Content-length: ' . strlen($data) . "\r\n";
$msg .= 'Connection: Close' . "\r\n\r\n";
$msg .= $data;
$result = fwrite($socket, $msg);
if ($result === false) {
$this->wrapperLog->critical('Error while writing to asycnhronous socket!');
throw new ConnectionException('Error while writing to asycnhronous socket!');
}
@fclose($socket);
}