EchoLogger.php 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. * @param string $entry
  32. */
  33. public function add($entry)
  34. {
  35. if ($this->_isHtml)
  36. {
  37. printf('%s%s%s', htmlspecialchars($entry, ENT_QUOTES), '<br />', PHP_EOL);
  38. }
  39. else
  40. {
  41. printf('%s%s', $entry, PHP_EOL);
  42. }
  43. }
  44. /**
  45. * Not implemented.
  46. */
  47. public function clear()
  48. {
  49. }
  50. /**
  51. * Not implemented.
  52. */
  53. public function dump()
  54. {
  55. }
  56. }