本文整理匯總了PHP中Monolog\Logger::addWarning方法的典型用法代碼示例。如果您正苦於以下問題:PHP Logger::addWarning方法的具體用法?PHP Logger::addWarning怎麽用?PHP Logger::addWarning使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Monolog\Logger
的用法示例。
在下文中一共展示了Logger::addWarning方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: writeEntry
protected function writeEntry($level, $message, $indent, $category = "", $additionalData = [])
{
$message = str_pad($category, 16, " ", STR_PAD_RIGHT) . "\t" . str_repeat(" ", $indent) . $message;
switch ($level) {
case Log::BULK_DATA_LEVEL:
$this->logger->addDebug($message, $additionalData);
break;
case Log::DEBUG_LEVEL:
$this->logger->addDebug($message, $additionalData);
break;
case Log::ERROR_LEVEL:
$this->logger->addError($message, $additionalData);
break;
case Log::PERFORMANCE_LEVEL:
$this->logger->addNotice($message, $additionalData);
break;
case Log::WARNING_LEVEL:
$this->logger->addWarning($message, $additionalData);
break;
case Log::REPOSITORY_LEVEL:
$this->logger->addNotice($message, $additionalData);
break;
default:
$this->logger->addNotice($message, $additionalData);
}
}
示例2: _call
/**
* @param string $token Access token from the calling client
*
* @return string|false The result from the cURL call against the oauth API.
*
* @codeCoverageIgnore This function is not tested because we can't test
* curl_* calls in PHPUnit.
*/
protected function _call($token)
{
$ch = curl_init();
$url = $this->_apiUrl . $token;
$this->_logger->addDebug('calling GET: ' . $url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
$result = curl_exec($ch);
$responseCode = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curlErrno = curl_errno($ch);
$curlError = curl_error($ch);
// remove token from url for log output
$url = substr($url, 0, stripos($url, 'token') + 6);
if (0 !== $curlErrno) {
$this->_logger->addError('curl error (' . $curlErrno . '): ' . $curlError . ' url: ' . $url);
}
if ($responseCode >= 500) {
$this->_logger->addError('curl call error: ' . $responseCode . ' url: ' . $url);
} elseif ($responseCode >= 300) {
$this->_logger->addWarning('curl call warning: ' . $responseCode . ' url: ' . $url);
}
$this->_logger->addDebug('result: (' . $responseCode . ') ' . var_export($result, true));
curl_close($ch);
return $result;
}
示例3: log
public function log($message, $priority = self::INFO)
{
if ($message instanceof \Exception) {
$message = $message->getMessage();
$context = [];
} elseif (is_string($message)) {
$context = [];
} else {
$context = $message;
unset($context[0]);
unset($context[1]);
if (isset($message[1])) {
$message = preg_replace('#\\s*\\r?\\n\\s*#', ' ', trim($message[1]));
}
}
switch ($priority) {
case self::DEBUG:
return $this->monolog->addDebug($message, $context);
case self::CRITICAL:
return $this->monolog->addCritical($message, $context);
case self::ERROR:
return $this->monolog->addError($message, $context);
case self::EXCEPTION:
return $this->monolog->addEmergency($message, $context);
case self::WARNING:
return $this->monolog->addWarning($message, $context);
case 'access':
return $this->monolog->addNotice($message, $context);
case 'emergency':
return $this->monolog->addEmergency($message, $context);
default:
return $this->monolog->addInfo($message, $context);
}
}
示例4: write
/**
* Uses the Monolog file Logger to write a log message in a file.
*
* @param string $message Message that needs to be output
* @param bool $error If the log message is considered an error, for logging purposes
*/
public function write($message, $error = false)
{
if (!$error) {
$this->logger->addWarning($message);
return;
}
$this->logger->addError($message);
}
示例5: addModule
/**
* Add Module
* @param string $moduleName
* @param array $args
*/
public function addModule($moduleName, $args = [])
{
try {
$module = $this->moduleFactory->build($moduleName, PHP_OS, $args);
$this->moduleComposite->addComponent($module);
} catch (ModuleException $e) {
$this->logger->addWarning($e->getMessage());
}
}
示例6: getAll
/**
* @param string|null $type
* @return array
*/
public function getAll($type = null)
{
$type = strtolower($type);
if (!empty($this->config[$type])) {
return $this->config[$type];
}
$this->logger->addWarning('Config group not found: [' . $type . ']');
return array();
}
示例7: send
/**
* Send the email
*
* @return void
*/
public function send()
{
if ($this->enabled) {
if (!$this->emailer->send()) {
$this->logger->addWarning($this->emailer->error());
}
} else {
$this->logger->addWarning('Faked sending an email ' . $this->emailer->get('body'));
}
}
示例8: getSortingParametersFromArray
/**
* @param array $inputArray
* @param string[] $columNamesInDatabase
* @return null|string[]
*/
public function getSortingParametersFromArray($inputArray, $columNamesInDatabase, $defaultSearch = array())
{
if (array_key_exists('iSortingCols', $inputArray)) {
if ($inputArray['iSortingCols'] > count($columNamesInDatabase)) {
$this->logger->addWarning("did have enough columNames for " . $inputArray['iSortingCols'] . " sort columns.");
return null;
}
return $this->getSortingParametersFromArrayImpl($inputArray, $columNamesInDatabase, $defaultSearch);
} else {
$this->logger->addWarning("did not find iSortingCols in inputArray");
return null;
}
}
示例9: log
/**
* Log a message
*
* @param string $message
* @param int $level
* @param array $context
* @return void
*/
public function log($message, $level = Logger::INFO, array $context = [])
{
if (!$this->logger) {
return;
}
if (null === $level) {
$level = Logger::INFO;
}
switch ($level) {
case Logger::DEBUG:
$this->logger->addDebug($message, $context);
break;
case Logger::INFO:
$this->logger->addInfo($message, $context);
break;
case Logger::NOTICE:
$this->logger->addNotice($message, $context);
break;
case Logger::WARNING:
$this->logger->addWarning($message, $context);
break;
case Logger::ERROR:
$this->logger->addError($message, $context);
break;
case Logger::CRITICAL:
$this->logger->addCritical($message, $context);
break;
case Logger::EMERGENCY:
$this->logger->addEmergency($message, $context);
break;
default:
break;
}
}
示例10: log
/**
* Отправляет сообщение в лог
*
* @param string $message сообщение
* @param int $level уровень
*
* @return void
*/
public function log($message, $level = AbstractLogger::NOTICE)
{
if ($level < $this->severity) {
return;
}
switch ($level) {
case AbstractLogger::EMERGENCY:
$this->impl->addEmergency($message);
break;
case AbstractLogger::ALERT:
$this->impl->addAlert($message);
break;
case AbstractLogger::CRITICAL:
$this->impl->addCritical($message);
break;
case AbstractLogger::ERROR:
$this->impl->addError($message);
break;
case AbstractLogger::WARNING:
$this->impl->addWarning($message);
break;
case AbstractLogger::NOTICE:
$this->impl->addNotice($message);
break;
case AbstractLogger::INFO:
$this->impl->addInfo($message);
break;
case AbstractLogger::DEBUG:
$this->impl->addDebug($message);
break;
}
}
示例11: putIndex
/**
* Update an existing user
*
* @param int $id
* @param HttpFoundation\Request $request
* @return HttpFoundation\JsonResponse|HttpFoundation\Response
*/
public function putIndex($id, HttpFoundation\Request $request)
{
$this->log->addDebug(print_r($request, true), ['namespace' => 'HackTheDinos\\Controllers\\User', 'method' => 'putIndex', 'type' => 'request']);
//If this request validated then the userId should be in the request.
$userId = $request->request->get('userId');
if ($userId === $id) {
$user = $this->repo->getById($userId);
$this->log->addDebug(print_r($user, true), ['namespace' => 'HackTheDinos\\Controllers\\User', 'method' => 'putIndex', 'type' => 'user']);
//It's almost impossible for this to happen but it's good defensive coding.
if (!empty($user)) {
$user = $this->converter->entityArrayToModel(json_decode($request->getContent(), true), new Models\User());
$user->id = $userId;
if (isset($user->password)) {
$user->password = password_hash($user->password, PASSWORD_DEFAULT);
}
if ($this->repo->save($user)) {
$this->log->addInfo('Updated user', ['namespace' => 'HackTheDinos\\Controllers\\User', 'method' => 'putIndex', 'user' => (array) $user]);
return new HttpFoundation\JsonResponse($user, 200);
}
//Otherwise we couldn't save the user for some reason
$this->log->addWarning('Unable to update user', ['namespace' => 'HackTheDinos\\Controllers\\User', 'method' => 'putIndex', 'request' => $request->getContent(), 'user' => (array) $user]);
return new HttpFoundation\Response('Bad Request', 400);
}
}
//We didn't find a user to update.
$this->log->addWarning('No user found', ['namespace' => 'HackTheDinos\\Controllers\\User', 'method' => 'putIndex', 'id' => $id, 'userId' => $userId]);
return new HttpFoundation\Response('Not Found', 404);
}
示例12: compareColumns
/**
* @param array $fromCols
* @param array $toCols
* @throws StructureException
* @throws \Exception
*/
public function compareColumns($fromCols, $toCols)
{
$columnClass = new \ReflectionClass('rombar\\PgExplorerBundle\\Models\\dbElements\\Column');
if (count($fromCols) == 0 || count($toCols) == 0) {
throw new \Exception('A table has no columns!');
}
$ignoredMethods = ['getTable', 'getRealPosition', 'getOid'];
list($namesFrom, $namesTo) = $this->compareColumnsNames($fromCols, $toCols);
foreach ($namesFrom as $fromKey => $fromColName) {
$fromCol = $fromCols[$fromKey];
$toCol = $toCols[array_search($fromColName, $namesTo)];
foreach ($columnClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
if (preg_match('#^get#', $method->name) && !in_array($method->name, $ignoredMethods)) {
$getter = $method->name;
if ($fromCol->{$getter}() != $toCol->{$getter}()) {
//Special hook for nextval.
// With certain search path, the schema can be omitted wich make a false positive.
if ($getter == 'getDefault' && preg_match('/^nextval/', $fromCol->{$getter}())) {
$diff = str_replace('.', '', Utils::stringDiff($fromCol->{$getter}(), $toCol->{$getter}()));
$this->logger->addDebug('diff search_path : ' . $diff);
if (in_array($diff, $this->toAnalyzer->getSearchPath()) || in_array($diff, $this->fromAnalyzer->getSearchPath())) {
$this->logger->addWarning('Bypass by search_path test for ' . $getter . ' : ' . $fromCol->{$getter}() . ' vs ' . $toCol->{$getter}());
continue;
}
}
$this->logger->addWarning('Column ' . $fromColName . '->' . $getter . '() : ' . $fromCol->{$getter}() . ' vs ' . $toCol->{$getter}());
var_dump($fromCol);
var_dump($toCol);
throw new StructureException('Targeted database has a different column ' . $fromCol->getName() . ' in table ' . $fromCol->getSchema() . PgAnalyzer::DB_SEPARATOR . $this->fromAnalyzer->getTable($fromCol->getSchema(), $fromCol->getTable())->getName() . ' check the property ' . substr($getter, 3));
}
}
}
}
}
示例13: findTextByKey
protected function findTextByKey($steps, $count)
{
$node = $this->source;
foreach (explode('.', $steps) as $step) {
if (!isset($node[$step])) {
$this->log->addWarning("Translation for '{$steps}' not found, missing key '{$step}'", [$this->language]);
return NULL;
}
$node = $node[$step];
}
if (!is_array($node)) {
if ($count !== NULL) {
$this->log->addNotice("Translation for '{$steps}' has no plurals, but count '{$count}' was passed", [$this->language]);
}
return $node;
}
if ($count === NULL) {
$this->log->addNotice("Translation for '{$steps}' has plurals, but no count was passed", [$this->language]);
}
$keys = $this->countToKey($count);
foreach ($keys as $key) {
if (isset($node[$key])) {
return $node[$key];
}
}
$this->log->addWarning("Translation for '{$steps}' is missing plurals", [$this->language]);
return NULL;
}
示例14: startWorker
/**
* Start the worker.
*/
public function startWorker()
{
$this->pheanstalk->watch($this->queue);
$this->pheanstalk->ignore('default');
$buildStore = Factory::getStore('Build');
while ($this->run) {
// Get a job from the queue:
$job = $this->pheanstalk->reserve();
$this->checkJobLimit();
// Get the job data and run the job:
$jobData = json_decode($job->getData(), true);
if (!$this->verifyJob($job, $jobData)) {
continue;
}
$this->logger->addInfo('Received build #' . $jobData['build_id'] . ' from Beanstalkd');
// If the job comes with config data, reset our config and database connections
// and then make sure we kill the worker afterwards:
if (!empty($jobData['config'])) {
$this->logger->addDebug('Using job-specific config.');
$currentConfig = Config::getInstance()->getArray();
$config = new Config($jobData['config']);
Database::reset($config);
}
try {
$build = BuildFactory::getBuildById($jobData['build_id']);
} catch (\Exception $ex) {
$this->logger->addWarning('Build #' . $jobData['build_id'] . ' does not exist in the database.');
$this->pheanstalk->delete($job);
}
try {
// Logging relevant to this build should be stored
// against the build itself.
$buildDbLog = new BuildDBLogHandler($build, Logger::INFO);
$this->logger->pushHandler($buildDbLog);
$builder = new Builder($build, $this->logger);
$builder->execute();
// After execution we no longer want to record the information
// back to this specific build so the handler should be removed.
$this->logger->popHandler($buildDbLog);
} catch (\PDOException $ex) {
// If we've caught a PDO Exception, it is probably not the fault of the build, but of a failed
// connection or similar. Release the job and kill the worker.
$this->run = false;
$this->pheanstalk->release($job);
} catch (\Exception $ex) {
$build->setStatus(Build::STATUS_FAILED);
$build->setFinished(new \DateTime());
$build->setLog($build->getLog() . PHP_EOL . PHP_EOL . $ex->getMessage());
$buildStore->save($build);
$build->sendStatusPostback();
}
// Reset the config back to how it was prior to running this job:
if (!empty($currentConfig)) {
$config = new Config($currentConfig);
Database::reset($config);
}
// Delete the job when we're done:
$this->pheanstalk->delete($job);
}
}
示例15: index
public function index()
{
$this->load->view('welcome_message');
$log = new Logger('test001');
$log->pushHandler(new StreamHandler('/tmp/my.log', Logger::WARNING));
$log->addWarning('Foo');
$log->addError('Bar');
}