YiiDebugToolbarPanelLogging.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. /**
  3. * YiiDebugToolbarPanelLogging class file.
  4. *
  5. * @author Sergey Malyshev <malyshev.php@gmail.com>
  6. */
  7. /**
  8. * YiiDebugToolbarPanelLogging represents an ...
  9. *
  10. * Description of YiiDebugToolbarPanelLogging
  11. *
  12. * @author Sergey Malyshev <malyshev.php@gmail.com>
  13. * @author Igor Golovanov <igor.golovanov@gmail.com>
  14. * @version $Id$
  15. * @package YiiDebugToolbar
  16. * @since 1.1.7
  17. */
  18. class YiiDebugToolbarPanelLogging extends YiiDebugToolbarPanel
  19. {
  20. public $i = 'j';
  21. /**
  22. * Message count.
  23. *
  24. * @var integer
  25. */
  26. private $_countMessages;
  27. /**
  28. * Logs.
  29. *
  30. * @var array
  31. */
  32. private $_logs;
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function getMenuTitle()
  37. {
  38. return YiiDebug::t('Logging');
  39. }
  40. /**
  41. * {@inheritdoc}
  42. */
  43. public function getMenuSubTitle()
  44. {
  45. return $this->countMessages;
  46. }
  47. /**
  48. * {@inheritdoc}
  49. */
  50. public function getTitle()
  51. {
  52. return YiiDebug::t('Log Messages');
  53. }
  54. /**
  55. * Get logs.
  56. *
  57. * @return array
  58. */
  59. public function getLogs()
  60. {
  61. if (null === $this->_logs)
  62. {
  63. $this->_logs = $this->filterLogs();
  64. }
  65. return $this->_logs;
  66. }
  67. /**
  68. * Get count of messages.
  69. *
  70. * @return integer
  71. */
  72. public function getCountMessages()
  73. {
  74. if (null === $this->_countMessages)
  75. {
  76. $this->_countMessages = count($this->logs);
  77. }
  78. return $this->_countMessages;
  79. }
  80. /**
  81. * {@inheritdoc}
  82. */
  83. public function run()
  84. {
  85. $this->render('logging', array(
  86. 'logs' => $this->logs
  87. ));
  88. }
  89. /**
  90. * Get filter logs.
  91. *
  92. * @return array
  93. */
  94. protected function filterLogs()
  95. {
  96. $logs = array();
  97. foreach ($this->owner->getLogs() as $entry)
  98. {
  99. if (CLogger::LEVEL_PROFILE !== $entry[1] && false === strpos($entry[2], 'system.db.CDbCommand'))
  100. {
  101. $logs[] = $entry;
  102. }
  103. }
  104. return $logs;
  105. }
  106. }