|
TYPO3 API
SVNRelease
|
00001 <?php 00002 00003 /* 00004 * This file is part of SwiftMailer. 00005 * (c) 2004-2009 Chris Corbyn 00006 * 00007 * For the full copyright and license information, please view the LICENSE 00008 * file that was distributed with this source code. 00009 */ 00010 00011 /** 00012 * Logs to an Array backend. 00013 * @package Swift 00014 * @subpackage Transport 00015 * @author Chris Corbyn 00016 */ 00017 class Swift_Plugins_Loggers_ArrayLogger implements Swift_Plugins_Logger 00018 { 00019 00020 /** 00021 * The log contents. 00022 * @var array 00023 * @access private 00024 */ 00025 private $_log = array(); 00026 00027 /** 00028 * Max size of the log. 00029 * @var int 00030 * @access private 00031 */ 00032 private $_size = 0; 00033 00034 /** 00035 * Create a new ArrayLogger with a maximum of $size entries. 00036 * @var int $size 00037 */ 00038 public function __construct($size = 50) 00039 { 00040 $this->_size = $size; 00041 } 00042 00043 /** 00044 * Add a log entry. 00045 * @param string $entry 00046 */ 00047 public function add($entry) 00048 { 00049 $this->_log[] = $entry; 00050 while (count($this->_log) > $this->_size) 00051 { 00052 array_shift($this->_log); 00053 } 00054 } 00055 00056 /** 00057 * Clear the log contents. 00058 */ 00059 public function clear() 00060 { 00061 $this->_log = array(); 00062 } 00063 00064 /** 00065 * Get this log as a string. 00066 * @return string 00067 */ 00068 public function dump() 00069 { 00070 return implode(PHP_EOL, $this->_log); 00071 } 00072 00073 }
1.8.0