本文整理汇总了PHP中Logger::getLogger方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::getLogger方法的具体用法?PHP Logger::getLogger怎么用?PHP Logger::getLogger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logger
的用法示例。
在下文中一共展示了Logger::getLogger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __call
public function __call($method, $args)
{
// If observer enabled
if (!$this->Config || $this->Config->GetFieldByName("IsEnabled")->Value == 0) {
return;
}
$enabled = $this->Config->GetFieldByName("{$method}Notify");
if (!$enabled || $enabled->Value == 0) {
return;
}
$DB = \Scalr::getDb();
// Event name
$name = substr($method, 2);
// Event message
$message = $DB->GetOne("SELECT message FROM events WHERE event_id = ? LIMIT 1", array($args[0]->GetEventID()));
$farm_name = $DB->GetOne("SELECT name FROM farms WHERE id=? LIMIT 1", array($args[0]->GetFarmID()));
// Set subject
if (!$farm_name) {
$this->Mailer->setSubject("{$name} event notification (FarmID: {$args[0]->GetFarmID()})");
} else {
$this->Mailer->setSubject("{$name} event notification (FarmID: {$args[0]->GetFarmID()} FarmName: {$farm_name})");
}
// Set body
$this->Mailer->setMessage($message);
// Send mail
try {
$res = $this->Mailer->send();
} catch (\Exception $e) {
$res = false;
}
if (!$res) {
Logger::getLogger(__CLASS__)->info("Mail sent to '{$this->Config->GetFieldByName("EventMailTo")->Value}'. Result: {$res}");
}
}
示例2: getLogger
/**
* Get Logger instance. Creates if not already created.
*
* @return Logger
*/
protected function getLogger()
{
if (is_null($this->logger)) {
$this->logger = Logger::getLogger('core.SchedulerService');
}
return $this->logger;
}
示例3: getLoggerInstance
/**
* Get Logger instance. Creates if not already created.
*
* @return Logger
*/
protected function getLoggerInstance()
{
if (is_null($this->logger)) {
$this->logger = Logger::getLogger('leave.undeleteLeaveTypeAction');
}
return $this->logger;
}
示例4: execute
public function execute($request)
{
if ($request->isMethod(sfWebRequest::POST)) {
$username = $request->getParameter('txtUsername');
$password = $request->getParameter('txtPassword');
$additionalData = array('timeZoneOffset' => $request->getParameter('hdnUserTimeZoneOffset', 0));
try {
$success = $this->getAuthenticationService()->setCredentials($username, $password, $additionalData);
if ($success) {
$this->getLoginService()->addLogin();
$paramString = $this->_getParameterString($request, true);
//$this->redirect('oauth/authorize'. $paramString);
$url = url_for('oauth/authorize') . $paramString;
$logger = Logger::getLogger('login');
$loggedInUserId = $this->getAuthenticationService()->getLoggedInUserId();
$loggedInUser = $this->getSystemUserService()->getSystemUser($loggedInUserId);
$logger->info($loggedInUserId . ', ' . $loggedInUser->getUserName() . ', ' . $_SERVER['REMOTE_ADDR']);
$this->redirect($url);
} else {
$paramString = $this->_getParameterString($request);
$this->getUser()->setFlash('message', __('Invalid credentials'), true);
$this->redirect('oauth/login' . $paramString);
}
} catch (AuthenticationServiceException $e) {
$this->getUser()->setFlash('message', $e->getMessage(), true);
$paramString = $this->_getParameterString($request);
$this->redirect('oauth/login' . $paramString);
}
}
return sfView::NONE;
}
示例5: removeNodeFromChefServer
private function removeNodeFromChefServer(DBServer $dbServer, $config, $nodeName)
{
$chefSettings = $dbServer->GetFarmRoleObject()->getChefSettings();
$chefServerInfo = $this->db->GetRow("SELECT * FROM services_chef_servers WHERE id=?", array($chefSettings[self::ROLE_CHEF_SERVER_ID]));
$chefServerInfo['auth_key'] = trim($this->getCrypto()->decrypt($chefServerInfo['auth_key'], $this->cryptoKey));
$chefClient = Scalr_Service_Chef_Client::getChef($config->serverUrl, $chefServerInfo['username'], trim($chefServerInfo['auth_key']));
try {
$status = $chefClient->removeNode($nodeName);
if ($status) {
Logger::getLogger(LOG_CATEGORY::FARM)->warn(new FarmLogMessage($dbServer->farmId, sprintf("Chef node '%s' removed from chef server", $nodeName)));
} else {
Logger::getLogger(LOG_CATEGORY::FARM)->error(new FarmLogMessage($dbServer->farmId, sprintf("Unable to remove chef node '%s' from chef server: %s", $nodeName, $status)));
}
} catch (Exception $e) {
Logger::getLogger(LOG_CATEGORY::FARM)->error(new FarmLogMessage($dbServer->farmId, sprintf("Unable to remove chef node '%s' from chef server: %s", $nodeName, $e->getMessage())));
}
try {
$status2 = $chefClient->removeClient($nodeName);
if ($status2) {
Logger::getLogger(LOG_CATEGORY::FARM)->warn(new FarmLogMessage($dbServer->farmId, sprintf("Chef client '%s' removed from chef server", $nodeName)));
} else {
Logger::getLogger(LOG_CATEGORY::FARM)->error(new FarmLogMessage($dbServer->farmId, sprintf("Unable to remove chef client '%s' from chef server: %s", $nodeName, $status2)));
}
} catch (Exception $e) {
Logger::getLogger(LOG_CATEGORY::FARM)->error(new FarmLogMessage($dbServer->farmId, sprintf("Unable to remove chef node '%s' from chef server: %s", $nodeName, $e->getMessage())));
}
}
示例6: __construct
/**
* @param $config
* @key string [name]
* @key string [key]
* @key array [items]
*/
function __construct($config)
{
$this->logger = Logger::getLogger(__CLASS__);
$this->initialConfig = $config;
$this->shm = new Scalr_System_Ipc_Shm($config);
$key = $this->shm->key + 8;
$this->logger->debug(sprintf("Get semaphore (key: 0x%08x)", $key));
$this->sem = sem_get($key, 1, 0666, true);
if (!$this->sem) {
throw new Scalr_System_Ipc_Exception("Cannot sem_get (key: {$key})");
}
if (!sem_acquire($this->sem)) {
throw new Scalr_System_Ipc_Exception("Cannot acquire semaphore");
}
try {
$meta = $this->getMeta();
if ($meta === null) {
$this->clear0();
}
sem_release($this->sem);
} catch (Exception $e) {
sem_release($this->sem);
throw $e;
}
if ($config["items"]) {
foreach ($config["items"] as $item) {
$this->add($item);
}
}
}
示例7: handle
public function handle(EventMessage $event)
{
if ($event instanceof \PAMI\Message\Event\AsyncAGIEvent) {
if ($event->getSubEvent() == 'Start') {
switch ($pid = pcntl_fork()) {
case 0:
$logger = \Logger::getLogger(__CLASS__);
$this->_client = new ClientImpl($this->_pamiOptions);
$this->_client->open();
$agi = new \PAMI\AsyncAgi\AsyncClientImpl(array('pamiClient' => $this->_client, 'asyncAgiEvent' => $event));
$app = new MyPAGIApplication(array('pagiClient' => $agi));
$app->init();
$app->run();
//$agi->indicateProgress();
//$agi->answer();
//$agi->streamFile('welcome');
//$agi->playCustomTones(array("425/50","0/50"));
//sleep(5);
//$agi->indicateCongestion(10);
//$agi->hangup();
$this->_client->close();
echo "Application finished\n";
exit(0);
break;
case -1:
echo "Could not fork application\n";
break;
default:
echo "Forked Application\n";
break;
}
}
}
}
示例8: using
/**
* @static
* @param mixed $resource A resource that needs to be closed, for example a mysql connection
* @param callable $callable (resource) => T Callable method that accepts $resource as parameter
* @param string $close [Optional] Name of close method on $resource
* @return mixed product of $callable (can be null)
* @throws \Exception If resource is null or if there is a problem with the callable
*/
public static function using($resource, $callable, $close = 'close')
{
if (!$resource) {
throw new \InvalidArgumentException('Cannot loan a null resource');
}
$logger = \Logger::getLogger(__CLASS__);
$problem = null;
$result = null;
try {
$result = $callable($resource);
$logger->debug('Successfully executed callable on resource');
} catch (\Exception $e) {
$logger->warn('Problem encountered using resource', $e);
$problem = $e;
}
try {
$resource->{$close}();
$logger->debug('Successfully closed resource');
} catch (\Exception $e) {
$logger->warn('Problem encountered closing resource', $e);
if ($problem) {
$problem = new CompoundException($e->getMessage(), $e->getCode(), $problem);
} else {
// PHP has no built in support for re-throwing, so we explicitly do so
throw $e;
}
}
if ($problem) {
throw $problem;
}
return $result;
}
示例9: getLogger
/**
* Get Logger instance
* @return Logger
*/
public function getLogger()
{
if (empty($this->logger)) {
$this->logger = Logger::getLogger('leave.leavemailer');
}
return $this->logger;
}
示例10: __construct
/**
* @param $config
* @key string $jobDir
* @key string $clsSuffix
* @key string $clsNamespace
* @key bool $oldSyntax (default true)
* TODO: add $getopt key
* TODO: support new syntax: php -q cron.php [options] task
*/
function __construct($config)
{
foreach ($config as $k => $v) {
$this->{$k} = $v;
}
$this->logger = Logger::getLogger(__CLASS__);
}
示例11: __construct
function __construct($bridge, $version)
{
$this->bridge = $bridge;
$this->version = $version;
$this->defaultCharset = 'utf-8';
$this->logger = Logger::getLogger(__CLASS__);
}
示例12: __construct
/**
* Constructor
* @ignore
*/
function __construct()
{
$this->Logger = Logger::getLogger('SignalHandler');
if (!function_exists("pcntl_signal")) {
self::RaiseError("Function pcntl_signal() not found. PCNTL must be enabled in PHP.", E_ERROR);
}
}
示例13: getUserRoleManager
public function getUserRoleManager()
{
$logger = Logger::getLogger('core.UserRoleManagerService');
$class = $this->getUserRoleManagerClassName();
$manager = null;
if (class_exists($class)) {
try {
$manager = new $class();
} catch (Exception $e) {
throw new ServiceException('Exception when initializing user role manager:' . $e->getMessage());
}
} else {
throw new ServiceException('User Role Manager class ' . $class . ' not found.');
}
if (!$manager instanceof AbstractUserRoleManager) {
throw new ServiceException('User Role Manager class ' . $class . ' is not a subclass of AbstractUserRoleManager');
}
// Set System User object in manager
$userId = $this->getAuthenticationService()->getLoggedInUserId();
$systemUser = $this->getSystemUserService()->getSystemUser($userId);
if ($systemUser instanceof SystemUser) {
$manager->setUser($systemUser);
} else {
if ($logger->isInfoEnabled()) {
$logger->info('No logged in system user when creating UserRoleManager');
}
}
return $manager;
}
示例14: __construct
public function __construct($fieldsAndValues)
{
$logger = Logger::getLogger('NounRoot.__construct');
$logger->debug("new NounRoot");
parent::__construct($fieldsAndValues);
$logger->debug("new NounRoot, apr�s parent::__construct");
$this->number = $fieldsAndValues['number'];
if ($this->number == NULL || $this->number == '') {
$this->number = 's';
}
$this->cf = $fieldsAndValues['cf'];
if ($this->cf != NULL && $this->cf != '') {
$this->cfs = explode(' ', $this->cf);
}
$this->dialect = $fieldsAndValues['dialect'];
$this->source = $fieldsAndValues['source'];
if ($this->source == NULL || $this->source == '') {
$this->source = 'A2';
}
$this->sources = explode(' ', $this->source);
// Racine de composition pour les racines duelles et plurielles
$this->compositionRoot = $fieldsAndValues['compositionRoot'];
$this->morphemeID = self::make_id($fieldsAndValues);
$logger->debug("new NounRoot, exit");
}
示例15: Save
public function Save(Location $location)
{
try {
$SQL = self::$INSERT;
if ($location->getSeq() != null && $location->getSeq() != "" && $location->getSeq() > 0) {
$SQL = self::$UPDATE;
}
$conn = self::$db->getConnection();
$stmt = $conn->prepare($SQL);
$stmt->bindValue(':name', $location->getLocationName());
$stmt->bindValue(':locationfolder', $location->getLocationFolder());
$stmt->bindValue(':details', $location->getLocationDetails());
$isPrivate = 0;
if ($location->getIsPrivate() == true || $location->getIsPrivate() == 1) {
$isPrivate = 1;
}
$stmt->bindValue(':hasdirectory', $location->getHasDirectory());
$stmt->bindValue(':isprivate', $isPrivate);
if ($SQL == self::$UPDATE) {
$stmt->bindValue(':locationSeq', $location->getSeq());
}
$stmt->execute();
$error = $stmt->errorInfo();
if ($error[2] != "") {
throw new Exception($error[2]);
}
} catch (Exception $e) {
$logger = Logger::getLogger($ConstantsArray["logger"]);
$logger->error("Error During Save Location : - " . $e->getMessage());
}
//I will be put code here for throw exception and show on the screen
}