Logger.php 713 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * @file
  4. * Trivial logger for easier debug.
  5. */
  6. namespace OSInet\Class_Grapher;
  7. class Logger {
  8. var $debugLevel;
  9. public function __construct($debugLevel) {
  10. $this->debugLevel = $debugLevel;
  11. }
  12. /**
  13. * Output a message on STDERR if its relevance is above minimum level.
  14. *
  15. * @param string $message
  16. * @param int $level
  17. * Defined in RFC 3164, section 4.1.1 "Severity". But compare with Drupal 7
  18. * WATCHDOG_* constants in includes/bootstrap.inc for an explanation about
  19. * syslog constants in PHP.
  20. */
  21. public function debug($message = "\n", $level = LOG_INFO) {
  22. if ($level <= $this->debugLevel) {
  23. fputs(STDERR, $message);
  24. fflush(STDERR);
  25. }
  26. }
  27. }