本文整理汇总了PHP中Monolog\Logger::addDebug方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::addDebug方法的具体用法?PHP Logger::addDebug怎么用?PHP Logger::addDebug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monolog\Logger
的用法示例。
在下文中一共展示了Logger::addDebug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: optionsIndex
/**
* Options request for any Installation request.
*
* @param HttpFoundation\Request $request
* @return HttpFoundation\Response
*/
public function optionsIndex(HttpFoundation\Request $request)
{
$this->log->addDebug(print_r($request, true), ['namespace' => 'Alerts\\Controllers\\Install', 'method' => 'optionsIndex', 'type' => 'request']);
$response = new HttpFoundation\Response('OK');
$response->headers->add(['Access-Control-Allow-Methods' => 'POST, OPTIONS']);
return $response;
}
示例2: __invoke
/**
* Called when this object is called as a function
*
* @param Context $context
* @param OptionsFactory $optionsFactory
* @throws \Exception if haltOnError setting is true
*/
public function __invoke(Context $context, OptionsFactory $optionsFactory)
{
$getopt = $context->getopt(array_keys(self::$options));
// Get directory list
$dirListFactory = new DirectoryListFactory();
$dirListFactory->loadFromCommandline($getopt->get(), 2);
$dirListFactory->loadFromStdin(new StdinReader(3));
$dirList = $dirListFactory->getList();
$this->logger->addDebug('Found directories', [count($dirList)]);
// Load base options
$baseOptions = $optionsFactory->newInstance();
$baseOptions->validateAllRequired();
if ($baseOptions->preview) {
$this->logger->addNotice('PREVIEW MODE');
}
foreach ($dirList as $dir) {
try {
$this->logger->addNotice('In directory', [$dir]);
$this->processDirectory($dir, $baseOptions, $optionsFactory);
} catch (\Exception $e) {
if ($baseOptions->haltOnError) {
throw $e;
} elseif ($baseOptions->verbosity == 2) {
$this->logger->addError($e, []);
} else {
$this->logger->addError($e->getMessage(), []);
}
}
}
}
示例3: 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);
}
}
示例4: 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);
}
}
示例5: _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;
}
示例6: sendPush
public static function sendPush($deviceToken, $message, $data = null, $type = null)
{
$log = new \Monolog\Logger('notifications');
$log->pushHandler(new \Monolog\Handler\StreamHandler(Env::$config->logPath . 'notifications.log', Logger::DEBUG));
$log->addInfo('Entering to send a push');
if (strlen($deviceToken) == 64) {
$log->addInfo('Sending notification to ios device', ["deviceToken" => $deviceToken]);
$ctx = stream_context_create();
//dev pem /home7/quesoazu/www/doyride/push/dev_key.pem
stream_context_set_option($ctx, 'ssl', 'local_cert', Env::$config->pem);
stream_context_set_option($ctx, 'ssl', 'passphrase', Env::$config->passphrase);
// Open a connection to the APNS server
// DEV APNS gateway.sandbox.push.apple.com:2195
$fp = stream_socket_client(Env::$config->apns, $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx);
if (!$fp) {
exit("Failed to connect: {$err} {$errstr}" . PHP_EOL);
}
//echo 'Connected to APNS' . PHP_EOL;
// Create the payload body
$body['aps'] = array('alert' => $message, 'sound' => 'default', 'content-available' => 1);
$body['d'] = $data;
$body['t'] = $type;
// Encode the payload as JSON
$payload = json_encode($body);
// Build the binary notification
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
// Send it to the server
$result = fwrite($fp, $msg, strlen($msg));
$log->addDebug($result);
// Close the connection to the server
fclose($fp);
} else {
$log->addInfo('Sending notification to android device', ["deviceToken" => $deviceToken]);
//AIzaSyBpweimzrQ-5pjUO1absB4cTrDVRHIxmMg
$api_key = Env::$config->apikey;
//$registrationIDs = array("APA91bHOZnfPwVys28cus-w9s18zZw4lXb-CU1Os8OiA2MpLpvGc4b9sxipnAVZNiDHe3iWv4T-_5B7UHJ_ce2ybu_w_Z4Y_kXWsIJqE4bjyF0tcrZrofszmE42xJ_sg15Tw2yG2IxVXcFu37LyP7ZHx9DqRqqRByPSLUwkrUqzqavQSWt1A3l4");
$registrationIDs = array($deviceToken);
$message = $message;
$url = 'https://android.googleapis.com/gcm/send';
/*$body['registration_ids'] = $deviceToken;
$body['aps'] = array(
'alert' => $message,
'sound' => 'default'
);
$body['d'] = $data;
$body['t'] = $type;*/
$fields = array('registration_ids' => $registrationIDs, 'data' => array("message" => $message, "d" => $data, "t" => $type));
$headers = array('Authorization: key=' . $api_key, 'Content-Type: application/json');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
$log->addDebug($result);
curl_close($ch);
}
}
示例7: loadFile
/**
* @param $configFile
*/
public function loadFile($configFile)
{
if (!file_exists(realpath($configFile))) {
$this->logger->addError('Config file ' . realpath($configFile) . ' not found.');
return;
}
try {
$this->config = array_change_key_case(include $configFile, \CASE_LOWER);
$this->logger->addDebug('Config file loaded: ' . realpath($configFile));
} catch (\Exception $e) {
$this->logger->addError('Failed loading config file (' . realpath($configFile) . '): ' . $e->getMessage());
}
}
示例8: 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;
}
}
示例9: debug
/**
* @internal Log debug events in verbose mode
*/
private function debug($message)
{
if (1 < func_num_args()) {
$message = call_user_func_array('sprintf', func_get_args());
}
$this->logger->addDebug($message);
}
示例10: 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));
}
}
}
}
}
示例11: optionsIndex
/**
* Options request for OAuth.
*
* @param int $id
* @param HttpFoundation\Request $request
* @return HttpFoundation\Response
*/
public function optionsIndex($id, HttpFoundation\Request $request)
{
$this->log->addDebug(print_r($request, true), ['namespace' => 'HackTheDinos\\Controllers\\User', 'method' => 'optionsIndex', 'type' => 'request']);
$response = new HttpFoundation\Response('OK');
$response->headers->add(['Access-Control-Allow-Methods' => is_null($id) ? 'POST, OPTIONS' : 'POST, PUT, OPTIONS']);
return $response;
}
示例12: 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;
}
}
示例13: 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);
}
}
示例14: loadPlugin
/**
* Loads a plugin. See the README for plugin documentation.
*
* @param AbstractPlugin $plugin An instance of the plugin to load
*
* @return \Philip\Philip
*/
public function loadPlugin(AbstractPlugin $plugin)
{
$name = $plugin->getName();
$this->log->addDebug('--- Loading plugin ' . $name . PHP_EOL);
$plugin->init();
$this->plugins[$name] = $plugin;
return $this;
}
示例15: post
private function post($path, $code, $grant_type, $fields = [])
{
$curl = curl_init();
curl_setopt_array($curl, [CURLOPT_URL => self::PUBLIC_API . DIRECTORY_SEPARATOR . $path, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['Accept: application/json'], CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query(array_merge(['code' => $code, 'grant_type' => $grant_type, 'client_id' => $this->getClientId(), 'client_secret' => $this->getClientSecret(), 'redirect_uri' => $this->getRedirectUri()], $fields))]);
$result = curl_exec($curl);
$this->logger->addDebug('#Orcid Debug', [$result]);
return json_decode($result);
}