Source for file Echo.php

Documentation is available at Echo.php

  1. <?php
  2. // vim: foldmethod=marker
  3. /**
  4.  *  Echo.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: b85c5275070c9afc6ed8f504ba7847fab7778706 $
  10.  */
  11.  
  12. // {{{ Ethna_Plugin_Logwriter_Echo
  13. /**
  14.  *  ログ出力基底クラス
  15.  *
  16.  *  @author     Masaki Fujimoto <fujimoto@php.net>
  17.  *  @access     public
  18.  *  @package    Ethna
  19.  */
  20. {
  21.     /**#@+
  22.      *  @access private
  23.      */
  24.  
  25.     /**#@-*/
  26.  
  27.     /**
  28.      *  ログを出力する
  29.      *
  30.      *  @access public
  31.      *  @param  int     $level      ログレベル(LOG_DEBUG, LOG_NOTICE...)
  32.      *  @param  string  $message    ログメッセージ(+引数)
  33.      */
  34.     function log($level, $message)
  35.     {
  36.         $c = Ethna_Controller::getInstance();
  37.  
  38.         $prefix = $this->ident;
  39.         if (array_key_exists("pid", $this->option)) {
  40.             $prefix .= sprintf('[%d]', getmypid());
  41.         }
  42.         $prefix .= sprintf($c->getGateway() != GATEWAY_WWW ? '(%s): ' : '(<b>%s</b>): ',
  43.             $this->_getLogLevelName($level)
  44.         );
  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.  
  60.         $br = $c->getGateway() != GATEWAY_WWW ? "" : "<br />";
  61.         echo($prefix . $message . $br . "\n");
  62.  
  63.         return $prefix . $message;
  64.     }
  65. }
  66. // }}}

Documentation generated on Fri, 11 Nov 2011 03:58:01 +0900 by phpDocumentor 1.4.3