EchoLogger.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. * @author Chris Corbyn
  13. */
  14. class Swift_Plugins_Loggers_EchoLogger implements Swift_Plugins_Logger
  15. {
  16. /** Whether or not HTML should be output */
  17. private $_isHtml;
  18. /**
  19. * Create a new EchoLogger.
  20. *
  21. * @param bool $isHtml
  22. */
  23. public function __construct($isHtml = true)
  24. {
  25. $this->_isHtml = $isHtml;
  26. }
  27. /**
  28. * Add a log entry.
  29. *
  30. * @param string $entry
  31. */
  32. public function add($entry)
  33. {
  34. if ($this->_isHtml) {
  35. printf('%s%s%s', htmlspecialchars($entry, ENT_QUOTES), '<br />', PHP_EOL);
  36. } else {
  37. printf('%s%s', $entry, PHP_EOL);
  38. }
  39. }
  40. /**
  41. * Not implemented.
  42. */
  43. public function clear()
  44. {
  45. }
  46. /**
  47. * Not implemented.
  48. */
  49. public function dump()
  50. {
  51. }
  52. }