本文整理汇总了PHP中Zend_Log::addPriority方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Log::addPriority方法的具体用法?PHP Zend_Log::addPriority怎么用?PHP Zend_Log::addPriority使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Log
的用法示例。
在下文中一共展示了Zend_Log::addPriority方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
$writer = new Zend_Log_Writer_Firebug();
$logger = new Zend_Log($writer);
$logger->addPriority('LOGD', 8);
$writer->setPriorityStyle(8, 'LOG');
$logger->addPriority('ERROR', 9);
$writer->setPriorityStyle(9, 'ERROR');
$logger->addPriority('TRACE', 10);
$writer->setPriorityStyle(10, 'TRACE');
$logger->addPriority('EXCEPTION', 11);
$writer->setPriorityStyle(11, 'EXCEPTION');
$logger->addPriority('TABLE', 12);
$writer->setPriorityStyle(12, 'TABLE');
$logger->logd($_SERVER);
$logger->info($_SERVER);
$logger->warn($_SERVER);
$logger->error($_SERVER);
$logger->trace($_SERVER);
try {
throw new Exception('Test Exception');
} catch (Exception $e) {
$logger->exception($e);
}
$logger->table(array('2 SQL queries took 0.06 seconds', array(array('SQL Statement', 'Time', 'Result'), array('SELECT * FROM Foo', '0.02', array('row1', 'row2')), array('SELECT * FROM Bar', '0.04', array('row1', 'row2')))));
}
示例2: __construct
public function __construct()
{
\Zend_Controller_Front::getInstance()->registerPlugin($this);
$this->writer = new Writer();
$this->logger = new \Zend_Log($this->writer);
$this->logger->addPriority('ZFLOG', self::ZFLOG);
}
示例3: startLog
protected function startLog()
{
$writer = new \Zend_Log_Writer_Stream('php://stdout');
$logger = new \Zend_Log($writer);
$logger->addPriority("sql", 8);
$this->config->log = $logger;
}
示例4: initLog
/**
* Initialize logger(s)
*
* @return My_Plugin_Initialize
*/
public function initLog()
{
$writer = new Zend_Log_Writer_Firebug();
$log = new Zend_Log($writer);
$writer->setPriorityStyle(8, 'TABLE');
$log->addPriority('TABLE', 8);
Zend_Registry::set('log', $log);
return $this;
}
示例5: 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;
}
示例6: _createLogger
private static function _createLogger()
{
// get config
$config = MyProject::registry('config');
// disabled log
if (!$config->log->enable) {
return false;
}
// init logger
$logger = new Zend_Log();
// add default priority for
$dbProfilerLogPriority = 8;
$logger->addPriority('TABLE', $dbProfilerLogPriority);
// add priority per components
$componentsEnables = $config->log->components->toArray();
$components = array('DBCOLLECTION' => BaseZF_DbCollection::LOG_PRIORITY, 'DBITEM' => BaseZF_DbItem::LOG_PRIORITY, 'DBQUERY' => BaseZF_DbQuery::LOG_PRIORITY);
foreach ($components as $name => $priority) {
$logger->addPriority($name, $priority);
if (!$componentsEnables[strtolower($name)] && isset($componentsEnables[strtolower($name)])) {
$filter = new Zend_Log_Filter_Priority($priority, '!=');
$logger->addFilter($filter);
}
}
// add stream writer
if ($config->log->writers->stream->enable) {
$writer = new Zend_Log_Writer_Stream($config->log->writers->stream->path);
$logger->addWriter($writer);
}
// add firebug writer
if ($config->log->writers->firebug->enable) {
$writer = new Zend_Log_Writer_Firebug();
$writer->setPriorityStyle($dbProfilerLogPriority, 'TABLE');
$logger->addWriter($writer);
}
// add default writer if no writer was added
if (!isset($writer)) {
$writer = new Zend_Log_Writer_Null();
$logger->addWriter($writer);
}
return $logger;
}
示例7: init
public function init()
{
$this->getBootstrap()->bootstrap(array('db'));
$tbl = 'tbl_ot_log';
$application = $this->getBootstrap()->getApplication();
$prefix = $application->getOption('tablePrefix');
if (!empty($prefix)) {
$tbl = $prefix . $tbl;
}
// Setup logger
if ($this->_useLog) {
$adapter = Zend_Db_Table::getDefaultAdapter();
$writer = new Zend_Log_Writer_Db($adapter, $tbl);
} else {
$writer = new Zend_Log_Writer_Null();
}
$logger = new Zend_Log($writer);
$logger->addPriority('LOGIN', 8);
$logger->setEventItem('sid', session_id());
$logger->setEventItem('timestamp', time());
$logger->setEventItem('request', str_replace(Zend_Controller_Front::getInstance()->getBaseUrl(), '', $_SERVER['REQUEST_URI']));
Zend_Registry::set('logger', $logger);
}
示例8: array
* @package Zend_Wildfire
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
/* NOTE: You must have Zend Framework in your include path! */
/*
* Add our Firebug Log Writer to the registry
*/
// require_once 'Zend/Registry.php';
// require_once 'Zend/Log.php';
// require_once 'Zend/Log/Writer/Firebug.php';
$writer = new Zend_Log_Writer_Firebug();
$writer->setPriorityStyle(8, 'TABLE');
$writer->setPriorityStyle(9, 'TRACE');
$logger = new Zend_Log($writer);
$logger->addPriority('TABLE', 8);
$logger->addPriority('TRACE', 9);
Zend_Registry::set('logger', $logger);
/*
* Add our Firebug DB Profiler to the registry
*/
// require_once 'Zend/Db.php';
// require_once 'Zend/Db/Profiler/Firebug.php';
$profiler = new Zend_Db_Profiler_Firebug('All DB Queries');
$db = Zend_Db::factory('PDO_SQLITE', array('dbname' => ':memory:', 'profiler' => $profiler));
$db->getProfiler()->setEnabled(true);
Zend_Registry::set('db', $db);
/*
* Run the front controller
*/
// require_once 'Zend/Controller/Front.php';
示例9: testPriorityDuplicates
/**
* @group ZF-10170
*/
public function testPriorityDuplicates()
{
$logger = new Zend_Log();
$mock = new Zend_Log_Writer_Mock();
$logger->addWriter($mock);
try {
$logger->addPriority('emerg', 8);
$this->fail();
} catch (Exception $e) {
$this->assertTrue($e instanceof Zend_Log_Exception);
$this->assertEquals('Existing priorities cannot be overwritten', $e->getMessage());
}
try {
$logger->log('zf10170', 0);
$logger->log('clone zf10170', 8);
$this->fail();
} catch (Exception $e) {
$this->assertTrue($e instanceof Zend_Log_Exception);
$this->assertEquals('Bad log priority', $e->getMessage());
}
$this->assertEquals(0, $mock->events[0]['priority']);
$this->assertEquals('EMERG', $mock->events[0]['priorityName']);
$this->assertFalse(array_key_exists(1, $mock->events));
}
示例10: testAddLogPriority
public function testAddLogPriority()
{
$logger = new Zend_Log($this->writer);
$logger->addPriority('EIGHT', $priority = 8);
$logger->eight($message = 'eight message');
rewind($this->log);
$logdata = stream_get_contents($this->log);
$this->assertContains((string) $priority, $logdata);
$this->assertContains($message, $logdata);
}
示例11: dirname
<?php
define('ZF_APPLICATION_DIRECTORY', dirname(dirname(dirname(__FILE__))));
define('ZF_LIBRARY_DIRECTORY', dirname(ZF_APPLICATION_DIRECTORY) . '/library');
set_include_path(ZF_LIBRARY_DIRECTORY);
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
$request = new Zend_Controller_Request_Http();
$response = new Zend_Controller_Response_Http();
$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
$channel->setRequest($request);
$channel->setResponse($response);
$writer = new Zend_Log_Writer_Firebug();
$writer->setPriorityStyle(8, 'TABLE');
$logger = new Zend_Log($writer);
$logger->addPriority('TABLE', 8);
$db = Zend_Db::factory('PDO_SQLITE', array('dbname' => ':memory:'));
$profiler = new Zend_Db_Profiler_Firebug('Queries');
$profiler->setEnabled(true);
$db->setProfiler($profiler);
$db->getConnection()->exec('CREATE TABLE foo (
id INTEGNER NOT NULL,
col1 VARCHAR(10) NOT NULL
)');
$table = array('sdfsdf', array(array('sdfsdf', 'sdfsdf'), array('sdwt32g2', '23g23g')));
$logger->table($table);
$channel->flush();
$channel->getResponse()->sendHeaders();
示例12: addPriority
/**
* adds a priority in flippedPriorities array
* @param string $name
* @param integer $priority
*/
public function addPriority($name, $priority)
{
parent::addPriority($name, $priority);
$this->_flippedPriorities[strtoupper($name)] = $priority;
}
示例13: initLogging
/**
* Initialize logging.
*/
private static function initLogging()
{
$log = self::$config->curry->log;
switch ($log->method) {
case 'firebug':
self::$writer = new Zend_Log_Writer_Firebug();
self::$writer->setPriorityStyle(self::LOG_TABLE, 'TABLE');
$request = new Zend_Controller_Request_Http();
$response = new Zend_Controller_Response_Http();
$channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
$channel->setRequest($request);
$channel->setResponse($response);
ob_start();
break;
case 'file':
self::$writer = new Zend_Log_Writer_Stream($log->file);
break;
case 'none':
default:
return;
}
self::$logger = new Zend_Log(self::$writer);
self::$logger->addPriority('TABLE', self::LOG_TABLE);
self::log("Logging initialized", Zend_Log::NOTICE);
}
示例14: __construct
/**
* @return void
*/
public function __construct($functionName, array $functionParams, $functionRevision, $serviceID = 0, $clientID = 0)
{
$cIP = Zend_Controller_Action_HelperBroker::getStaticHelper('Currentip');
$this->_ip = $cIP->getCurrentIp();
$this->_functionName = $functionName;
$this->_functionParams = $functionParams;
$this->_functionRevision = $functionRevision;
$this->_clientID = $clientID;
$this->_serviceID = $serviceID;
$this->_log = new Zend_Log(new Zend_Log_Writer_Db(Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('multidb')->getDb('log'), 'log.webservice', array('priority' => 'priority', 'message' => 'message', 'ip' => 'ip', 'public_ws_client_id' => 'public_ws_client_id', 'public_ws_service_id' => 'public_ws_service_id', 'function_name' => 'function_name', 'function_params' => 'function_params', 'function_revision' => 'function_revision', 'execution_time' => 'execution_time')));
$this->_log->addPriority('E200', 200);
$this->_log->addPriority('E401', 401);
$this->_log->addPriority('E402', 402);
$this->_log->addPriority('E405', 405);
$this->_log->addPriority('E406', 406);
$this->_log->addPriority('E407', 407);
$this->_log->addPriority('E410', 410);
$this->_log->addPriority('E415', 415);
$this->_log->addPriority('E416', 416);
$this->_log->addPriority('E417', 417);
$this->_log->addPriority('E420', 420);
$this->_log->addPriority('E421', 421);
$this->_log->addPriority('E422', 422);
$this->_log->addPriority('E423', 423);
$this->_log->addPriority('E424', 424);
$this->_log->addPriority('E425', 425);
$this->_log->addPriority('E430', 430);
$this->_log->addPriority('E431', 431);
$this->_log->addPriority('E432', 432);
$this->_log->addPriority('E440', 440);
$this->_log->addPriority('E441', 441);
$this->_log->addPriority('E442', 442);
$this->_log->addPriority('E443', 443);
$this->_log->addPriority('E444', 444);
$this->_log->addPriority('E445', 445);
$this->_log->addPriority('E446', 446);
$this->_log->addPriority('E447', 447);
$this->_log->addPriority('E448', 448);
$this->_log->addPriority('E449', 449);
$this->_log->addPriority('E450', 450);
$this->_log->addPriority('E451', 451);
$this->_log->addPriority('E452', 452);
$this->_log->addPriority('E453', 453);
$this->_log->addPriority('E501', 501);
$this->_log->addPriority('E510', 510);
$this->_log->addPriority('E511', 511);
$this->_log->addPriority('E512', 512);
$this->_log->addPriority('E520', 520);
}
示例15: _initLog
/**
* Initialization Log, Search, KCFinder
*
* @return void
*/
protected function _initLog()
{
$params = array();
//------------------
$_startTime = microtime(1);
//Получим конфигурацию
$config = $this->_options;
//----- Create Zend_Log object -----
$columnMapping = array('ts' => 'timestamp', 'msg' => 'message', 'pr' => 'priority', 'pr_name' => 'priorityName');
$countMsg = $config['logging']['log']['max_rows'];
$countEx = $config['logging']['exeption']['max_rows'];
$countStat = $config['logging']['statistics']['max_rows'];
// Get DB
$db = Zend_Registry::get('db');
// Set params
$params['db'] = $db;
$params['columnMap'] = $columnMapping;
// Create writer for DB
$params['table'] = 'log_msg';
$params['max_rows'] = $countMsg;
$writerMsg = new Default_Model_Log($params);
$params['table'] = 'log_error';
$params['max_rows'] = $countEx;
$writerEx = new Default_Model_Log($params);
$params['table'] = 'log_stat';
$params['max_rows'] = $countStat;
$writerStat = new Default_Model_Log($params);
// Create logers
$logMsg = new Zend_Log($writerMsg);
$logEx = new Zend_Log($writerEx);
$logStat = new Zend_Log($writerStat);
// Adding new priorities for the $logMsg
$logMsg->addPriority('LOGIN_OK', 8);
$logMsg->addPriority('LOGIN_ERR', 9);
$logMsg->addPriority('LOGOUT', 10);
$logMsg->addPriority('REG_OK', 11);
$logMsg->addPriority('REG_ERR', 12);
$logMsg->addPriority('DETAILS_OK', 13);
$logMsg->addPriority('FETCHPASS_COMPLETE_OK', 14);
$logMsg->addPriority('FETCHPASS_COMPLETE_ERR', 15);
$logMsg->addPriority('FETCHPASS_CONFIRM_OK', 16);
$logMsg->addPriority('FETCHPASS_CONFIRM_ERR', 17);
$logMsg->addPriority('MAIL_OK', 18);
$logMsg->addPriority('MAIL_ERR', 19);
$logMsg->addPriority('DB_SAVE_ERR', 20);
$logMsg->addPriority('DB_DELETE_ERR', 21);
$logMsg->addPriority('POST_EDIT', 22);
$logMsg->addPriority('POST_SET_STATUS', 23);
$logMsg->addPriority('ADMIN_POST_EDIT', 24);
$logMsg->addPriority('ADMIN_ROW_UPDATE', 25);
$logMsg->addPriority('ADMIN_ROW_INSERT', 26);
$logMsg->addPriority('ADMIN_ROW_DELETE', 27);
$logMsg->addPriority('MY_MSG', 28);
// Adding new priorities for the $logStat
$logStat->addPriority('LOGIN_OK', 8);
$logStat->addPriority('LOGIN_ERR', 9);
$logStat->addPriority('MAIL_OK', 10);
$logStat->addPriority('FETCHPASS_COMPLETE_OK', 11);
$logStat->addPriority('FETCHPASS_COMPLETE_ERR', 12);
$logStat->addPriority('FETCHPASS_CONFIRM_OK', 13);
$logStat->addPriority('FETCHPASS_CONFIRM_ERR', 14);
$logStat->addPriority('POST_OPEN', 15);
$logStat->addPriority('VIDEO_PLAY', 16);
$logStat->addPriority('AUDIO_PLAY', 17);
$emailParams = $config['logging']['email'];
if ($emailParams['send']) {
$mail = Default_Plugin_SysBox::createMail($emailParams);
$writer = new Zend_Log_Writer_Mail($mail);
$my_request = Default_Plugin_SysBox::getUrlRequest();
if (!$emailParams['subject']) {
$writer->setSubjectPrependText('Errors request - ' . $my_request);
}
$writer->addFilter(Zend_Log::EMERG);
$writer->addFilter(Zend_Log::ALERT);
$writer->addFilter(Zend_Log::CRIT);
$writer->addFilter(Zend_Log::ERR);
$logger->addWriter($writer);
}
// Save to Registry
Zend_Registry::set("Zend_Log", $logMsg);
Zend_Registry::set("Zend_LogEx", $logEx);
Zend_Registry::set("Zend_LogStat", $logStat);
// Remember in the session array of search results
$Zend_Auth = Zend_Registry::get("Zend_Auth");
if (!$Zend_Auth->search) {
$Zend_Auth->search = array();
}
//------------ Configure default search -------------
// Establish a query analyzer in the coding Utf8
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
//------ Initialization file manager -------------
Default_Plugin_SysBox::iniKCFinder();
//---- Defining script execution time ----
$infoProfiler = Default_Plugin_SysBox::Translate("Время выполнения") . " Bootstrap_initLog(): ";
Default_Plugin_SysBox::profilerTime2Registry($_startTime, $infoProfiler);
//.........这里部分代码省略.........