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


PHP rcube_utils::date_format方法代码示例

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


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

示例1: write_log

 /**
  * Append a line to a logfile in the logs directory.
  * Date will be added automatically to the line.
  *
  * @param string $name Name of the log file
  * @param mixed  $line Line to append
  */
 public static function write_log($name, $line)
 {
     if (!is_string($line)) {
         $line = var_export($line, true);
     }
     $date_format = $log_driver = $session_key = null;
     if (self::$instance) {
         $date_format = self::$instance->config->get('log_date_format');
         $log_driver = self::$instance->config->get('log_driver');
         $session_key = intval(self::$instance->config->get('log_session_id', 8));
     }
     $date = rcube_utils::date_format($date_format);
     // trigger logging hook
     if (is_object(self::$instance) && is_object(self::$instance->plugins)) {
         $log = self::$instance->plugins->exec_hook('write_log', array('name' => $name, 'date' => $date, 'line' => $line));
         $name = $log['name'];
         $line = $log['line'];
         $date = $log['date'];
         if ($log['abort']) {
             return true;
         }
     }
     // add session ID to the log
     if ($session_key > 0 && ($sess = session_id())) {
         $line = '<' . substr($sess, 0, $session_key) . '> ' . $line;
     }
     if ($log_driver == 'syslog') {
         $prio = $name == 'errors' ? LOG_ERR : LOG_INFO;
         syslog($prio, $line);
         return true;
     }
     // log_driver == 'file' is assumed here
     $line = sprintf("[%s]: %s\n", $date, $line);
     $log_dir = null;
     // per-user logging is activated
     if (self::$instance && self::$instance->config->get('per_user_logging', false) && self::$instance->get_user_id()) {
         $log_dir = self::$instance->get_user_log_dir();
         if (empty($log_dir)) {
             return false;
         }
     } else {
         if (!empty($log['dir'])) {
             $log_dir = $log['dir'];
         } else {
             if (self::$instance) {
                 $log_dir = self::$instance->config->get('log_dir');
             }
         }
     }
     if (empty($log_dir)) {
         $log_dir = RCUBE_INSTALL_PATH . 'logs';
     }
     // try to open specific log file for writing
     $logfile = $log_dir . '/' . $name;
     if ($fp = @fopen($logfile, 'a')) {
         fwrite($fp, $line);
         fflush($fp);
         fclose($fp);
         return true;
     }
     trigger_error("Error writing to log file {$logfile}; Please check permissions", E_USER_WARNING);
     return false;
 }
开发者ID:Enclavet,项目名称:roundcubemail,代码行数:70,代码来源:rcube.php

示例2: write_log

 /**
  * Append a line to a logfile in the logs directory.
  * Date will be added automatically to the line.
  *
  * @param string $name Name of the log file
  * @param mixed  $line Line to append
  *
  * @return bool True on success, False on failure
  */
 public static function write_log($name, $line)
 {
     if (!is_string($line)) {
         $line = var_export($line, true);
     }
     $date_format = $log_driver = $session_key = null;
     if (self::$instance) {
         $date_format = self::$instance->config->get('log_date_format');
         $log_driver = self::$instance->config->get('log_driver');
         $session_key = intval(self::$instance->config->get('log_session_id', 8));
     }
     $date = rcube_utils::date_format($date_format);
     // trigger logging hook
     if (is_object(self::$instance) && is_object(self::$instance->plugins)) {
         $log = self::$instance->plugins->exec_hook('write_log', array('name' => $name, 'date' => $date, 'line' => $line));
         $name = $log['name'];
         $line = $log['line'];
         $date = $log['date'];
         if ($log['abort']) {
             return true;
         }
     }
     // add session ID to the log
     if ($session_key > 0 && ($sess = session_id())) {
         $line = '<' . substr($sess, 0, $session_key) . '> ' . $line;
     }
     if ($log_driver == 'syslog') {
         $prio = $name == 'errors' ? LOG_ERR : LOG_INFO;
         return syslog($prio, $line);
     }
     // log_driver == 'file' is assumed here
     $line = sprintf("[%s]: %s\n", $date, $line);
     // per-user logging is activated
     if (self::$instance && self::$instance->config->get('per_user_logging', false) && self::$instance->get_user_id()) {
         $log_dir = self::$instance->get_user_log_dir();
         if (empty($log_dir) && $name != 'errors') {
             return false;
         }
     }
     if (empty($log_dir)) {
         if (!empty($log['dir'])) {
             $log_dir = $log['dir'];
         } else {
             if (self::$instance) {
                 $log_dir = self::$instance->config->get('log_dir');
             }
         }
     }
     if (empty($log_dir)) {
         $log_dir = RCUBE_INSTALL_PATH . 'logs';
     }
     return file_put_contents("{$log_dir}/{$name}", $line, FILE_APPEND) !== false;
 }
开发者ID:jimjag,项目名称:roundcubemail,代码行数:62,代码来源:rcube.php


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