|
Revision 9081, 1.8 kB
(checked in by Carl.Vondrick, 5 years ago)
|
1.1: fixed @param phpdoc to fit specs for log (refs #2991)
|
- Property svn:mime-type set to
text/x-php
- Property svn:eol-style set to
native
- Property svn:keywords set to
Id
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
class sfStreamLogger extends sfLogger |
|---|
| 20 |
{ |
|---|
| 21 |
protected |
|---|
| 22 |
$stream = null; |
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
* Initializes this logger. |
|---|
| 26 |
* |
|---|
| 27 |
* Available options: |
|---|
| 28 |
* |
|---|
| 29 |
* - stream: A PHP stream |
|---|
| 30 |
* |
|---|
| 31 |
* @param sfEventDispatcher $dispatcher A sfEventDispatcher instance |
|---|
| 32 |
* @param array $options An array of options. |
|---|
| 33 |
* |
|---|
| 34 |
* @return Boolean true, if initialization completes successfully, otherwise false. |
|---|
| 35 |
*/ |
|---|
| 36 |
public function initialize(sfEventDispatcher $dispatcher, $options = array()) |
|---|
| 37 |
{ |
|---|
| 38 |
if (!isset($options['stream'])) |
|---|
| 39 |
{ |
|---|
| 40 |
throw new sfConfigurationException('You must provide a "stream" option for this logger.'); |
|---|
| 41 |
} |
|---|
| 42 |
else |
|---|
| 43 |
{ |
|---|
| 44 |
if (is_resource($options['stream']) && 'stream' != get_resource_type($options['stream'])) |
|---|
| 45 |
{ |
|---|
| 46 |
throw new sfConfigurationException('The provided "stream" option is not a stream.'); |
|---|
| 47 |
} |
|---|
| 48 |
} |
|---|
| 49 |
|
|---|
| 50 |
$this->stream = $options['stream']; |
|---|
| 51 |
|
|---|
| 52 |
return parent::initialize($dispatcher, $options); |
|---|
| 53 |
} |
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
* Sets the PHP stream to use for this logger. |
|---|
| 57 |
* |
|---|
| 58 |
* @param stream $stream A php stream |
|---|
| 59 |
*/ |
|---|
| 60 |
public function setStream($stream) |
|---|
| 61 |
{ |
|---|
| 62 |
$this->stream = $stream; |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
* Logs a message. |
|---|
| 67 |
* |
|---|
| 68 |
* @param string $message Message |
|---|
| 69 |
* @param string $priority Message priority |
|---|
| 70 |
*/ |
|---|
| 71 |
protected function doLog($message, $priority) |
|---|
| 72 |
{ |
|---|
| 73 |
fwrite($this->stream, $message.PHP_EOL); |
|---|
| 74 |
flush(); |
|---|
| 75 |
} |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|