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.

56 lines
1.2 KiB

  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. abstract class Logger
  11. {
  12. protected static $_instance = null;
  13. /**
  14. * pid текущего процесса
  15. * @var string
  16. */
  17. protected $pid = '';
  18. protected function __construct() {}
  19. public static function getInstance()
  20. {
  21. if(static::$_instance === null) {
  22. //$class = get_called_class();
  23. $class = Config::get('Logger')->logger;
  24. static::$_instance = new $class();
  25. }
  26. return static::$_instance;
  27. }
  28. /**
  29. * Вывод лога
  30. * @param string $message Сообщение
  31. */
  32. public function log($message)
  33. {
  34. if (DEBUG) {
  35. $this->concreteLog($message);
  36. }
  37. }
  38. /**
  39. * Установить pid текущего процесса для вывода в лог
  40. * @param int $pid
  41. */
  42. public function setPid($pid)
  43. {
  44. if (!empty($pid)) {
  45. $this->pid = ' <' . $pid . '> ';
  46. }
  47. }
  48. abstract protected function concreteLog($message);
  49. }