当前位置: 首页>>代码示例>>PHP>>正文


PHP SS_Log::log方法代码示例

本文整理汇总了PHP中SS_Log::log方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_Log::log方法的具体用法?PHP SS_Log::log怎么用?PHP SS_Log::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SS_Log的用法示例。


在下文中一共展示了SS_Log::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getLocationsByDay

 public function getLocationsByDay(SS_HTTPRequest $request)
 {
     try {
         $query_string = $request->getVars();
         $summit_id = intval($request->param('SUMMIT_ID'));
         $day = strtolower(Convert::raw2sql($query_string['day']));
         $summit = $this->summit_repository->getById($summit_id);
         if (is_null($summit)) {
             throw new NotFoundEntityException('Summit', sprintf(' id %s', $summit_id));
         }
         if (!$summit->isDayBelongs($day)) {
             throw new EntityValidationException(sprintf('day %s does not belongs to summit id %s', $day, $summit_id));
         }
         $response = array('day' => $day, 'summit_id' => intval($summit_id), 'locations' => array());
         foreach ($summit->getTopVenues() as $venue) {
             $class_name = $venue->ClassName;
             if ($class_name != 'SummitVenue' && $class_name != 'SummitExternalLocation' && $class_name != 'SummitHotel') {
                 continue;
             }
             $count = $summit->getPublishedEventsCountByDateLocation($day, $venue);
             array_push($response['locations'], array('id' => intval($venue->ID), 'events_count' => intval($count)));
             if ($class_name == 'SummitVenue') {
                 foreach ($venue->Rooms() as $room) {
                     $count = $summit->getPublishedEventsCountByDateLocation($day, $room);
                     array_push($response['locations'], array('id' => intval($room->ID), 'events_count' => intval($count)));
                 }
             }
         }
         return $this->ok($response);
     } catch (Exception $ex) {
         SS_Log::log($ex->getMessage(), SS_Log::ERR);
         return $this->serverError();
     }
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:34,代码来源:SummitAppLocationsApi.php

示例2: transform

 public function transform($item, $parentObject, $duplicateStrategy)
 {
     $newFile = $this->getTypeForFile($item->Name);
     $folderPath = $parentObject->getRelativePath();
     $parentId = $parentObject ? $parentObject->ID : 0;
     $filter = 'ParentID = \'' . Convert::raw2sql($parentId) . '\' and Title = \'' . Convert::raw2sql($item->Name) . '\'';
     $existing = DataObject::get_one('File', $filter);
     if ($existing && $duplicateStrategy == ExternalContentTransformer::DS_SKIP) {
         // just return the existing children
         return new TransformResult($existing, null);
     } else {
         if ($existing && $duplicateStrategy == ExternalContentTransformer::DS_OVERWRITE) {
             $newFile = $existing;
         }
     }
     //
     $newFile->Name = $item->Name;
     $newFile->Title = $item->Name;
     $newFile->MenuTitle = $item->Name;
     //
     $size = filesize($item->FilePath);
     $details = array('size' => $size, 'name' => $item->Name, 'tmp_name' => $item->FilePath);
     $upload = new FileLoader();
     $folderPath = trim(substr($folderPath, strpos($folderPath, '/')), '/');
     try {
         $upload->loadIntoFile($details, $newFile, $folderPath);
     } catch (ValidationException $ve) {
         // ignore for now, there should really be a proper error reporting mechanism though...
         SS_Log::log("File import failed: " . $ve->getMessage(), SS_Log::WARN);
     }
     return new TransformResult($newFile, null);
 }
开发者ID:nyeholt,项目名称:silverstripe-filesystem-connector,代码行数:32,代码来源:FileSystemFileImporter.php

示例3: addressFromIP

 protected function addressFromIP($ip)
 {
     $geocoder = AddressGeocoding::get_geocoder();
     $geodata = array();
     try {
         if ($ip) {
             $geodata = $geocoder->geocode($ip)->toArray();
         }
     } catch (Exception $e) {
         SS_Log::log($e, SS_Log::ERR);
     }
     $geodata = array_filter($geodata);
     $datamap = array('Country' => 'countryCode', 'County' => 'county', 'State' => 'region', 'PostalCode' => 'zipcode', 'Latitude' => 'latitude', 'Longitude' => 'longitude');
     $mappeddata = array();
     foreach ($datamap as $addressfield => $geofield) {
         if (is_array($geofield)) {
             if ($data = implode(" ", array_intersect_key($geodata, array_combine($geofield, $geofield)))) {
                 $mappeddata[$addressfield] = $data;
             }
         } elseif (isset($geodata[$geofield])) {
             $mappeddata[$addressfield] = $geodata[$geofield];
         }
     }
     return $mappeddata;
 }
开发者ID:burnbright,项目名称:silverstripe-shop-geocoding,代码行数:25,代码来源:GeocodedUserInfo.php

示例4: process

 public function process()
 {
     $post = $this->getObject();
     if ($post) {
         $author = $post->Owner();
         $balance = $author->Balance;
         if (self::$api_key && $post->Content != self::SPAM_CONTENT) {
             require_once Director::baseFolder() . '/microblog/thirdparty/defensio/Defensio.php';
             $defensio = new Defensio(self::$api_key);
             $document = array('type' => 'comment', 'content' => $post->Content, 'platform' => 'silverstripe_microblog', 'client' => 'MicroBlog Defensio-PHP | 0.1 | Marcus Nyeholt | marcus@silverstripe.com.au', 'async' => 'false');
             try {
                 $result = $defensio->postDocument($document);
                 if ($result && isset($result[1])) {
                     if ($result[1]->allow == 'false') {
                         $post->Content = self::SPAM_CONTENT;
                         $post->Down += self::SPAM_DOWN;
                         $post->write();
                         $author->Down += self::SPAM_DOWN;
                         $author->write();
                     }
                 }
             } catch (Exception $e) {
                 SS_Log::log($e, SS_Log::WARN);
             }
         }
         if ($post->Content != self::SPAM_CONTENT) {
             $post->analyseContent();
             $post->write();
         }
     }
     $this->isComplete = true;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-microblog,代码行数:32,代码来源:ProcessPostJob.php

示例5: confirm

 public function confirm()
 {
     parent::init();
     try {
         $token = Session::get('SummitConfirmSpeakerPage.Token');
         if (isset($_REQUEST['t'])) {
             $token = base64_decode($_REQUEST['t']);
             Session::set('SummitConfirmSpeakerPage.Token', $token);
             return $this->redirect($this->Link('confirm'));
         }
         if (empty($token)) {
             throw new InvalidArgumentException('missing token!');
         }
         $request = PresentationSpeakerSummitAssistanceConfirmationRequest::get()->filter('ConfirmationHash', PresentationSpeakerSummitAssistanceConfirmationRequest::HashConfirmationToken($token))->first();
         if (is_null($request)) {
             throw new NotFoundEntityException('PresentationSpeakerSummitAssistanceConfirmationRequest', '');
         }
         if (!$request->alreadyConfirmed()) {
             $request->confirm($token);
             $request->write();
         }
         $data['Speaker'] = $request->Speaker();
         $data['Summit'] = $request->Summit();
         Session::set('Current.PresentationSpeakerSummitAssistanceConfirmationRequest', $request);
         return $this->customise($data)->renderWith(array('SummitConfirmSpeakerPage', 'SummitPage'), $this->parent);
     } catch (Exception $ex) {
         SS_Log::log($ex->getMessage(), SS_Log::WARN);
         return $this->httpError(404, 'Sorry, this speaker confirmation token does not seem to be correct.');
     }
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:30,代码来源:SummitConfirmSpeakerPage.php

示例6: run

 /**
  * @return void
  */
 public function run()
 {
     try {
         $init_time = time();
         $processed_events = 0;
         $events = array();
         $current_summit = Summit::get_active();
         if ($current_summit) {
             $events = $current_summit->getSchedule();
         }
         foreach ($events as $event) {
             $processed_events++;
             $rate_sum = 0;
             $rate_count = 0;
             foreach ($event->Feedback as $feedback) {
                 $rate_count++;
                 $rate_sum = $rate_sum + $feedback->Rate;
             }
             $rate_avg = $rate_count > 0 ? $rate_sum / $rate_count : 0;
             try {
                 $event->setAvgRate(round($rate_avg, 2));
                 $event->write(true);
             } catch (Exception $ex) {
                 SS_Log::log($ex, SS_Log::ERR);
                 echo $ex->getMessage();
             }
         }
         $finish_time = time() - $init_time;
         echo 'processed events ' . $processed_events . ' - time elapsed : ' . $finish_time . ' seconds.';
     } catch (Exception $ex) {
         SS_Log::log($ex->getMessage(), SS_Log::ERR);
     }
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:36,代码来源:SummitEventSetAvgRate.php

示例7: placeOrder

 public function placeOrder(SS_HTTPRequest $request)
 {
     $eventbrite_event_header = $request->getHeader('X-Eventbrite-Event');
     if (!$eventbrite_event_header) {
         return $this->httpError(403);
     }
     if ($eventbrite_event_header !== 'order.placed') {
         return $this->httpError(403);
     }
     if (!$this->isJson()) {
         return $this->httpError(403);
     }
     $json_request = $this->getJsonRequest();
     if (!isset($json_request['config']) || !isset($json_request['api_url'])) {
         return $this->httpError(403);
     }
     $config = $json_request['config'];
     if (!isset($config['action']) || $config['action'] !== 'order.placed') {
         return $this->httpError(403);
     }
     $current_local_url = Controller::join_links(Director::absoluteBaseURL(), $request->getURL());
     if (!isset($config['endpoint_url']) || $config['endpoint_url'] !== $current_local_url) {
         return $this->httpError(403);
     }
     try {
         $this->manager->registerEvent('ORDER_PLACED', $json_request['api_url']);
     } catch (Exception $ex) {
         SS_Log::log($ex->getMessage(), SS_Log::ERR);
         return $this->httpError(500);
     }
     return true;
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:32,代码来源:EventbriteOrderPlacedEndpoint.php

示例8: send

 /** Send the email out to the Recipient */
 public function send($newsletter = null, $recipient = null)
 {
     // fetch from database again to make sure the sent flag is not set yet
     if (!$this->ID || self::get()->byID($this->ID)->Status != 'Sent') {
         if (empty($newsletter)) {
             $newsletter = $this->Newsletter();
         }
         if (empty($recipient)) {
             $recipient = $this->Recipient();
         }
         //check recipient not blacklisted and verified
         if ($recipient && empty($recipient->Blacklisted) && !empty($recipient->Verified)) {
             $email = new NewsLetterEmail($newsletter, $recipient);
             if (!empty($newsletter->ReplyTo)) {
                 $email->addCustomHeader('Reply-To', $newsletter->ReplyTo);
             }
             $success = $email->send();
             if ($success) {
                 $this->Status = 'Sent';
                 $recipient->ReceivedCount = $recipient->ReceivedCount + 1;
             } else {
                 $this->Status = 'Failed';
                 $recipient->BouncedCount = $recipient->BouncedCount + 1;
             }
             $recipient->write();
         } else {
             $this->Status = 'BlackListed';
         }
         $this->write();
     } else {
         SS_Log::log(new Exception("prevented sending of SendRecipientQueue #{$this->ID} because it has already been sent"), SS_Log::ERR);
     }
 }
开发者ID:Zauberfisch,项目名称:silverstripe-newsletter,代码行数:34,代码来源:SendRecipientQueue.php

示例9: run

 function run()
 {
     try {
         $election_input_path = Director::baseFolder() . '/' . ELECTION_VOTERS_INGEST_PATH;
         $files = scandir($election_input_path);
         $manager = new ElectionManager(new SapphireElectionRepository(), new SapphireFoundationMemberRepository(), new SapphireVoteRepository(), new SapphireVoterFileRepository(), new VoteFactory(), new VoterFileFactory(), new ElectionFactory(), SapphireTransactionManager::getInstance());
         foreach ($files as $file_name) {
             if ($this->isCSV($file_name) && (list($election_id, $open_date, $close_date) = $this->isValidElectionFileName($file_name))) {
                 try {
                     echo printf('processing file %s' . PHP_EOL, $file_name);
                     list($count, $not_processed) = $manager->ingestVotersForElection($election_input_path . '/' . $file_name, $election_id, $open_date, $close_date);
                     echo printf('file %s - processed %d rows - not processed %d rows' . PHP_EOL, $file_name, $count, count($not_processed));
                     if (count($not_processed) > 0) {
                         echo 'not processed details ... ' . PHP_EOL;
                         echo var_dump($not_processed) . PHP_EOL;
                     }
                     echo printf('deleting file %s ...' . PHP_EOL, $file_name);
                     unlink($election_input_path . '/' . $file_name);
                 } catch (Exception $ex) {
                     SS_Log::log($ex, SS_Log::ERR);
                     echo $ex->getMessage();
                 }
             }
         }
         return 'OK';
     } catch (Exception $ex) {
         SS_Log::log($ex, SS_Log::ERR);
         echo $ex->getMessage();
     }
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:30,代码来源:VotersDataIngestionTask.php

示例10: sendToSocialMedia

 /**
  *
  * @param array $data
  * @param array $services
  */
 public function sendToSocialMedia(array $data, array $services = array('facebook', 'twitter'))
 {
     // init output
     $ids = array('facebook' => null, 'twitter' => null);
     // Facebook
     if (in_array('facebook', $services) && $this->confirmFacebookAccess()) {
         $facebook = new Facebook(array('appId' => static::$conf->FacebookAppId, 'secret' => static::$conf->FacebookAppSecret));
         $facebook->setAccessToken(static::$conf->FacebookPageAccessToken);
         try {
             $post_id = $facebook->api("/" . static::$conf->FacebookPageId . "/feed", "post", $data);
             $ids['facebook'] = $post_id['id'];
         } catch (FacebookApiException $e) {
             SS_Log::log('Error ' . $e->getCode() . ' : ' . $e->getFile() . ' Line ' . $e->getLine() . ' : ' . $e->getMessage() . "\n" . 'BackTrace: ' . "\n" . $e->getTraceAsString(), SS_Log::ERR);
         }
     }
     // Twitter
     if (in_array('twitter', $services) && $this->confirmTwitterAccess()) {
         $connection = new tmhOAuth(array('consumer_key' => static::$conf->TwitterConsumerKey, 'consumer_secret' => static::$conf->TwitterConsumerSecret, 'user_token' => static::$conf->TwitterOAuthToken, 'user_secret' => static::$conf->TwitterOAuthSecret));
         $tweet = $data['name'] . ": " . $data['link'];
         $code = $connection->request('POST', $connection->url('1.1/statuses/update'), array('status' => $tweet));
         if ($code == 200) {
             $data = json_decode($connection->response['response']);
             $ids['twitter'] = $data->id_str;
         }
     }
     return $ids;
 }
开发者ID:helpfulrobot,项目名称:azt3k-abc-silverstripe-social,代码行数:32,代码来源:PostToSocialMedia.php

示例11: StartSurvey

 function StartSurvey($data, $form)
 {
     try {
         $data = SQLDataCleaner::clean($data);
         $data['MembershipType'] = 'community';
         Session::set("FormInfo.{$form->FormName()}.data", $data);
         $profile_page = EditProfilePage::get()->first();
         $member = $this->member_manager->registerMobile($data, new MemberRegistrationSenderService());
         //Get profile page
         if (!is_null($profile_page)) {
             //Redirect to profile page with success message
             Session::clear("FormInfo.{$form->FormName()}.data");
             $request = Controller::curr()->getRequest();
             $back_url = $request->postVar('BackURL');
             $link = $profile_page->Link('?success=1');
             if (!empty($back_url)) {
                 $link .= "&BackURL=" . $back_url;
             }
             return OpenStackIdCommon::loginMember($member, $link);
         }
     } catch (EntityValidationException $ex1) {
         Form::messageForForm($form->FormName(), $ex1->getMessage(), 'bad');
         //Return back to form
         SS_Log::log($ex1->getMessage(), SS_Log::WARN);
         return Controller::curr()->redirectBack();
     } catch (Exception $ex) {
         Form::messageForForm($form->FormName(), "There was an error with your request, please contact your admin.", 'bad');
         //Return back to form
         SS_Log::log($ex->getMessage(), SS_Log::ERR);
         return Controller::curr()->redirectBack();
     }
 }
开发者ID:hogepodge,项目名称:openstack-org,代码行数:32,代码来源:SurveyRegistrationForm.php

示例12: storeThemeFile

 /**
  * Store the contents of a folder on a CDN. 
  * 
  * If processReferences is set, relative URL references are attempted to be 
  * detected and stored remotely as well, with the file to be stored rewritten 
  * to refer to the CDN value. This really is only useful for CSS 
  *
  * @param string $folder
  * @param boolean $processReferences 
  */
 public function storeThemeFile($toCdn, $file, $forceUpdate = false, $processReferences = false)
 {
     $mtime = @filemtime($file);
     $relativeName = self::CDN_THEME_PREFIX . '/' . $mtime . '/' . trim(str_replace(Director::baseFolder(), '', $file), '/');
     if (!$forceUpdate) {
         // see if the file already exists, if not we do NOT do an update
         $reader = $this->contentService->findReaderFor($toCdn, $relativeName);
         if ($reader && $reader->exists()) {
             return $reader->getURL();
         }
     }
     $clear = false;
     if ($processReferences) {
         $clear = true;
         $file = $this->processFileReferences($toCdn, $file, $forceUpdate);
     }
     // otherwise, lets get a content writer
     $writer = $this->contentService->getWriter($toCdn);
     try {
         $writer->write($file, $relativeName);
     } catch (Exception $e) {
         SS_Log::log($e, SS_Log::WARN);
     }
     if ($clear && strpos($file, '.cdn') > 0) {
         @unlink($file);
     }
     $id = $writer->getContentId();
     return $writer->getReader()->getURL();
 }
开发者ID:stephenmcm,项目名称:silverstripe-cdncontent,代码行数:39,代码来源:ContentDeliveryService.php

示例13: stageChildren

 public function stageChildren($showAll = false)
 {
     $children = new ArrayList();
     $repo = $this->source->getRemoteRepository();
     try {
         if ($repo->isConnected()) {
             $ssId = $this->getSS_ID();
             if (!$ssId) {
                 $ssId = '0';
             }
             $kids = $repo->getChildren(array('ClassName' => ClassInfo::baseDataClass($this->getType()), 'ParentID' => $this->getSS_ID()));
             if (!$kids) {
                 throw new Exception("No kids and null object returned for children of " . $this->getSS_ID());
             }
             // Even though it returns actual dataobjects, we need to wrap them for sanity and safety's sake
             foreach ($kids as $childItem) {
                 $item = $this->source->getObject($childItem);
                 $children->push($item);
             }
         }
     } catch (Exception $fre) {
         SS_Log::log($fre, SS_Log::WARN);
         return $children;
     }
     return $children;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-australia-silverstripe-connector,代码行数:26,代码来源:SilverStripeContentItem.php

示例14: regenerateToken

 /**
  *	Attempt to regenerate the current security token.
  */
 public function regenerateToken()
 {
     // Restrict this functionality to administrators.
     $user = Member::currentUserID();
     if (Permission::checkMember($user, 'ADMIN')) {
         // Attempt to create a random hash.
         $regeneration = $this->service->generateHash();
         if ($regeneration) {
             // Instantiate the new security token.
             $token = APIwesomeToken::create();
             $token->Hash = $regeneration['hash'];
             $token->AdministratorID = $user;
             $token->write();
             // Temporarily use the session to display the new security token key.
             Session::set('APIwesomeToken', "{$regeneration['key']}:{$regeneration['salt']}");
         } else {
             // Log the failed security token regeneration.
             SS_Log::log('APIwesome security token regeneration failed.', SS_Log::ERR);
             Session::set('APIwesomeToken', -1);
         }
         // Determine where the request came from.
         $from = $this->getRequest()->getVar('from');
         $redirect = $from ? $from : 'admin/json-xml/';
         return $this->redirect($redirect);
     } else {
         return $this->httpError(404);
     }
 }
开发者ID:helpfulrobot,项目名称:nglasl-silverstripe-apiwesome,代码行数:31,代码来源:APIwesome.php

示例15: run

 /**
  * @return void
  */
 public function run()
 {
     try {
         $batch_size = 100;
         $init_time = time();
         $summit = null;
         if (isset($_GET['batch_size'])) {
             $batch_size = intval(trim(Convert::raw2sql($_GET['batch_size'])));
             echo sprintf('batch_size set to %s', $batch_size) . PHP_EOL;
         }
         if (isset($_GET['summit_id'])) {
             $summit = Summit::get()->byID(intval($_GET['summit_id']));
         }
         if (is_null($summit)) {
             throw new Exception('summit_id is not valid!');
         }
         $manager = Injector::inst()->get('SpeakerSecondBreakoutAnnouncementSenderManager');
         if (!$manager instanceof ISpeakerSecondBreakoutAnnouncementSenderManager) {
             return;
         }
         $processed = $manager->send($summit, $batch_size);
         $finish_time = time() - $init_time;
         echo 'processed records ' . $processed . ' - time elapsed : ' . $finish_time . ' seconds.';
     } catch (Exception $ex) {
         SS_Log::log($ex->getMessage(), SS_Log::ERR);
     }
 }
开发者ID:hogepodge,项目名称:openstack-org,代码行数:30,代码来源:SpeakerSecondBreakoutEmailSenderTask.php


注:本文中的SS_Log::log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。