"Fossies" - the Fresh Open Source Software Archive

Member "seopanel/libs/google-api-php-client/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php" (22 Dec 2019, 3382 Bytes) of package /linux/www/seopanel.v.4.3.0.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "AbstractSyslogHandler.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 /*
    4  * This file is part of the Monolog package.
    5  *
    6  * (c) Jordi Boggiano <j.boggiano@seld.be>
    7  *
    8  * For the full copyright and license information, please view the LICENSE
    9  * file that was distributed with this source code.
   10  */
   11 
   12 namespace Monolog\Handler;
   13 
   14 use Monolog\Logger;
   15 use Monolog\Formatter\LineFormatter;
   16 
   17 /**
   18  * Common syslog functionality
   19  */
   20 abstract class AbstractSyslogHandler extends AbstractProcessingHandler
   21 {
   22     protected $facility;
   23 
   24     /**
   25      * Translates Monolog log levels to syslog log priorities.
   26      */
   27     protected $logLevels = array(
   28         Logger::DEBUG     => LOG_DEBUG,
   29         Logger::INFO      => LOG_INFO,
   30         Logger::NOTICE    => LOG_NOTICE,
   31         Logger::WARNING   => LOG_WARNING,
   32         Logger::ERROR     => LOG_ERR,
   33         Logger::CRITICAL  => LOG_CRIT,
   34         Logger::ALERT     => LOG_ALERT,
   35         Logger::EMERGENCY => LOG_EMERG,
   36     );
   37 
   38     /**
   39      * List of valid log facility names.
   40      */
   41     protected $facilities = array(
   42         'auth'     => LOG_AUTH,
   43         'authpriv' => LOG_AUTHPRIV,
   44         'cron'     => LOG_CRON,
   45         'daemon'   => LOG_DAEMON,
   46         'kern'     => LOG_KERN,
   47         'lpr'      => LOG_LPR,
   48         'mail'     => LOG_MAIL,
   49         'news'     => LOG_NEWS,
   50         'syslog'   => LOG_SYSLOG,
   51         'user'     => LOG_USER,
   52         'uucp'     => LOG_UUCP,
   53     );
   54 
   55     /**
   56      * @param mixed   $facility
   57      * @param int     $level    The minimum logging level at which this handler will be triggered
   58      * @param Boolean $bubble   Whether the messages that are handled can bubble up the stack or not
   59      */
   60     public function __construct($facility = LOG_USER, $level = Logger::DEBUG, $bubble = true)
   61     {
   62         parent::__construct($level, $bubble);
   63 
   64         if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
   65             $this->facilities['local0'] = LOG_LOCAL0;
   66             $this->facilities['local1'] = LOG_LOCAL1;
   67             $this->facilities['local2'] = LOG_LOCAL2;
   68             $this->facilities['local3'] = LOG_LOCAL3;
   69             $this->facilities['local4'] = LOG_LOCAL4;
   70             $this->facilities['local5'] = LOG_LOCAL5;
   71             $this->facilities['local6'] = LOG_LOCAL6;
   72             $this->facilities['local7'] = LOG_LOCAL7;
   73         } else {
   74             $this->facilities['local0'] = 128; // LOG_LOCAL0
   75             $this->facilities['local1'] = 136; // LOG_LOCAL1
   76             $this->facilities['local2'] = 144; // LOG_LOCAL2
   77             $this->facilities['local3'] = 152; // LOG_LOCAL3
   78             $this->facilities['local4'] = 160; // LOG_LOCAL4
   79             $this->facilities['local5'] = 168; // LOG_LOCAL5
   80             $this->facilities['local6'] = 176; // LOG_LOCAL6
   81             $this->facilities['local7'] = 184; // LOG_LOCAL7
   82         }
   83 
   84         // convert textual description of facility to syslog constant
   85         if (array_key_exists(strtolower($facility), $this->facilities)) {
   86             $facility = $this->facilities[strtolower($facility)];
   87         } elseif (!in_array($facility, array_values($this->facilities), true)) {
   88             throw new \UnexpectedValueException('Unknown facility value "'.$facility.'" given');
   89         }
   90 
   91         $this->facility = $facility;
   92     }
   93 
   94     /**
   95      * {@inheritdoc}
   96      */
   97     protected function getDefaultFormatter()
   98     {
   99         return new LineFormatter('%channel%.%level_name%: %message% %context% %extra%');
  100     }
  101 }