本文整理汇总了PHP中sfLogger类的典型用法代码示例。如果您正苦于以下问题:PHP sfLogger类的具体用法?PHP sfLogger怎么用?PHP sfLogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sfLogger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: depp_prioritiser
/**
* Return the HTML code for an unordered list showing opinions that can be voted (no AJAX)
* If the user has already voted, then a message appears
*
* @param BaseObject $object Propel object instance to vote
* @param string $message a message string to be displayed in the voting-message block
* @param array $options Array of HTML options to apply on the HTML list
* @return string
**/
function depp_prioritiser($object, $message = '', $options = array())
{
if (is_null($object)) {
sfLogger::getInstance()->debug('A NULL object cannot be prioritised');
return '';
}
$user_id = sfContext::getInstance()->getUser()->getId();
try {
$options = _parse_attributes($options);
if (!isset($options['id'])) {
$options = array_merge($options, array('id' => 'prioritising-items'));
}
$object_id = $object->getPrioritisableReferenceKey();
$list_content = '';
$object_priority = is_null($object->getPriorityValue()) ? 1 : $object->getPriorityValue();
for ($i = $object->allowsNullPriority() ? 0 : 1; $i <= $object->getMaxPriority(); $i++) {
if ($object_priority == $i) {
if ($object->getPriorityLastUser() != 0) {
$label = sprintf('Priorità impostata da user_id:%d il %s alle %s', $object->getPriorityLastUser(), $object->getPriorityLastUpdate('d/m/Y'), $object->getPriorityLastUpdate('h:i'));
} else {
$label = 'Priorità di default';
}
$list_content .= content_tag('li', content_tag('span', $i, array('title' => $label)), array('class' => 'current'));
} else {
$label = sprintf(__('Set priority to %d'), $i);
$list_content .= content_tag('li', link_to($i, sprintf('deppPrioritising/prioritise?object_id=%d&object_model=%s&priority=%d', $object->getId(), get_class($object), $i), array('title' => $label, 'post' => true)));
}
}
return content_tag('ul', $list_content, $options) . content_tag('div', $message, array('id' => 'priority-message'));
} catch (Exception $e) {
sfLogger::getInstance()->err('Exception catched from deppPrioritising helper: ' . $e->getMessage());
}
}
示例2: highlight
public static function highlight($raw_body)
{
$body = sfMarkdown::doConvert($raw_body);
$matches = array();
$langs = array();
preg_match_all("/<pre><code>\\[(\\w*)\\](\\r?\\n)+(.+)(\\r?\\n)+<\\/code><\\/pre>/isU", $body, $matches, PREG_SET_ORDER);
if (sizeof($matches) > 0) {
$service = new SnippetServiceClient();
$cnt = 1;
foreach ($matches as $match) {
sfLogger::getInstance()->info("From myUtils: " . $match[3]);
$languageLower = $match[1];
$languageUpper = strtoupper($match[1]);
sfLogger::getInstance()->info("myUtils languages: {$languageLower} {$languageUpper}" . sizeof(self::$languages));
if (in_array($languageUpper, self::$languages)) {
$highlighted = $service->highlight($languageUpper, htmlspecialchars_decode($match[3]));
$highlighted['snippet'] = "<div class=\"code-wrapper\">{$highlighted['snippet']}</div>";
$body = str_replace($match[0], $highlighted['snippet'], $body, $cnt);
$langs[$languageLower] = $langs[$languageLower] ? $langs[$languageLower] + 1 : 1;
} else {
sfLogger::getInstance()->info("myUtils : {$languageLower} is not supported.");
$langs[$languageLower] = $langs[$languageLower] ? $langs[$languageLower] + 1 : 1;
$body = str_replace($match[0], "<div class=\"code-wrapper\"><pre><code>{$match[3]}</code></pre></div>", $body, $cnt);
}
}
}
return array('body' => $body, 'langs' => $langs);
}
示例3: depp_omnibus_selector
/**
* Return the HTML code for an unordered list showing opinions that can be voted (no AJAX)
* If the user has already voted, then a message appears
*
* @param BaseObject $object Propel object instance to vote
* @param string $message a message string to be displayed in the voting-message block
* @param array $options Array of HTML options to apply on the HTML list
* @return string
**/
function depp_omnibus_selector($object, $message = '', $options = array())
{
if (is_null($object)) {
sfLogger::getInstance()->debug('A NULL object cannot be flagged as Omnibus');
return '';
}
$user_id = sfContext::getInstance()->getUser()->getId();
try {
$options = _parse_attributes($options);
if (!isset($options['id'])) {
$options = array_merge($options, array('id' => 'omnibus-flag'));
}
$object_is_omnibus = $object->getIsOmnibus();
$object_will_be_omnibus = !$object_is_omnibus;
$selector = '';
if ($object_is_omnibus) {
$status = "Questo atto è Omnibus";
$label = "Marcalo come non-Omnibus";
} else {
$status = "Questo atto non è Omnibus";
$label = "Marcalo come Omnibus";
}
$selector .= link_to($label, sprintf('atto/setOmnibusStatus?id=%d&status=%d', $object->getId(), $object_will_be_omnibus), array('post' => true));
return content_tag('div', $status) . content_tag('div', $selector, $options);
} catch (Exception $e) {
sfLogger::getInstance()->err('Exception catched from deppOmnibus helper: ' . $e->getMessage());
}
}
示例4: executePrioritise
/**
* <p>Vote a propel object, un-ajax style</p>
*
* @see deppPropelActAsVotableBehavior API
*/
public function executePrioritise()
{
try {
if ($this->getRequest()->getMethod() !== sfRequest::POST) {
$this->setError($this->messages['post_only']);
}
// Retrieve parameters from request
$object_id = $this->getRequestParameter('object_id');
$object_model = $this->getRequestParameter('object_model');
$priority = $this->getRequestParameter('priority');
// Retrieve ratable propel object
if (is_null($priority) || is_null($object_id) || is_null($object_model)) {
$this->setError($this->messages['missing_params']);
}
$object = deppPropelActAsPrioritisableBehaviorToolkit::retrievePrioritisableObject($object_model, $object_id);
if (is_null($object)) {
$this->setError($this->message['prioritisable_error']);
}
// User retrieval
$user_id = sfContext::getInstance()->getUser()->getId();
if (!$object->allowsNullPriority() && $priority == 0) {
$msg = $this->messages['null_not_allowed'];
sfLogger::getInstance()->warning($msg);
$this->setError($msg);
} else {
$object->setPriorityValue((int) $priority, $user_id);
$message = $this->messages['thank_you'];
}
$this->setFlash('depp_prioritising_message', $message);
$this->redirect($this->getRequest()->getReferer());
} catch (Exception $e) {
$this->setError($e->getMessage());
}
}
示例5: convertLogPriority
/**
* Converts the log priority into its string representation.
*
* @param sfEvent $event
* @param array $logEntry
*
* @return array
*/
public static function convertLogPriority(sfEvent $event, array $logEntry)
{
if (is_int($logEntry['priority'])) {
$logEntry['priority'] = sfLogger::getPriorityName($logEntry['priority']);
}
return $logEntry;
}
示例6: execute
public function execute($filterChain)
{
$filterChain->execute();
$response = $this->getContext()->getResponse();
$request = $this->getContext()->getRequest();
$controller = $this->getContext()->getController();
// don't highlight:
// * for XHR requests
// * if 304
// * if not rendering to the client
// * if HTTP headers only
if ($request->isXmlHttpRequest() || strpos($response->getContentType(), 'html') === false || $response->getStatusCode() == 304 || $controller->getRenderMode() != sfView::RENDER_CLIENT || $response->isHeaderOnly()) {
return;
}
$timer = sfTimerManager::getTimer('Highlight Filter');
try {
if (!$this->highlight()) {
$this->removeNotice();
}
} catch (sfSolrHighlighterException $e) {
sfLogger::getInstance()->err('{sfSolrHighlightFilter} silently ignoring exception: ' . $e->getMessage());
if ($this->testMode) {
$timer->addTime();
throw $e;
}
} catch (Exception $e) {
$timer->addTime();
throw $e;
}
$timer->addTime();
}
示例7: signIn
/**
* uses information in the $xml_user SimpleXML object to give attributes and permissions to the user
* also sets remember or sso cookie, depending on the value of the $remember parameter
*
* @param $xml_user - SimpleXMLObject
* @param $cookie - boolean
* @return void
* @author Guglielmo Celata
**/
public function signIn($xml_user, $cookie = 'none')
{
// legge i permission dall'xml user
$permissions = array();
foreach ($xml_user->permissions->permission as $perm) {
$permissions[] = $perm;
}
$this->setAttribute('subscriber_id', (string) $xml_user->subscriber_id, 'subscriber');
$this->setAuthenticated(true);
$expiration_age = sfConfig::get('app_cookies_remember_key_expiration_age', 15 * 24 * 3600);
$cookie_remember_name = sfConfig::get('app_cookies_remember_name', 'sfRemember');
$cookie_sso_name = sfConfig::get('app_cookies_sso_name', 'sfSSO');
$cookie_path = sfConfig::get('app_cookies_path', '/');
$cookie_domain = sfConfig::get('app_cookies_domain', 'sfDomain.it');
// if cookie argument was set to 'remember' or 'session' a cookie is set
// this MUST only happen with signin invoked from validator (form)
sfContext::getInstance()->getLogger()->info('xxx - signIn - cookie: ' . $cookie);
if ($cookie == 'remember') {
//save the key to the remember cookie
sfContext::getInstance()->getLogger()->info('xxx - setting remember cookie: ' . (string) $xml_user->remember_key);
sfContext::getInstance()->getResponse()->setCookie($cookie_remember_name, (string) $xml_user->remember_key, time() + $expiration_age, $cookie_path, $cookie_domain);
} elseif ($cookie == 'session') {
// save the hash to the sso cookie
sfContext::getInstance()->getLogger()->info('xxx - setting sso cookie: ' . (string) $xml_user->remember_key);
sfContext::getInstance()->getResponse()->setCookie($cookie_sso_name, (string) $xml_user->remember_key, 0, $cookie_path, $cookie_domain);
}
$this->addCredential('subscriber');
if (in_array('moderatore', $permissions)) {
$this->addCredential('moderator');
}
if (in_array('amministratore', $permissions)) {
$this->addCredential('moderator');
$this->addCredential('administrator');
}
// add all credentials from groups and direct permissions
foreach ($permissions as $perm) {
$this->addCredential((string) $perm);
}
$this->setAttribute('name', (string) $xml_user->name, 'subscriber');
$this->setAttribute('firstname', (string) $xml_user->firstname, 'subscriber');
$this->setAttribute('hash', (string) $xml_user->hash, 'subscriber');
// read the last_login ts from the xml (it comes from the DB)
$this->setAttribute('last_login', (string) $xml_user->last_login, 'subscriber');
// store the new last_login ts (now) in the DB
$remote_guard_host = sfConfig::get('sf_remote_guard_host', 'op_accesso.openpolis.it');
$script = str_replace('fe', 'be', sfContext::getInstance()->getRequest()->getScriptName());
if ($script == '/be.php') {
$script = '/index.php';
}
$apikey = sfConfig::get('sf_internal_api_key', 'xxx');
$last_login_url = sprintf("http://%s%s/setLastLogin/%s/%s/%s", $remote_guard_host, $script, $apikey, (string) $xml_user->hash, urlencode(date('Y-m-d H:i:s')));
sfLogger::getInstance()->info('xxx: last_login_call: ' . $last_login_url);
$xml = simplexml_load_file($last_login_url);
if (!$xml->ok instanceof SimpleXMLElement) {
sfLogger::getInstance()->info('xxx: error while setting last login: %s' . (string) $xml->error);
}
}
示例8: getPreference
public function getPreference($preference)
{
if ($item = $this->getAttribute("app_preference_{$preference}")) {
return $item;
}
$item = sfConfig::get("app_preference_{$preference}");
sfLogger::getInstance()->info("Sending default preference for app_preference_{$preference}={$item}");
return $item;
}
示例9: getInstance
/**
* Returns the sfLogger instance.
*
* @return object the sfLogger instance
*/
public static function getInstance()
{
if (!sfLogger::$logger) {
// the class exists
$class = __CLASS__;
sfLogger::$logger = new $class();
sfLogger::$logger->initialize();
}
return sfLogger::$logger;
}
示例10: __construct
/**
* Class constructor.
*
* @param string The error message
* @param int The error code
*/
public function __construct($message = null, $code = 0)
{
if ($this->getName() === null) {
$this->setName('sfException');
}
parent::__construct($message, $code);
if (sfConfig::get('sf_logging_enabled') && $this->getName() != 'sfStopException') {
sfLogger::getInstance()->err('{' . $this->getName() . '} ' . $message);
}
}
示例11: getLogger
private static function getLogger()
{
if (!self::$logger) {
if (class_exists('sfLogger')) {
self::$logger = sfLogger::getInstance();
} else {
self::$logger = KalturaLog::getInstance();
}
}
return self::$logger;
}
示例12: execute
/**
* Action permettant de récupérer l'arbre des jeux de données.
*
* @param sfWebRequest $request
*/
public function execute($request)
{
$this->logger = sfContext::getInstance()->getLogger();
$this->logger->info("----------------------------------------------------------");
$this->logger->info("--- DEBUT RECUPERATION ARBRE DATA SET");
$this->getResponse()->setContentType('application/json');
$this->setLayout(false);
try {
$this->getUser()->signIn($this->user, true);
/** @var EiNodeTable $tableEiNode */
$tableEiNode = Doctrine_Core::getTable("EiNode");
// Récupération du noeud du scénario.
$node = $this->scenario->getEiNode();
// Recherche de la structure des fichiers des jeux de données.
$rootFolder = Doctrine_Core::getTable('EiNode')->findOneByRootIdAndType($node->getId(), 'EiDataSetFolder');
// On récupère ensuite la structure brute des dossiers.
$structureBrute = $tableEiNode->getStructureDataSets($rootFolder);
$structureBrute["root"]["name"] = "Root";
// Puis on la retravaille.
// $structure = $this->getReorderedStructure(array(), $structureBrute);
$response = json_encode(array("tree" => array($structureBrute)));
} catch (Exception $e) {
$response = array();
}
return $this->renderText($response);
}
示例13: save
/**
* Surcharge de la méthode save permettant de mettre à jour la table EiNode.
*
* @param Doctrine_Connection $conn
*/
public function save(Doctrine_Connection $conn = null)
{
$this->logger = sfContext::getInstance()->getLogger();
$this->logger->info("----------------------------------------------------------");
$this->logger->info("--- DEBUT SAUVEGARDE TEMPLATE");
$isNew = $this->isNew();
/** @var EiNode $ei_node */
if ($isNew) {
if ($this->getEiNode() == null) {
$ei_node = new EiNode();
$this->setEiNode($ei_node);
} else {
$ei_node = $this->getEiNode();
}
}
parent::save($conn);
if ($isNew) {
$ei_node->setType(EiNode::$TYPE_DATASET_TEMPLATE);
$ei_node->setObjId($this->getId());
$ei_node->setName($this->getName());
$ei_node->save($conn);
} elseif (!$isNew) {
$ei_node = $this->getEiNode();
$ei_node->setName($this->getName());
$ei_node->save($conn);
}
$this->updateCampaignGraphDataSet($conn);
$this->logger->info("----------------------------------------------------------");
$this->logger->info("--- FIN SAUVEGARDE TEMPLATE");
}
示例14: initialize
public function initialize(sfEventDispatcher $dispatcher, $options = array())
{
parent::initialize($dispatcher, $options);
$ops = array_merge($this->defaults, $options);
$this->r = new Redis($ops['host'], $ops['port']);
$this->maxlogs = $ops['maxlogs'];
}
示例15: save
/**
* @param Doctrine_Connection $conn
*/
public function save(Doctrine_Connection $conn = null)
{
$this->logger = sfContext::getInstance()->getLogger();
$this->logger->info("----------------------------------------------------------");
$this->logger->info("--- DEBUT SAUVEGARDE DATA SET");
$isNew = $this->isNew();
if ($isNew) {
if ($this->getEiNode() == null) {
$ei_node = new EiNode();
$this->setEiNode($ei_node);
} else {
$ei_node = $this->getEiNode();
}
}
parent::save($conn);
if ($isNew) {
$ei_node->setType('EiDataSet');
$ei_node->setObjId($this->getId());
$ei_node->setName($this->getName());
if ($this->getEiDataSetTemplate() != null) {
$ei_node->setRootId($this->getEiDataSetTemplate()->getEiNode()->getId());
}
$ei_node->save($conn);
} else {
$ei_node = $this->getEiNode();
$ei_node->setName($this->getName());
$ei_node->save($conn);
}
$this->logger->info("----------------------------------------------------------");
$this->logger->info("--- FIN SAUVEGARDE DATA SET");
}