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


PHP CRM_Core_Error::createDebugLogger方法代码示例

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


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

示例1: checkLogFileIsNotAccessible

 /**
  * Check if our logfile is directly accessible.
  *
  * Per CiviCRM default the logfile sits in a folder which is
  * web-accessible, and is protected by a default .htaccess
  * configuration. If server config causes the .htaccess not to
  * function as intended, there may be information disclosure.
  *
  * The debug log may be jam-packed with sensitive data, we don't
  * want that.
  *
  * Being able to be retrieved directly doesn't mean the logfile
  * is browseable or visible to search engines; it means it can be
  * requested directly.
  *
  * @return array
  *   Array of messages
  * @see CRM-14091
  */
 public function checkLogFileIsNotAccessible()
 {
     $messages = array();
     $config = CRM_Core_Config::singleton();
     $log = CRM_Core_Error::createDebugLogger();
     $log_filename = str_replace('\\', '/', $log->_filename);
     $filePathMarker = $this->getFilePathMarker();
     // Hazard a guess at the URL of the logfile, based on common
     // CiviCRM layouts.
     if ($upload_url = explode($filePathMarker, $config->imageUploadURL)) {
         $url[] = $upload_url[0];
         if ($log_path = explode($filePathMarker, $log_filename)) {
             // CRM-17149: check if debug log path includes $filePathMarker
             if (count($log_path) > 1) {
                 $url[] = $log_path[1];
                 $log_url = implode($filePathMarker, $url);
                 $headers = @get_headers($log_url);
                 if (stripos($headers[0], '200')) {
                     $docs_url = $this->createDocUrl('checkLogFileIsNotAccessible');
                     $msg = 'The <a href="%1">CiviCRM debug log</a> should not be downloadable.' . '<br />' . '<a href="%2">Read more about this warning</a>';
                     $messages[] = new CRM_Utils_Check_Message(__FUNCTION__, ts($msg, array(1 => $log_url, 2 => $docs_url)), ts('Security Warning'), \Psr\Log\LogLevel::WARNING, 'fa-lock');
                 }
             }
         }
     }
     return $messages;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:46,代码来源:Security.php

示例2: testMixLog

 /**
  * We have two coding conventions for writing to log. Make sure that they work together.
  *
  * This tests a theory about what caused CRM-10766.
  */
 function testMixLog()
 {
     CRM_Core_Error::debug_log_message("static-1");
     $logger = CRM_Core_Error::createDebugLogger();
     CRM_Core_Error::debug_log_message("static-2");
     $logger->info('obj-1');
     CRM_Core_Error::debug_log_message("static-3");
     $logger->info('obj-2');
     CRM_Core_Error::debug_log_message("static-4");
     $logger2 = CRM_Core_Error::createDebugLogger();
     $logger2->info('obj-3');
     CRM_Core_Error::debug_log_message("static-5");
     $this->assertLogRegexp('/static-1.*static-2.*obj-1.*static-3.*obj-2.*static-4.*obj-3.*static-5/s');
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:19,代码来源:ErrorTest.php

示例3: checkLogFileIsNotAccessible

 /**
  * Check if our logfile is directly accessible.
  *
  * Per CiviCRM default the logfile sits in a folder which is
  * web-accessible, and is protected by a default .htaccess
  * configuration. If server config causes the .htaccess not to
  * function as intended, there may be information disclosure.
  *
  * The debug log may be jam-packed with sensitive data, we don't
  * want that.
  *
  * Being able to be retrieved directly doesn't mean the logfile
  * is browseable or visible to search engines; it means it can be
  * requested directly.
  *
  * @return array of messages
  * @see CRM-14091
  */
 public function checkLogFileIsNotAccessible()
 {
     $messages = array();
     $config = CRM_Core_Config::singleton();
     $log = CRM_Core_Error::createDebugLogger();
     $log_filename = $log->_filename;
     $filePathMarker = $this->getFilePathMarker();
     // Hazard a guess at the URL of the logfile, based on common
     // CiviCRM layouts.
     if ($upload_url = explode($filePathMarker, $config->imageUploadURL)) {
         $url[] = $upload_url[0];
         if ($log_path = explode($filePathMarker, $log_filename)) {
             $url[] = $log_path[1];
             $log_url = implode($filePathMarker, $url);
             $docs_url = $this->createDocUrl('checkLogFileIsNotAccessible');
             if ($log = @file_get_contents($log_url)) {
                 $msg = 'The <a href="%1">CiviCRM debug log</a> should not be downloadable.' . '<br />' . '<a href="%2">Read more about this warning</a>';
                 $messages[] = ts($msg, array(1 => $log_url, 2 => $docs_url));
             }
         }
     }
     return $messages;
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:41,代码来源:Security.php

示例4: getTaskContext

 /**
  * @return CRM_Queue_TaskContext
  */
 protected function getTaskContext()
 {
     if (!is_object($this->taskCtx)) {
         $this->taskCtx = new CRM_Queue_TaskContext();
         $this->taskCtx->queue = $this->queue;
         // $this->taskCtx->log = CRM_Core_Config::getLog();
         $this->taskCtx->log = CRM_Core_Error::createDebugLogger();
     }
     return $this->taskCtx;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:13,代码来源:Runner.php

示例5: testDebugLoggerFormat

 /**
  * Check that a debugger is created and there is no error when passing in a prefix.
  *
  * Do some basic content checks.
  */
 public function testDebugLoggerFormat()
 {
     $log = CRM_Core_Error::createDebugLogger('my-test');
     $log->log('Mary had a little lamb');
     $log->log('Little lamb');
     $config = CRM_Core_Config::singleton();
     $fileContents = file_get_contents($log->_filename);
     $this->assertEquals($config->configAndLogDir . 'CiviCRM.' . 'my-test.' . CRM_Core_Error::generateLogFileHash($config) . '.log', $log->_filename);
     // The 5 here is a bit arbitrary - on my local the date part is 15 chars (Mar 29 05:29:16) - but we are just checking that
     // there are chars for the date at the start.
     $this->assertTrue(strpos($fileContents, '[info] Mary had a little lamb') > 10);
     $this->assertContains('[info] Little lamb', $fileContents);
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:18,代码来源:ErrorTest.php


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