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


PHP Kohana::log_directory方法代码示例

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


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

示例1: remove_old_logs

 /**
  * Deletes old log files older than # days defined in config
  */
 public function remove_old_logs()
 {
     $days_old = Kohana::config('config.log_cleanup_days_old');
     // First check if we should even be doing this
     if ($days_old == FALSE or !is_int($days_old)) {
         return FALSE;
     }
     $dir = Kohana::log_directory();
     if (is_dir($dir) and is_writable($dir) and $dh = opendir($dir)) {
         $oldest_allowed = date('Y-m-d', mktime(0, 0, 0, date("m"), date("d") - $days_old, date("Y")));
         while (($file = readdir($dh)) !== false) {
             // If it's a hidden or system file, skip it
             if ($file[0] == '.') {
                 continue;
             }
             // Strip off the file extension so we can just evaluate the date
             $date = str_ireplace('.log' . EXT, '', $file);
             if ($date <= $oldest_allowed) {
                 // This file needs to be deleted.
                 unlink($dir . $file);
             }
         }
         closedir($dh);
     }
     //$filename = $dir.date('Y-m-d').'.log'.EXT;
     //var_dump($filename);
 }
开发者ID:Dirichi,项目名称:Ushahidi_Web,代码行数:30,代码来源:s_cleanup.php

示例2: submitReport

 protected function submitReport($report)
 {
     $valid = TRUE;
     $validation = Bluebox_Controller::$validation;
     if (empty($report['issue'])) {
         $validation->add_error('report[issue]', 'Please describe the issue');
         $valid = FALSE;
     }
     if (empty($report['while'])) {
         $validation->add_error('report[while]', 'Please describe the cause');
         $valid = FALSE;
     }
     if (empty($report['contact'])) {
         $validation->add_error('report[contact]', 'Please provide a method to contact you');
         $valid = FALSE;
     }
     if (empty($report['error'])) {
         $validation->add_error('report[error]', 'Please provide the error message');
         $valid = FALSE;
     }
     if (!$valid) {
         return FALSE;
     }
     if (!empty($report['log'])) {
         $filename = Kohana::log_directory() . date('Y-m-d') . '.log' . EXT;
         $offset = -150 * 120;
         $rs = @fopen($filename, 'r');
         $report['log'] = '';
         if ($rs !== FALSE) {
             fseek($rs, $offset, SEEK_END);
             fgets($rs);
             while (!feof($rs)) {
                 $buffer = fgets($rs);
                 $report['log'] .= htmlspecialchars($buffer . "\n");
             }
             fclose($rs);
         }
     }
     $allowStats = Kohana::config('core.anonymous_statistics');
     if (!empty($allowStats)) {
         $report['anonymous_id'] = Kohana::config('core.anonymous_id');
         Package_Catalog::disableRemote();
         Package_Catalog::buildCatalog();
         $report['catalog'] = Package_Catalog::getPackageList();
     }
     try {
         $errorCollector = Kohana::config('errorreporter.collector');
         $this->do_post_request($errorCollector, $report);
     } catch (Exception $e) {
         message::set($e->getMessage());
         $this->returnQtipAjaxForm(NULL);
         return FALSE;
     }
     return TRUE;
 }
开发者ID:swk,项目名称:bluebox,代码行数:55,代码来源:errorreporter.php

示例3: log_rotate

 /**
  * Implements the deletion of old logs if the indicia.log_rotate config item exists
  * @throws \Kohana_Exception
  */
 public static function log_rotate()
 {
     $rotate_days = Kohana::config('indicia.log_rotate', FALSE, FALSE);
     if ($rotate_days) {
         $filename = Kohana::log_directory() . date('Y-m-d') . '.log' . EXT;
         if (!is_file($filename)) {
             // writing the first message today, so we can go back and delete log files over a certain age
             $files = glob(Kohana::log_directory() . "*");
             $now = time();
             foreach ($files as $file) {
                 if (is_file($file) && $now - filemtime($file) >= 60 * 60 * 24 * $rotate_days) {
                     unlink($file);
                 }
             }
         }
     }
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:21,代码来源:init.php

示例4: changeDebugLevel

 public static function changeDebugLevel($new_level = NULL)
 {
     // If the users debug_level is valid then update our threshold and
     // re-init the kohana logger so it takes the new settings
     if ($new_level <= 4 and $new_level >= 0) {
         $old_level = Kohana::config('core.log_threshold');
         Kohana::config_set('core.log_threshold', $new_level);
         Kohana::log_directory(Kohana::config('core.log_directory'));
         register_shutdown_function(array('Kohana', 'log_save'));
         Event::run('bluebox.change_debug_level', $new_level);
         return TRUE;
     }
     return FALSE;
 }
开发者ID:swk,项目名称:bluebox,代码行数:14,代码来源:users.php


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