本文整理汇总了PHP中Zend_Log::addFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Log::addFilter方法的具体用法?PHP Zend_Log::addFilter怎么用?PHP Zend_Log::addFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Log
的用法示例。
在下文中一共展示了Zend_Log::addFilter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setFilter
/**
* Add a filter to log/not log messages of a specific type.
* Fluent interface.
*
* @param string $type Filter type, action may be negated by prefixing it with '!'
* @param boolean $action Q\Log::FILTER_* constant
* @return Log
*/
public function setFilter($type, $action = LOG::FILTER_INCLUDE)
{
if ($type[0] == '!') {
$action = !$action;
$type = substr($type, 1);
}
if ($action == LOG::FILTER_EXCLUDE) {
trigger_error("Filters to exclude types aren't supported in Zend_Log.", E_USER_WARNING);
return;
}
$priority = isset($this->alias[$type]) ? $this->alias[$type] : $this->alias[null];
$filter = new \Zend_Log_Filter_Priority($priority);
$this->zendlog->addFilter($filter);
}
示例2: _getLogger
/**
* return Zend_Log
*/
protected function _getLogger()
{
if (!$this->_logger instanceof Zend_Log) {
$config = $this->_getConfig();
$this->_logger = new Zend_Log();
$this->_logger->addWriter(new Zend_Log_Writer_Stream($config->general->logfile ? $config->general->logfile : STDOUT));
$this->_logger->addFilter(new Zend_Log_Filter_Priority((int) $config->general->loglevel));
}
return $this->_logger;
}
示例3: testShouldLogMissingSkuOncePerLine
function testShouldLogMissingSkuOncePerLine()
{
$importer = $this->mappingsImporterFromData('sku,make,model,year_range' . "\n" . 'sku1,honda,civic,2000-2001');
$writer = new Zend_Log_Writer_Mock();
$logger = new Zend_Log($writer);
$logger->addFilter(new Zend_Log_Filter_Priority(Zend_Log::NOTICE));
$importer->setLog($logger);
$importer->import();
$this->assertEquals(1, count($writer->events));
}
示例4: factory
/**
* Factory to construct the Zend_Log and add writers based on the
* configuration
*
* $config can be an array of an instance of Zend_Config
*
* @param mixed $config Array or instance of Zend_Config
* @return Zend_Log
*/
public static function factory($config = array())
{
// check config param
if ($config instanceof Zend_Config) {
$config = $config->toArray();
} else {
if (!is_array($config)) {
throw new BazeZF_Framework_Log_Exception(sprintf('%s::%s first param must be an array or instance of Zend_Config', __CLASS__, __FUNC__));
}
}
// Do we have one or more writers configured?
if (!is_array(current($config))) {
$config = array($config);
}
$logger = new Zend_Log();
// load priority
if (isset($config['priorities'])) {
foreach ($config['priorities'] as $priorityName => $priority) {
// convert priority const has integer
if (!is_numeric($priority)) {
$priority = constant($priority);
}
$logger->addPriority($priorityName, (int) $priority);
}
}
// load writers
if (isset($config['writers'])) {
foreach ($config['writers'] as $writer) {
// skip disabled writer
if (isset($writer['enable']) && !$writer['enable']) {
continue;
}
$writerObj = self::_loadWriter($writer['writerName'], isset($writer['writerParams']) ? $writer['writerParams'] : array());
// load writer filters
if (isset($writer['filterName'])) {
$filterObj = self::_loadFilter($writer['filterName'], isset($writer['filterParams']) ? $writer['filterParams'] : array());
$writerObj->addFilter($filterObj);
}
$logger->addWriter($writerObj);
}
}
// load writer filters
if (isset($config['filters'])) {
foreach ($config['filters'] as $filter) {
$filterObj = self::_loadFilter($filter['filterName'], isset($filter['filterParams']) ? $filter['filterParams'] : array());
$logger->addFilter($filterObj);
}
}
// add default writer if no writer was added
if (!isset($writerObj)) {
$writer = new Zend_Log_Writer_Null();
$logger->addWriter($writer);
}
return $logger;
}
示例5: getLogger
/**
* lees de opties uit application.ini en maak een log-object aan dat in de
* registry wordt gezet. Deze is vanuit de hele code te gebruiken voor debug-logging
* @return Zend_Log
*/
public function getLogger()
{
if (null === $this->_logger) {
$options = $this->getOptions();
if (!isset($options['debuglog'])) {
throw new Exception("Debug log path undefined in application.ini");
}
try {
$writer = new Zend_Log_Writer_Stream($options['debuglog']);
$this->_logger = new Zend_Log($writer);
} catch (Exception $e) {
$this->_logger = null;
}
if (isset($options['firebug']) && "1" == $options['firebug']) {
try {
$writer = new Zend_Log_Writer_Firebug();
if (null !== $this->_logger) {
$this->_logger->addWriter($writer);
} else {
$this->_logger = new Zend_Log($writer);
}
} catch (Exception $e) {
$this->_logger = null;
}
}
// voeg eventueel een uitvoer filter toe
if (null !== $this->_logger && isset($options['loglevel'])) {
try {
$loglevel = intVal($options['loglevel']);
$filter = new Zend_Log_Filter_Priority($loglevel);
$this->_logger->addFilter($filter);
} catch (Exception $e) {
}
}
}
// voeg toe aan de registry zodat we deze later eenvoudig kunnen gebruiken
if (null !== $this->_logger) {
$this->_logger->info('==========================================================');
Zend_Registry::set('logger', $this->_logger);
}
return $this->_logger;
}
示例6: testShouldLogCorrectLineNumber
function testShouldLogCorrectLineNumber()
{
$importer = $this->vehiclesListImporter('make,model,year' . "\n" . 'honda,civic,2000' . "\n" . 'honda,,2000');
$writer = new Zend_Log_Writer_Mock();
$logger = new Zend_Log($writer);
$logger->addFilter(new Zend_Log_Filter_Priority(Zend_Log::NOTICE));
$importer->setLog($logger);
$importer->import();
$event = $writer->events[0];
$this->assertEquals('Line(2) Blank Model', $event['message']);
}
示例7: testShouldNotLogErrorsForUniversalRecord
function testShouldNotLogErrorsForUniversalRecord()
{
$importer = $this->mappingsImporterFromData('sku, make, model, year, universal
"sku","","","","1"');
$importer->import();
$writer = new Zend_Log_Writer_Mock();
$logger = new Zend_Log($writer);
$logger->addFilter(new Zend_Log_Filter_Priority(Zend_Log::NOTICE));
$importer->setLog($logger);
$importer->import();
$this->assertEquals(0, count($writer->events));
}
示例8: _initLogging
/**
* Setup the logging
*/
protected function _initLogging()
{
$this->bootstrap('frontController');
$logger = new Zend_Log();
$writer = 'production' == $this->getEnvironment() ? new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../data/log/app.log') : new Zend_Log_Writer_Firebug();
$logger->addWriter($writer);
if ('production' == $this->getEnvironment()) {
$filter = new Zend_Log_Filter_Priority(Zend_Log::CRIT);
$logger->addFilter($filter);
}
$this->_logger = $logger;
Zend_Registry::set('log', $logger);
}
示例9: setUp
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
if (class_exists('Zend_Log') === false) {
$this->markTestSkipped('Class \\Zend_Log not found');
}
$writer = new \Zend_Log_Writer_Stream('error.log');
$formatter = new \Zend_Log_Formatter_Simple('log: %message%' . PHP_EOL);
$writer->setFormatter($formatter);
$logger = new \Zend_Log($writer);
$filter = new \Zend_Log_Filter_Priority(\Zend_Log::INFO);
$logger->addFilter($filter);
$this->object = new \Aimeos\MW\Logger\Zend($logger);
}
示例10: getInstance
/**
* @return Esendex_Sms_Model_Logger_Logger
*/
public static function getInstance()
{
if (static::$logger) {
return static::$logger;
}
$file = sprintf('%s/%s', Mage::getBaseDir('log'), static::LOG_FILE);
$logger = new Zend_Log(new Zend_Log_Writer_Stream($file));
if (!Mage::getStoreConfig('esendex_sms/sms/debug_mode')) {
$logger->addFilter(new Zend_Log_Filter_Priority(Zend_Log::CRIT));
}
static::$logger = new Esendex_Sms_Model_Logger_Logger($logger);
return static::$logger;
}
示例11: _initLogger
/**
* init config
*/
protected function _initLogger()
{
$this->_logger = new Zend_Log();
if ($this->_config->logfile) {
$writer = new Zend_Log_Writer_Stream($this->_config->logfile);
} else {
$writer = new Zend_Log_Writer_Null();
}
$this->_logger->addWriter($writer);
if ($this->_config->loglevel) {
$filter = new Zend_Log_Filter_Priority($this->_config->loglevel);
$this->_logger->addFilter($filter);
}
}
示例12: initializePimcoreLogging
/**
* Hook into the pimcore logger using the Pimcore\Console\Log\Writer
*
* @param int $filterPriority
*/
protected function initializePimcoreLogging($filterPriority = \Zend_Log::INFO)
{
$writer = new Writer($this->output);
$logger = new \Zend_Log($writer);
if ($this->output->isVerbose()) {
$filterPriority = null;
}
if (null !== $filterPriority) {
$logger->addFilter(new \Zend_Log_Filter_Priority($filterPriority));
}
// the filter handles verbosity
\Logger::setVerbosePriorities();
\Logger::addLogger($logger);
}
示例13: _initMyLoggingSettings
protected function _initMyLoggingSettings()
{
$logger = new Zend_Log();
$logger->addFilter(new Zend_Log_Filter_Priority((int) $this->_options["logging"]["level"]));
foreach ($this->_options["logging"]["writer"] as $wr) {
if ($wr == "Zend_Log_Writer_Stream") {
$w = new $wr($this->_options["logging"]["filename"]);
$logger->addWriter($w);
} else {
$logger->addWriter(new $wr());
}
}
Zend_Registry::set("logger", $logger);
}
示例14: testPWReplacements
/**
* test pw replacements
*/
public function testPWReplacements()
{
$config = Tinebase_Core::getConfig();
$logfile = tempnam(Tinebase_Core::getTempDir(), 'testlog');
$writer = new Zend_Log_Writer_Stream($logfile);
$formatter = new Tinebase_Log_Formatter();
$formatter->addReplacement($config->database->password);
$writer->setFormatter($formatter);
$this->_logger->addWriter($writer);
$filter = new Zend_Log_Filter_Priority(5);
$this->_logger->addFilter($filter);
$this->_logger->notice($config->database->password);
$loggerFile = file_get_contents($logfile);
$writer->shutdown();
unlink($logfile);
$this->assertFalse(strpos($loggerFile, $config->database->password), 'pw found!');
$this->assertContains('********', $loggerFile);
if ($config->logger->logruntime || $config->logger->logdifftime) {
$this->assertTrue(preg_match('/' . Tinebase_Core::getUser()->accountLoginName . ' \\d/', $loggerFile) === 1);
} else {
$this->assertContains(Tinebase_Core::getUser()->accountLoginName . ' - ', $loggerFile);
}
}
示例15: __construct
/**
* make new logger, configuration is taken from system_config, section $instanceName
* @param string $instanceName
* @param string $application
*/
protected function __construct($instanceName, $application = null)
{
if ($instanceName === null) {
throw new Exception(__METHOD__ . ': expected an instance name, got none');
}
$config = Config::getInstance(SYSTEM_CONFIG);
$log_config = $config->{$instanceName};
$this->log = new Zend_Log();
if (isset($log_config->file) && intval($log_config->file->enabled) !== 0) {
$file_logger = new Zend_Log_Writer_Stream($log_config->file->name);
/**
*
$format = Zend_Log_Formatter_Simple::DEFAULT_FORMAT;
$formatter = new Zend_Log_Formatter_Simple($format);
$file_logger->setFormatter($formatter);
*/
if (isset($application) && $application != '') {
$this->log->setEventItem('application', $application);
}
$formatter = new Zend_Log_Formatter_Simple('%syslog_time% %application%[%pid%]: %priorityName%: %message%' . PHP_EOL);
$file_logger->setFormatter($formatter);
$this->log->addWriter($file_logger);
}
if (isset($log_config->syslog) && intval($log_config->syslog->enabled) !== 0) {
$param = array('facility' => $log_config->syslog->facility);
if (isset($application) && $application != '') {
$param['application'] = $application;
}
$sys_logger = new Zend_Log_Writer_Syslog($param);
$formatter = new Zend_Log_Formatter_Simple('%priorityName%: %message%' . PHP_EOL);
$sys_logger->setFormatter($formatter);
$this->log->addWriter($sys_logger);
}
$filter = new Zend_Log_Filter_Priority(intval($log_config->priority));
$this->log->addFilter($filter);
}