本文整理汇总了PHP中Log::warning方法的典型用法代码示例。如果您正苦于以下问题:PHP Log::warning方法的具体用法?PHP Log::warning怎么用?PHP Log::warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Log
的用法示例。
在下文中一共展示了Log::warning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: email
protected static function email($template, $title, $data, $receivers, $sender, $bcc = null, $file = null)
{
$data['app_name'] = Config::get('app.name');
$data['base'] = Config::get('app.url');
$data['title'] = $title;
$data['receivers'] = $receivers;
$data['user_name'] = $sender['name'];
$data['user_email'] = $sender['email'];
$data['bcc'] = (array) $bcc;
$data['file'] = $file;
$success = false;
try {
Log::info('<!> Sending new email...');
Mail::queue('emails.' . $template, $data, function ($message) use($data) {
$message->from($data['user_email'], $data['user_name'])->subject($data['app_name'] . ' - ' . $data['title']);
if (!empty($data['receivers'])) {
$message->to($data['receivers']);
}
if (!empty($data['bcc'])) {
$message->bcc($data['bcc']);
}
if (!empty($data['file'])) {
$message->attach($data['file']);
}
});
Log::info('...DONE!');
// Log::info( json_encode($data) );
$success = true;
} catch (Exception $e) {
Log::warning('<!!!> ...FAILED! Exception while sending email: ' . $e->getMessage());
}
return $success;
}
示例2: load
public static function load($controlName = '', $funcName = 'index')
{
// $funcOfController = '';
if (preg_match('/(\\w+)\\@(\\w+)/i', $controlName, $matchesName)) {
$controlName = $matchesName[1];
// $funcOfController = $matchesName[2];
$funcName = $matchesName[2];
}
// $path = CONTROLLERS_PATH . $controlName . '.php';
$path = self::getPath() . $controlName . '.php';
if (!file_exists($path)) {
Response::headerCode(404);
Log::warning('Controller <b>' . $controlName . '</b> not exists.');
}
include $path;
if (preg_match('/.*?\\/(\\w+)$/i', $controlName, $matches)) {
$controlName = $matches[1];
}
$load = new $controlName();
if (!isset($funcName[0])) {
$funcName = 'index';
}
$funcName = $funcName == 'index' ? $funcName : 'get' . ucfirst($funcName);
if (!method_exists($load, $funcName)) {
Response::headerCode(404);
Log::warning('Function <b>' . $funcName . '</b> not exists inside controller <b>' . $controlName . '</b> .');
}
$load->{$funcName}();
}
示例3: getReferenced
/**
* Returns a DaoIterator for a specific reference.
* A DataSource can directly return the DataHash, so it doesn't have to be fetched.
*
* @param Record $record
* @param string $attribute The attribute it's being accessed on
* @return DaoIterator
*/
public function getReferenced($record, $attribute)
{
if ($data = $record->getDirectly($attribute)) {
if (is_array($data)) {
if (count($data) === 0 || is_array(reset($data))) {
// The data hash is an array, either empty, or containing the hashes.
return new DaoHashListIterator($data, $this->getForeignDao());
} elseif (is_int(reset($data)) && ($foreignKey = $this->getForeignKey())) {
// The data hash is an array containing the ids, and there is a
// foreign key to link them to.
return new DaoKeyListIterator($data, $this->getForeignDao(), $foreignKey);
}
}
Log::warning(sprintf('The data hash for `%s` was set but incorrect.', $attribute));
return new DaoHashListIterator(array(), $this->getForeignDao());
} else {
// Get the list of ids
$localKey = $this->getLocalKey();
$foreignKey = $this->getForeignKey();
if ($localKey && $foreignKey) {
$localValue = $record->get($localKey);
return new DaoKeyListIterator($localValue ? $localValue : array(), $this->getForeignDao(), $foreignKey);
}
return new DaoKeyListIterator(array(), $this->getForeignDao(), $foreignKey);
}
}
示例4: authenticate
public function authenticate($ticket, $service)
{
$r = Request::get($this->getValidateUrl($ticket, $service))->sendsXml()->timeoutIn($this->timeout)->send();
$r->body = str_replace("\n", "", $r->body);
try {
$xml = new SimpleXMLElement($r->body);
} catch (\Exception $e) {
throw new \UnexpectedValueException("Return cannot be parsed : '{$r->body}'");
}
$namespaces = $xml->getNamespaces();
$serviceResponse = $xml->children($namespaces['cas']);
$user = $serviceResponse->authenticationSuccess->user;
if ($user) {
return (string) $user;
// cast simplexmlelement to string
} else {
$authFailed = $serviceResponse->authenticationFailure;
if ($authFailed) {
$attributes = $authFailed->attributes();
Log::warning("AuthenticationFailure : " . $attributes['code'] . " ({$ticket}, {$service})");
throw new AuthenticationFailure((string) $attributes['code']);
} else {
Log::error("Cas return is weird : '{$r->body}'");
throw new \UnexpectedValueException($r->body);
}
}
// never reach there
}
示例5: getNestData
/**
* @param \User $user
*
* @return mixed
*/
public function getNestData(\User $user)
{
// start, return is false:
$data = false;
$count = 0;
while ($data === false && $count < 5) {
\Log::debug('Attempt #' . ($count + 1));
// try to get the data:
$URL = 'https://developer-api.nest.com/?auth=' . $user->accessToken;
$client = new Client();
try {
$response = $client->get($URL);
} catch (RingException $e) {
\Log::error('GuzzleHttp\\Ring\\Exception\\ConnectException for user ' . $user->id . '! ' . $e->getMessage());
sleep(5);
return false;
} catch (ConnectException $e) {
\Log::error('GuzzleHttp\\Exception\\ConnectException for user ' . $user->id . '!! ' . $e->getMessage());
sleep(5);
return false;
} catch (\Exception $e) {
\Log::error('General exception (' . get_class($e) . ') for user ' . $user->id . '! ' . $e->getMessage());
if ($e->getCode() == 401) {
\Log::warning('This is unauthorized! Delete the user!');
$user->delete();
}
sleep(5);
return false;
}
$body = $response->getBody()->getContents();
$data = json_decode($body);
$count++;
}
return $data;
}
示例6: render
public static function render($template, $vars = array())
{
Log::debug(__CLASS__ . ': Attempting to render template "' . $template . '"');
$template_file = 'tpl.' . $template . '.php';
if (!self::$template_dir && !(self::$template_dir = Config::get('template_dir'))) {
$included_dirs = ini_get('include_path');
foreach (explode(':', $included_dirs) as $dir) {
if (is_readable($dir . '/templates')) {
self::$template_dir = $dir . '/templates';
break;
}
}
}
if (is_readable(self::$template_dir . '/' . $template_file)) {
ob_start();
extract($vars);
include self::$template_dir . '/' . $template_file;
$output = ob_get_contents();
ob_end_clean();
return $output;
} else {
Log::warning(__CLASS__ . ': Could not render template ' . self::$template_dir . '/' . $template_file);
}
return '';
}
示例7: searchObjects
/**
* Search objects of specified type for certain criteria.
*
* @param string $type object type (e.g. changeset)
* @param array $criteria array of criterion objects.
*
* @return Services_OpenStreetMap_Objects
*/
public function searchObjects($type, array $criteria)
{
$query = array();
foreach ($criteria as $criterion) {
$query[] = $criterion->query();
}
$config = $this->getConfig();
$url = $config->getValue('server') . 'api/' . $config->getValue('api_version') . '/' . $type . 's?' . implode('&', $query);
try {
$response = $this->getResponse($url);
} catch (Services_OpenStreetMap_Exception $ex) {
$this->log->warning((string) $ex);
switch ($ex->getCode()) {
case self::NOT_FOUND:
case self::UNAUTHORISED:
case self::GONE:
return false;
default:
throw $ex;
}
}
$class = 'Services_OpenStreetMap_' . ucfirst(strtolower($type)) . 's';
$obj = new $class();
$sxe = @simplexml_load_string($response->getBody());
if ($sxe === false) {
$obj->setVal(trim($response->getBody()));
} else {
$obj->setXml($sxe);
}
return $obj;
}
示例8: getInfobox
/**
* @param null $page
*/
public static function getInfobox($page = null)
{
self::$parameters['titles'] = $page;
$url = self::buildApiURL(self::$protocol, self::$locale, self::$endpoint, self::$parameters);
$response = self::doRequest($url);
if (self::isSuccessful($response->getStatusCode()) && self::isJson($response->getHeader('content-type'), self::$expectedReponseHeader)) {
if (!empty($response->json()['query']) && !empty($response->json()['query']['pages'])) {
$revision = array_pop($response->json()['query']['pages']);
$infobox = self::parseInfobox($revision['revisions'][0]['*']);
if (count($infobox) === 1) {
$lines = explode("\n", $infobox[0]);
$returnArray = self::convertInfoBoxToKeyValuePairs($lines);
echo json_encode($returnArray);
} else {
if (count($infobox) > 1) {
\Log::warning('more than one infobox found');
} else {
\Log::warning('Infobox not found');
}
}
}
} else {
\Log::warning('request not in json format');
}
}
示例9: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Eloquent::unguard();
if (!Config::get('gosmart.integrated_patient_database')) {
\Log::warning("Can only seed simulations if a patient database is available");
return;
}
$this->clean();
//$this->deepClean();
$organs = ['liver', 'kidney'];
foreach ($organs as $organ) {
$referenceSimulation[$organ] = [];
$sim = Simulation::join('ItemSet_Patient AS IS_P', 'IS_P.Id', '=', 'Simulation.Patient_Id')->join('ItemSet AS IS', 'IS.Id', '=', 'IS_P.Id')->join('Simulation_Needle AS SN', 'SN.Simulation_Id', '=', 'Simulation.Id')->where('IS_P.OrganType', '=', ContextEnum::value($organ))->where('IS.IsDeleted', '=', 'FALSE')->select('Simulation.*')->first();
if ($sim) {
$referenceSimulation[$organ]["patient"] = DB::table('ItemSet_Patient')->whereId($sim->Patient_Id)->first();
$referenceNeedle = $sim->SimulationNeedles->first();
$referenceSimulation[$organ]["target"] = $referenceNeedle->Target;
$referenceSimulation[$organ]["entry"] = $referenceNeedle->Entry;
} else {
$referenceSimulation[$organ]["patient"] = NULL;
$referenceSimulation[$organ]["target"] = PointSet::fromArray([0, 0, 0]);
$referenceSimulation[$organ]["entry"] = PointSet::fromArray([1, 1, 1]);
}
}
foreach (['5cm', '4cm', '3cm', '2cm'] as $length) {
$this->makeSimulation("{$length} RITA RFA", $referenceSimulation["liver"]["patient"], 'liver', 'NUMA RFA Basic SIF', "RITA Starburst {$length} Protocol", [], ['organ' => ["organ.vtp"], 'vessels' => ["vessels1.vtp"], 'tumour' => ["tumour.vtp"]], [["Manufacturer" => "RITA", "Name" => "Starburst MRI", "Parameters" => ['NEEDLE_TIP_LOCATION' => $referenceSimulation["liver"]["target"]->asString, 'NEEDLE_ENTRY_LOCATION' => $referenceSimulation["liver"]["entry"]->asString]]]);
}
$this->makeSimulation('Cryoablation', $referenceSimulation["kidney"]["patient"], 'kidney', 'NUMA Cryoablation Basic SIF', 'Empty', ['SETTING_FINAL_TIMESTEP' => '300'], ['organ' => ["organ.vtp"], 'vessels' => ["vessels1.vtp"], 'tumour' => ["tumour.vtp"]], [["Manufacturer" => "Galil Medical", "Name" => "IceROD", "Parameters" => ['NEEDLE_TIP_LOCATION' => $referenceSimulation["kidney"]["target"]->asString, 'NEEDLE_ENTRY_LOCATION' => $referenceSimulation["kidney"]["entry"]->asString]]]);
$needleDeltas = [[10, 8, -5], [10, 8, 5], [10, -8, -5], [10, -8, 5], [10, 5, 0], [10, -5, 0]];
$ireTipCentre = $referenceSimulation["liver"]["target"]->asArray;
$ireEntryCentre = $referenceSimulation["liver"]["entry"]->asArray;
$parallel = array_map(function ($c) use($ireTipCentre, $ireEntryCentre) {
return $ireTipCentre[$c] - $ireEntryCentre[$c];
}, [0, 1, 2]);
$norm = sqrt($parallel[0] * $parallel[0] + $parallel[1] * $parallel[1] + $parallel[2] * $parallel[2]);
$parallel = array_map(function ($c) use($norm) {
return $c / $norm;
}, $parallel);
$randVec = [0, 1.2384717624, 3.42878E-6];
$perp1 = crossProduct($parallel, $randVec);
$perp2 = crossProduct($parallel, $perp1);
//$parallel = [1, 0, 0];
//$perp1 = [0, 1, 0];
//$perp2 = [0, 0, 1];
$ireNeedles = [];
foreach ($needleDeltas as $needleDelta) {
$needleOffset = array_map(function ($c) use($needleDelta, $parallel, $perp1, $perp2) {
return $needleDelta[0] * $parallel[$c] + $needleDelta[1] * $perp1[$c] + $needleDelta[2] * $perp2[$c];
}, [0, 1, 2]);
$needleTip = array_map(function ($p) {
return $p[0] + $p[1];
}, array_map(null, $ireTipCentre, $needleOffset));
$ireNeedle = ["Manufacturer" => "Angiodynamics", "Name" => "Basic", "Parameters" => ['NEEDLE_TIP_LOCATION' => json_encode($needleTip), 'NEEDLE_ENTRY_LOCATION' => json_encode(array_map(function ($p) {
return $p[0] + $p[1];
}, array_map(null, $ireEntryCentre, $needleOffset)))]];
$ireNeedles[] = $ireNeedle;
}
$this->makeSimulation('IRE', $referenceSimulation["liver"]["patient"], 'liver', 'NUMA IRE 3D SIF', 'Empty', ['CONSTANT_IRE_POTENTIAL_DIFFERENCES' => "[1300, 1500, 1300, 1900, 1300, 1300, 1300, 1900, 1300]"], ['organ' => ["organ.vtp"], 'vessels' => ["vessels1.vtp"], 'tumour' => ["tumour.vtp"]], $ireNeedles);
$this->makeSimulation('Amica MWA', $referenceSimulation["kidney"]["patient"], 'kidney', 'NUMA MWA Nonlinear SIF', 'Generic modifiable power', [], ['organ' => ["organ.vtp"], 'vessels' => ["vessels1.vtp"], 'tumour' => ["tumour.vtp"]], [["Manufacturer" => "HS", "Name" => "APK11150T19V5", "Parameters" => ['NEEDLE_TIP_LOCATION' => $referenceSimulation["kidney"]["target"]->asString, 'NEEDLE_ENTRY_LOCATION' => $referenceSimulation["kidney"]["entry"]->asString]]]);
}
示例10: sanitize
public static function sanitize($str)
{
$tag = "DatabaseSanitizer::sanitize()";
//Log::debug("$tag: $str");
$db_host = BPConfig::$db_host;
$db_database = BPConfig::$db_database;
$db_user = BPConfig::$db_user_read_only;
$db_passwd = BPConfig::$db_passwd_read_only;
// connect to mysql database
$connection = new mysqli($db_host, $db_user, $db_passwd, $db_database);
// verify connection
if (mysqli_connect_error()) {
// connection failed
throw new Exception("Connection Failed");
}
// For backward compatibility
// Strip slashes automatically added when magic_quotes_gpc is On
// Note: magic_quotes_gpc deprecated in PHP 5.3 and removed in PHP 5.4
if (get_magic_quotes_gpc()) {
Log::warning("{$tag}: magic_quotes_gpc = On");
$str = stripslashes($str);
}
// Escape string
$str = mysqli_real_escape_string($connection, $str);
return $str;
}
示例11: page
public function page($slug = '')
{
// allow admin to view unpublished posts
if (Users::authed() === false) {
$params['status'] = 'published';
}
// if no slug is set we will use our default page
if (empty($slug)) {
$params['id'] = Config::get('metadata.home_page');
} else {
$params['slug'] = $slug;
}
// if we cant find either it looks like we're barney rubble (in trouble)
if (($page = Pages::find($params)) === false) {
Log::warning('Page connot be found: ' . $slug);
return Response::error(404);
}
// store our page for template functions
IoC::instance('page', $page, true);
// does the current page host our posts?
if ($page->id == Config::get('metadata.posts_page')) {
// render our posts template
return Template::render('posts');
}
// render our page template
Template::render('page');
}
示例12: updateFromServer
private function updateFromServer()
{
try {
$fetcher = new CnbetaArticleFetcher($this->id);
$newArticle = $fetcher->article;
Log::info('updating data for article: ' . $this->id);
if ($newArticle['hotlist']) {
$this->data = $newArticle;
} else {
if (isset($newArticle['view_num']) && isset($newArticle['comment_num'])) {
$this->data['view_num'] = $newArticle['view_num'];
$this->data['comment_num'] = $newArticle['comment_num'];
} else {
throw new Exception('nothing to save');
}
}
$this->saveToCache();
$article_entry = ArticleEntry::where('article_id', $this->id)->first();
$article_entry->view_num = $newArticle['view_num'];
$article_entry->comment_num = $newArticle['comment_num'];
$article_entry->save();
Log::info('updated article: ' . $this->id);
$this->markUpToDate();
} catch (Exception $ex) {
Log::warning('fetching article failed: ' . $ex->getMessage());
}
}
示例13: testOverridingDefaultLogFunctionalityWithFileHandler
/**
* Attempts to change the default database logging functionality
* into a file stream.
*/
public function testOverridingDefaultLogFunctionalityWithFileHandler()
{
if (file_exists(dirname(__FILE__) . '/test.log')) {
unlink(dirname(__FILE__) . '/test.log');
}
Log::info('This should be in the database.');
// now we will add a stream handler that can handle all the different
// types of debug messages, but it should keep things OUT of the database
$r = new stdClass();
$r->test = 'test';
$sh = new \Monolog\Handler\StreamHandler(dirname(__FILE__) . '/test.log', Logger::DEBUG, false);
Log::pushHandler($sh);
Log::warning('This is a warning!');
Log::info('This is an interesting object', array($r));
$db = Database::get();
$r = $db->GetAll('select * from Logs');
// there should only be one item in the logs table because the first info
// should be in there but the rest should not be.
$this->assertTrue($r[0]['logID'] == 1);
$this->assertTrue($r[0]['channel'] == Logger::CHANNEL_APPLICATION);
$this->assertTrue($r[0]['message'] == 'This should be in the database.');
$this->assertTrue($r[0]['level'] == Log::getLevelCode('info'));
$this->assertEquals(count($r), 1);
$contents = trim(file_get_contents(dirname(__FILE__) . '/test.log'));
$entries = explode("\n", $contents);
$this->assertEquals(count($entries), 2);
if (file_exists(dirname(__FILE__) . '/test.log')) {
unlink(dirname(__FILE__) . '/test.log');
}
}
示例14: url
/**
* Attach theme paths to a local Url. The Url must be a resource located on the asset path
* of the current theme or it's parents.
*
* @param string $url
* @return string
*/
public function url($url)
{
// return external URLs unmodified
if (preg_match('/^((http(s?):)?\\/\\/)/i', $url)) {
return $url;
}
// Is it on AWS? Dont lookup parent themes...
if (preg_match('/^((http(s?):)?\\/\\/)/i', $this->assetPath)) {
return $this->assetPath . '/' . ltrim($url, '/');
}
// Lookup asset in current's theme asset path
$fullUrl = (empty($this->assetPath) ? '' : '/') . $this->assetPath . '/' . ltrim($url, '/');
if (file_exists($fullPath = public_path($fullUrl))) {
return $fullUrl;
}
// If not found then lookup in parent's theme asset path
if ($this->getParent()) {
return $this->getParent()->url($url);
}
// Asset not found at all. Error handling
$action = \Config::get('themes.asset_not_found', 'LOG_ERROR');
if ($action == 'THROW_EXCEPTION') {
throw new themeException("Asset not found [{$url}]");
} elseif ($action == 'LOG_ERROR') {
\Log::warning("Asset not found [{$url}] in Theme [" . \Theme::get() . "]");
} elseif ($action === 'ASSUME_EXISTS') {
$assetPath = \Theme::find(\Theme::get())->assetPath;
return (empty($assetPath) ? '' : '/') . $assetPath . '/' . ltrim($url, '/');
}
}
示例15: isValidImageFile
/**
* GIF/JPEG/PNG のみ対象
* @param String $filepath
* @return bool
*/
function isValidImageFile($filepath)
{
try {
// WARNING, NOTICE が発生する可能性有り
$img_info = getimagesize($filepath);
switch ($img_info[2]) {
case IMAGETYPE_GIF:
case IMAGETYPE_JPEG:
case IMAGETYPE_PNG:
// getimagesize関数はマジックバイトを見ているだけ
// イメージリソースが生成できるかどうかでファイルの中身を判定する。
// データに問題がある場合、WARNING が発生する可能性有り
if (imagecreatefromstring(file_get_contents($filepath)) !== false) {
return true;
}
}
} catch (\ErrorException $e) {
$err_msg = sprintf("%s(%d): %s (%d) filepath = %s", __METHOD__, $e->getLine(), $e->getMessage(), $e->getCode(), $filepath);
switch ($e->getSeverity()) {
case E_WARNING:
\Log::warning($err_msg);
break;
case E_NOTICE:
\Log::notice($err_msg);
break;
default:
\Log::error($err_msg);
}
}
return false;
}