Source of file Tail.php
Size: 3,690 Bytes - Last Modified: 2015-05-15T11:18:15+02:00
/www-data/git/Hackathon_MageMonitoring/src/app/code/community/FireGento/MageMonitoring/Model/Widget/Log/Tail.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 | <?php /** * This file is part of a FireGento e.V. module. * * This FireGento e.V. module is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This script is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * * PHP version 5 * * @category FireGento * @package FireGento_MageMonitoring * @author FireGento Team <team@firegento.com> * @copyright 2015 FireGento Team (http://www.firegento.com) * @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3) */ /** * class FireGento_MageMonitoring_Model_Widget_Log_Tail * * @category FireGento * @package FireGento_MageMonitoring * @author FireGento Team <team@firegento.com> */ class FireGento_MageMonitoring_Model_Widget_Log_Tail extends FireGento_MageMonitoring_Model_Widget_Log_Abstract implements FireGento_MageMonitoring_Model_Widget, FireGento_MageMonitoring_Model_WatchDog { // define config keys const CONFIG_LOG_FILE = 'file_path'; const CONFIG_LOG_COLOR = 'color'; // set/override defaults protected $_defWidgetTitle = 'Log Watcher'; protected $_defLogFile = ''; protected $_defLogColor = 'info'; protected $_defLogLines = 60; protected $_defDisplayPrio = 20; /** * (non-PHPdoc) * * @see FireGento_MageMonitoring_Model_Widget::getVersion() */ public function getVersion() { return '1.0'; } /** * (non-PHPdoc) * * @see FireGento_MageMonitoring_Model_Widget::initConfig() */ public function initConfig() { parent::initConfig(); // add config for log file path $this->addConfig(self::CONFIG_LOG_FILE, 'Log file path:', $this->_defLogFile, 'widget', 'text', true, 'Complete system path or relative from magento root or var/log.'); // add background color $this->addConfig(self::CONFIG_LOG_COLOR, 'Background color:', $this->_defLogColor, 'widget', 'text', false, 'success | info | warning | error'); return $this->_config; } /** * (non-PHPdoc) * * @see FireGento_MageMonitoring_Model_Widget::getOutput() */ public function getOutput() { $logName = $this->getConfig(self::CONFIG_LOG_FILE); if ($logName) { $this->_output[] = $this->newLogBlock($this->getConfig(self::CONFIG_LOG_COLOR), $logName); } else { $this->dump(Mage::helper('magemonitoring')->__('Log file path is not configured!')); } return $this->_output; } /** * Reports on new log entries. * * (non-PHPdoc) * * @see FireGento_MageMonitoring_Model_WatchDog::watch() */ public function watch() { $logName = $this->getConfig(self::CONFIG_LOG_FILE); if ($logName) { $log = $this->getLogTail($logName, $this->getConfig(self::CONFIG_LOG_LINES)); return $this->watchLog($log, $logName); } else { $this->addReportRow('error', Mage::helper('magemonitoring')->__('Log file path is not configured!'), ''); return $this->_report; } } /** * Returns node name */ protected function _getNodeName() { // TODO: Implement _getNodeName() method. } } |