EchoLogger.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /*
  3. * This file is part of SwiftMailer.
  4. * (c) 2004-2009 Chris Corbyn
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * Prints all log messages in real time.
  11. *
  12. * @package Swift
  13. * @subpackage Transport
  14. * @author Chris Corbyn
  15. */
  16. class Swift_Plugins_Loggers_EchoLogger implements Swift_Plugins_Logger
  17. {
  18. /** Whether or not HTML should be output */
  19. private $_isHtml;
  20. /**
  21. * Create a new EchoLogger.
  22. *
  23. * @param boolean $isHtml
  24. */
  25. public function __construct($isHtml = true)
  26. {
  27. $this->_isHtml = $isHtml;
  28. }
  29. /**
  30. * Add a log entry.
  31. *
  32. * @param string $entry
  33. */
  34. public function add($entry)
  35. {
  36. if ($this->_isHtml) {
  37. printf('%s%s%s', htmlspecialchars($entry, ENT_QUOTES), '<br />', PHP_EOL);
  38. } else {
  39. printf('%s%s', $entry, PHP_EOL);
  40. }
  41. }
  42. /**
  43. * Not implemented.
  44. */
  45. public function clear()
  46. {
  47. }
  48. /**
  49. * Not implemented.
  50. */
  51. public function dump()
  52. {
  53. }
  54. }