You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
987 B

  1. <?php
  2. /**
  3. * @copyright NetMonsters <team@netmonsters.ru>
  4. * @link http://netmonsters.ru
  5. * @package Majestic
  6. * @subpackage Logger
  7. * @since 21-11-2011
  8. * @user: agrebnev
  9. */
  10. class FileLogger extends Logger
  11. {
  12. protected $file_path = '';
  13. protected $handler = null;
  14. protected function __construct()
  15. {
  16. $this->file_path = Config::get('Logger')->filepath;
  17. }
  18. protected function concreteLog($message)
  19. {
  20. $out = microtime(true) . " \t: " . $this->pid . trim($message) . "\r\n";
  21. if (!$this->handler) {
  22. $this->handler = @fopen($this->file_path, "a");
  23. if (!$this->handler) {
  24. throw new GeneralException('Could not open file ' . $this->file_path);
  25. }
  26. }
  27. fwrite($this->handler, $out);
  28. }
  29. public function __destruct()
  30. {
  31. if ($this->handler) {
  32. if (fclose($this->handler)) {
  33. $this->handler = null;
  34. }
  35. }
  36. }
  37. }