Source for file Syslog.php

Documentation is available at Syslog.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  Syslog.php
  5.  *
  6.  *  @author     Masaki Fujimoto <fujimoto@php.net>
  7.  *  @license    http://www.opensource.org/licenses/bsd-license.php The BSD License
  8.  *  @package    Ethna
  9.  *  @version    $Id: 30daaf92ffa7c2a2a2bf153bffbfea71a0064734 $
  10.  */
  11.  
  12. // {{{ Ethna_Plugin_Logwriter_Syslog
  13. /**
  14.  *  ログ出力クラス(Syslog)
  15.  *
  16.  *  @author     Masaki Fujimoto <fujimoto@php.net>
  17.  *  @access     public
  18.  *  @package    Ethna
  19.  */
  20. {
  21.     /**
  22.      *  ログ出力を開始する
  23.      *
  24.      *  @access public
  25.      */
  26.     function begin()
  27.     {
  28.         // syslog用オプションのみを指定
  29.         if (array_key_exists("pid"$this->option)) {
  30.             $option $this->option (LOG_PID);
  31.         }
  32.         openlog($this->ident$option$this->facility);
  33.     }
  34.  
  35.     /**
  36.      *  ログを出力する
  37.      *
  38.      *  @access public
  39.      *  @param  int     $level      ログレベル(LOG_DEBUG, LOG_NOTICE...)
  40.      *  @param  string  $message    ログメッセージ(+引数)
  41.      */
  42.     function log($level$message)
  43.     {
  44.         $prefix sprintf('%s: '$this->_getLogLevelName($level));
  45.         if (array_key_exists("function"$this->option||
  46.             array_key_exists("pos"$this->option)) {
  47.             $tmp "";
  48.             $bt $this->_getBacktrace();
  49.             if ($bt && array_key_exists("function"$this->option&& $bt['function']{
  50.                 $tmp .= $bt['function'];
  51.             }
  52.             if ($bt && array_key_exists("pos"$this->option&& $bt['pos']{
  53.                 $tmp .= $tmp sprintf('(%s)'$bt['pos']$bt['pos'];
  54.             }
  55.             if ($tmp{
  56.                 $prefix .= $tmp ": ";
  57.             }
  58.         }
  59.         syslog($level$prefix $message);
  60.  
  61.         return $prefix $message;
  62.     }
  63.  
  64.     /**
  65.      *  ログ出力を終了する
  66.      *
  67.      *  @access public
  68.      */
  69.     function end()
  70.     {
  71.         closelog();
  72.     }
  73. }
  74. // }}}

Documentation generated on Fri, 11 Nov 2011 03:59:08 +0900 by phpDocumentor 1.4.3