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.

62 lines
1.3 KiB

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