fix calendar css, take 2. (#213)
[openemr.git] / interface / modules / zend_modules / library / Zend / Log / Writer / ChromePhp.php
blob6483cc29a2b0e4988098d3901b8ff43ea0345a34
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Log\Writer;
12 use Traversable;
13 use Zend\Log\Writer\ChromePhp\ChromePhpBridge;
14 use Zend\Log\Writer\ChromePhp\ChromePhpInterface;
15 use Zend\Log\Formatter\ChromePhp as ChromePhpFormatter;
16 use Zend\Log\Logger;
17 use Zend\Log\Exception;
19 class ChromePhp extends AbstractWriter
21 /**
22 * The instance of ChromePhpInterface that is used to log messages to.
24 * @var ChromePhpInterface
26 protected $chromephp;
28 /**
29 * Initializes a new instance of this class.
31 * @param null|ChromePhpInterface|array|Traversable $instance An instance of ChromePhpInterface
32 * that should be used for logging
34 public function __construct($instance = null)
36 if ($instance instanceof Traversable) {
37 $instance = iterator_to_array($instance);
40 if (is_array($instance)) {
41 parent::__construct($instance);
42 $instance = isset($instance['instance']) ? $instance['instance'] : null;
45 if (!($instance instanceof ChromePhpInterface || $instance === null)) {
46 throw new Exception\InvalidArgumentException('You must pass a valid Zend\Log\Writer\ChromePhp\ChromePhpInterface');
49 $this->chromephp = $instance === null ? $this->getChromePhp() : $instance;
50 $this->formatter = new ChromePhpFormatter();
53 /**
54 * Write a message to the log.
56 * @param array $event event data
57 * @return void
59 protected function doWrite(array $event)
61 $line = $this->formatter->format($event);
63 switch ($event['priority']) {
64 case Logger::EMERG:
65 case Logger::ALERT:
66 case Logger::CRIT:
67 case Logger::ERR:
68 $this->chromephp->error($line);
69 break;
70 case Logger::WARN:
71 $this->chromephp->warn($line);
72 break;
73 case Logger::NOTICE:
74 case Logger::INFO:
75 $this->chromephp->info($line);
76 break;
77 case Logger::DEBUG:
78 $this->chromephp->trace($line);
79 break;
80 default:
81 $this->chromephp->log($line);
82 break;
86 /**
87 * Gets the ChromePhpInterface instance that is used for logging.
89 * @return ChromePhpInterface
91 public function getChromePhp()
93 // Remember: class names in strings are absolute; thus the class_exists
94 // here references the canonical name for the ChromePhp class
95 if (!$this->chromephp instanceof ChromePhpInterface
96 && class_exists('ChromePhp')
97 ) {
98 $this->setChromePhp(new ChromePhpBridge());
100 return $this->chromephp;
104 * Sets the ChromePhpInterface instance that is used for logging.
106 * @param ChromePhpInterface $instance The instance to set.
107 * @return ChromePhp
109 public function setChromePhp(ChromePhpInterface $instance)
111 $this->chromephp = $instance;
112 return $this;