本文整理汇总了PHP中Monolog\Logger::warning方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::warning方法的具体用法?PHP Logger::warning怎么用?PHP Logger::warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monolog\Logger
的用法示例。
在下文中一共展示了Logger::warning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public function update(Worker $worker)
{
/** @var EntityManager $em */
$em = $this->doctrine->getManager();
$exception = null;
$i = 0;
while ($i < 5) {
try {
$worker = $this->getWorker(['queue' => $worker->getQueue(), 'instance' => $worker->getInstance(), 'host' => $worker->getHost()]);
$em->persist($worker);
$em->flush();
return;
} catch (\Exception $e) {
// the connection might have "gone away"
$this->logger->warning("Error while updating worker entity", ['message' => $e->getMessage()]);
$exception = $e;
$this->doctrine->resetManager();
$em = $this->doctrine->getManager();
$em->getConnection()->close();
$em->getConnection()->connect();
}
$i++;
}
throw new ApplicationException("Unable to update worker entity", $exception);
}
示例2: validateHeader
private function validateHeader($data, $name)
{
if (!$data[0] instanceof \stdClass || !is_array($data[1])) {
$mes = "Incorrect input param type for {$name}";
if (isset($this->logger)) {
$this->logger->warning('ACCESS', ['Cause' => $mes]);
}
throw new \Exception($mes);
}
}
示例3: testLogsFileAndLineWhenUsingIntrospectionProcessor
public function testLogsFileAndLineWhenUsingIntrospectionProcessor()
{
$this->logger->pushProcessor(new IntrospectionProcessor());
$this->logger->warning('a warning');
$line = __LINE__;
$log = $this->pdo->query('SELECT * FROM logs')->fetch();
$this->assertTrue(isset($log['file']));
$this->assertTrue(isset($log['line']));
$this->assertEquals($log['message'], 'a warning');
$this->assertEquals($log['file'], __FILE__);
$this->assertEquals($log['line'], $line);
}
示例4: getData
/**
* Fetches the data for the given IP address
*
* @return $this
*/
public function getData()
{
$url = $this->getUrl();
try {
$response = $this->connector->{$this->method}($url);
$this->parseData($response->body);
} catch (\Exception $exception) {
if ($this->logger) {
$this->logger->warning('IP LOOKUP: ' . $exception->getMessage());
}
}
}
示例5: stopDaemon
protected function stopDaemon()
{
if (!file_exists(PHPCI_DIR . '/daemon/daemon.pid')) {
echo "Not started\n";
$this->logger->warning("Can't stop daemon as not started");
return "notstarted";
}
$cmd = "kill \$(cat %s/daemon/daemon.pid)";
$command = sprintf($cmd, PHPCI_DIR);
exec($command);
$this->logger->info("Daemon stopped");
unlink(PHPCI_DIR . '/daemon/daemon.pid');
}
示例6: weight
private function weight($imageRegion)
{
// Outros efectos para mellorar
//$imageRegion->negateImage(true);
//$imageRegion->fxImage('intensity');
//$imageRegion->contrastImage(1);
$imageRegion->whiteThresholdImage('#EEE');
$imageRegion->blackThresholdImage('#EEE');
/*$basename = $this->basedir . '/%02d.png';
$imageRegion->writeImage( sprintf($basename, $this->i++) );*/
// Contar pixels
$it = new \ImagickPixelIterator($imageRegion);
//$whitePixel = new \ImagickPixel('#000');
$whitePixel = new \ImagickPixel('#FFF');
$totalPixels = 0;
$dirtyPixels = 0;
foreach ($it as $pixels) {
foreach ($pixels as $column => $pixel) {
if (!$pixel->isSimilar($whitePixel, 0.1)) {
$dirtyPixels++;
}
$totalPixels++;
}
$it->syncIterator();
}
$percent = $dirtyPixels * 100 / $totalPixels;
//dump($percent);
$this->logger->warning('%: ' . $percent);
return $percent;
}
示例7: syncGroupUsers
/**
* @param Group $group
* @param int $offset
*/
private function syncGroupUsers(Group $group, $offset = 0)
{
$this->logger->info(' - Processing users for Group `' . $group->getName() . '` ' . $offset . ' to ' . ($offset + self::BATCH_SIZE) . '...');
$ldapUsers = $this->ldap->findGroupUsers($group->getReference(), $offset, self::BATCH_SIZE);
$grouphubUsers = $this->api->findGroupUsers($group, $offset, self::BATCH_SIZE);
// Nothing to sync, or done syncing
if (count($ldapUsers) === 0 && count($grouphubUsers) === 0) {
$this->logger->info(' - Done syncing Group users!');
return;
}
$index = $grouphubUsers->synchronize($ldapUsers, true);
$this->logger->info(' -- Going to add ' . count($grouphubUsers->getAddedElements()) . ' users for Group to Grouphub...');
foreach ($grouphubUsers->getAddedElements() as $element) {
/** @var User $element */
$user = $this->api->findUserByReference($element->getReference());
if (!$user) {
$this->logger->warning(' -- Skipping user with ref ' . $element->getReference() . ' because it cannot be found in the API?!?');
continue;
}
try {
$this->api->addGroupUser($group->getId(), $user->getId());
} catch (\Exception $e) {
$this->logger->warning(' -- Failed adding user with ref ' . $element->getReference() . ' message: ' . $e->getMessage());
}
}
$this->logger->info(' -- Going to remove ' . count($grouphubUsers->getRemovedElements()) . ' users for Group from Grouphub...');
foreach ($grouphubUsers->getRemovedElements() as $element) {
/** @var User $element */
$this->api->removeGroupUser($group->getId(), $element->getId());
}
$this->syncGroupUsers($group, $offset + $index + 1);
}
示例8: stopDaemon
protected function stopDaemon()
{
$pid = $this->getRunningPid();
if (!$pid) {
$this->logger->notice("Cannot stop the daemon as it is not started");
return "notstarted";
}
$this->logger->info("Trying to terminate the daemon", array('pid' => $pid));
$this->processControl->kill($pid);
for ($i = 0; ($pid = $this->getRunningPid()) && $i < 5; $i++) {
sleep(1);
}
if ($pid) {
$this->logger->warning("The daemon is resiting, trying to kill it", array('pid' => $pid));
$this->processControl->kill($pid, true);
for ($i = 0; ($pid = $this->getRunningPid()) && $i < 5; $i++) {
sleep(1);
}
}
if (!$pid) {
$this->logger->notice("Daemon stopped");
return "stopped";
}
$this->logger->error("Could not stop the daemon");
}
示例9: createLogger
protected function createLogger($path, $level = Logger::WARNING)
{
$logger = new Logger('app');
$logger->pushProcessor(new PsrLogMessageProcessor());
if (is_writable($path) || is_writable(dirname($path))) {
$logger->pushHandler(new StreamHandler($path, $level));
} else {
if ($this->app->isDebug()) {
throw new DCException("Log path '{$path}' is not writable. Make sure your logger.path of config.");
}
$logger->pushHandler(new ErrorLogHandler(ErrorLogHandler::OPERATING_SYSTEM, $level));
$logger->warning("Log path '{$path}' is not writable. Make sure your logger.path of config.");
$logger->warning("error_log() is used for application logger instead at this time.");
}
return $logger;
}
示例10: extract
protected function extract(Account $account, Profile $profile, $tableName, $dateFrom, $dateTo)
{
$config = $account->getConfiguration();
$cfg = $config[$tableName];
$filters = isset($cfg['filters'][0]) ? $cfg['filters'][0] : null;
$segment = isset($cfg['segment']) ? $cfg['segment'] : null;
$resultSet = $this->gaApi->getData($profile->getGoogleId(), $cfg['dimensions'], $cfg['metrics'], $filters, $segment, $dateFrom, $dateTo);
$this->logger->info("Extracting ...", ['dimensions' => $cfg['dimensions'], 'metrics' => $cfg['metrics'], 'dateFrom' => $dateFrom, 'dateTo' => $dateTo, 'results' => count($resultSet)]);
if (empty($resultSet)) {
$this->logger->warning("Query returned empty result", ['account' => $account->getAccountName(), 'profile' => $profile->getName(), 'outputTable' => $tableName]);
return;
}
$csv = $this->getOutputCsv($tableName, $profile);
$this->getDataManager()->saveToCsv($resultSet, $profile, $csv);
// Paging
$params = $this->gaApi->getDataParameters();
if ($params['totalResults'] > $params['itemsPerPage']) {
$pages = ceil($params['totalResults'] / $params['itemsPerPage']);
for ($i = 1; $i < $pages; $i++) {
$start = $i * $params['itemsPerPage'] + 1;
$resultSet = $this->gaApi->getData($profile->getGoogleId(), $cfg['dimensions'], $cfg['metrics'], $filters, $segment, $dateFrom, $dateTo, 'ga:date', $start, $params['itemsPerPage']);
$this->getDataManager()->saveToCsv($resultSet, $profile, $csv, true);
}
}
$this->getDataManager()->uploadCsv($csv->getPathname(), $this->getOutputTable($account, $tableName), true);
}
示例11: warning
public static function warning($message, $context = array())
{
$logger = new Logger('api_log');
$file = static::prepare('warning');
$logger->pushHandler(new StreamHandler($file, Logger::INFO));
$logger->warning($message, $context);
}
示例12: warning
public function warning($message, array $args = [], array $context = [])
{
if (count($args)) {
$message = vsprintf($message, $args);
}
return parent::warning($message, $context);
}
示例13: testLogNotHandled
/**
* @covers Monolog\Logger::addRecord
*/
public function testLogNotHandled()
{
$logger = new Logger(__METHOD__);
$handler = $this->getMock('Monolog\\Handler\\NullHandler', array('handle'), array(Logger::ERROR));
$handler->expects($this->never())->method('handle');
$logger->pushHandler($handler);
$this->assertFalse($logger->warning('test'));
}
示例14: initManager
public function initManager(\GearmanJob $job)
{
$this->job = $job;
$this->gearmanDto = unserialize($job->workload());
$this->processManager = ProcessManagerFactory::getProcessManager($this->gearmanDto->getManagerType());
$this->processManager->setJob($job);
$this->processManager->setGearmanDto($this->gearmanDto);
try {
$this->processManager->manage();
} catch (\Exception $e) {
$errorMessage = "Gearman process manager die with exception: " . $e->getMessage() . "| gearmanDto: " . serialize($this->gearmanDto);
$this->logger->warning($errorMessage);
$this->processManager->getExecutionDto()->setErrorMessage($errorMessage);
die;
}
return null;
}
示例15: makeAttentionLog
protected function makeAttentionLog($inspectionMessage)
{
if (!$this->allTasksComplete) {
$this->logger->error("Inspection message: " . $inspectionMessage);
}
$this->logger->warning("Executed with Error: " . serialize($this->executedWithError));
return null;
}