Logger.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Class Minify_Logger
  4. * @package Minify
  5. */
  6. /**
  7. * Message logging class
  8. *
  9. * @package Minify
  10. * @author Stephen Clay <steve@mrclay.org>
  11. *
  12. * @todo lose this singleton! pass log object in Minify::serve and distribute to others
  13. */
  14. class Minify_Logger {
  15. /**
  16. * Set logger object.
  17. *
  18. * The object should have a method "log" that accepts a value as 1st argument and
  19. * an optional string label as the 2nd.
  20. *
  21. * @param mixed $obj or a "falsey" value to disable
  22. * @return null
  23. */
  24. public static function setLogger($obj = null) {
  25. self::$_logger = $obj
  26. ? $obj
  27. : null;
  28. }
  29. /**
  30. * Pass a message to the logger (if set)
  31. *
  32. * @param string $msg message to log
  33. * @return null
  34. */
  35. public static function log($msg, $label = 'Minify') {
  36. if (! self::$_logger) return;
  37. self::$_logger->log($msg, $label);
  38. }
  39. /**
  40. * @var mixed logger object (like FirePHP) or null (i.e. no logger available)
  41. */
  42. private static $_logger = null;
  43. }