本文整理汇总了PHP中Zend_Log::log方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Log::log方法的具体用法?PHP Zend_Log::log怎么用?PHP Zend_Log::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Log
的用法示例。
在下文中一共展示了Zend_Log::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: errorAction
public function errorAction()
{
$errors = $this->_getParam('error_handler');
$logger = new Zend_Log();
$writer = new Zend_Log_Writer_Stream(dirname(APPLICATION_PATH) . '/logs/exceptions.log');
$logger->addWriter($writer);
//$logger->addWriter(new Keplin_Log_Writer_Email());
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
// 404 error -- controller or action not found
$this->getResponse()->setHttpResponseCode(404);
$this->view->message = 'Page not found';
$logger->log($errors->exception->getMessage(), Zend_Log::NOTICE);
break;
default:
// application error
$this->getResponse()->setHttpResponseCode(500);
$this->view->message = 'Application error';
if (get_class($errors->exception) == 'Keplin_ProhibitedException') {
$this->view->message = 'Access Prohibited.';
$logger->log($errors->exception->getMessage(), Zend_Log::WARN);
} else {
$logger->log($errors->exception->getMessage(), Zend_Log::ERR);
}
break;
}
// conditionally display exceptions
if ($this->getInvokeArg('displayExceptions') == true) {
$this->view->exception = $errors->exception;
}
$this->view->request = $errors->request;
}
示例2: logUpdate
private function logUpdate($eventType, $table, $oldValue, $newValue, $user)
{
$timestamp = Zend_Date::now()->toString('yyyy-MM-dd HH:mm:ss');
if ($this->trackFields != null) {
// insert a log for each tracked field
foreach ($this->trackFields as $field) {
if (isset($oldValue[$field]) && isset($newValue[$field])) {
if ($oldValue[$field] != $newValue[$field]) {
$this->setColEventType(self::EVENT_TYPE_UPDATE);
$this->setColEventDate($timestamp);
$this->setColFieldName($field);
$this->setColRecordId($oldValue['id']);
$this->setColAppAccountId($user['appaccount_id']);
$this->setColUserId($user['user_id']);
$this->setColTableName($table);
$this->setColFieldTextType(false);
$this->setColValue($oldValue[$field]);
$this->log->log('UPDATE on database', Zend_Log::INFO);
}
}
}
} else {
throw new Agana_Exception('Track Fields for audit trail is not set');
}
}
示例3: echoAction
public function echoAction()
{
$console = $this->getConsoleOptions(array('name|n=s' => 'Tell me your name'));
$message = 'Hello ' . $console->getOption("name");
echo $message, "\n";
$this->_logger->log($message, Zend_Log::INFO);
exit(0);
}
示例4: log
/**
* Logs with an arbitrary level.
*
* @param int $level
* @param string $message
* @param array $context
*
* @return null
*/
public function log($level, $message, array $context = [])
{
if (!isset($this->logMap[$level])) {
throw new \InvalidArgumentException('Level is not supported. See "Psr\\Log\\LogLevel"');
}
$zendLogLevel = $this->logMap[$level];
//Proxy log
$this->logger->log($message, $zendLogLevel);
}
示例5: _write
/**
* calls prent _write and and writes temp log file
*
* @param array $event Event data
* @return void
*/
protected function _write($event)
{
if (!is_file($this->_tempfile)) {
@\Pimcore\File::put($this->_tempfile, "... continued ...\r\n");
$writerFile = new \Zend_Log_Writer_Stream($this->_tempfile);
$this->_tempLogger = new \Zend_Log($writerFile);
}
$this->_tempLogger->log($event['message'], $event['priority']);
parent::_write($event);
}
示例6: indexAction
public function indexAction()
{
// writer
$writer = new Zend_Log_Writer_Firebug();
// log
$log = new Zend_Log($writer);
// messages
$log->log($_REQUEST, Zend_Log::ERR);
$log->log($_ENV, Zend_Log::ALERT);
$log->log($_SERVER, Zend_Log::ALERT);
}
示例7: _write
/**
* calls prent _write and and writes temp log file
*
* @param array $event Event data
* @return void
*/
protected function _write($event)
{
if (!is_file($this->_tempfile)) {
$fh = @fopen($this->_tempfile, 'a');
@fwrite($fh, "... continued ...\r\n");
@fclose($fh);
$writerFile = new Zend_Log_Writer_Stream($this->_tempfile);
$this->_tempLogger = new Zend_Log($writerFile);
}
$this->_tempLogger->log($event['message'], $event['priority']);
parent::_write($event);
}
示例8: fires
/**
* Required by ZIDS_Plugin_ActionPlugin_Interface
* Writes output to Zend_Log instance registered
*
* @return void
*/
public function fires(IDS_Report $ids_result, $impact, $levelname)
{
// get options for the log plugin
$options = $this->getOptions($levelname);
// parse log->items parameters
$this->_logitems = explode(',', $options['items']);
array_walk($this->_logitems, create_function('&$arr', '$arr=trim($arr);'));
if (null == $this->_log) {
throw new Exception('ZIDS cannot use the log action unless you register a Zend_Log instance.');
}
$this->_log->log($this->getNotificationString($impact, $ids_result, $levelname), $options['loglevel']);
}
示例9: log
/**
* @param string $websiteId
* @param string $id
* @param string $name
* @param string $additionalinfo
* @param integer $timestamp
* @param string $userid
* @param string $action
* @param integer $priority
*/
protected function log($websiteId, $id, $name, $additionalinfo, $timestamp, $userlogin, $action, $priority = \Zend_Log::INFO)
{
if ((int) $priority > (int) $this->level) {
return;
}
$this->logger->setEventItem('websiteid', $websiteId);
$this->logger->setEventItem('id', $id);
$this->logger->setEventItem('name', $name);
$this->logger->setEventItem('additionalinfo', $additionalinfo);
$this->logger->setEventItem('timestamp', $timestamp);
$this->logger->setEventItem('userlogin', $userlogin);
$this->logger->setEventItem('action', $action);
$this->logger->log($action, $priority);
}
示例10: log
/**
* Log a message.
*
* @param string $message
* @param string $type
*/
public function log($message, $type = null)
{
if (isset($message['type']) && !isset($type)) {
$type = $message['type'];
}
unset($message['type']);
if (is_array($message)) {
$message = count($message) == 1 ? reset($message) : '[' . join('] [', $message) . ']';
}
try {
$this->zendlog->log($message, isset($this->alias[$type]) ? $this->alias[$type] : $this->alias[null]);
} catch (\Exception $e) {
trigger_error('Logging using ' . get_class($this->zendlog) . ' failed: ' . $e->getMessage(), E_USER_WARNING);
}
}
示例11: preDispatch
public function preDispatch($request)
{
try {
$locale = new Zend_Locale();
$locale->setDefault('en');
$locale->setLocale(Zend_Locale::BROWSER);
$requestedLanguage = key($locale->getBrowser());
$formatter = new Zend_Log_Formatter_Simple('%message%' . PHP_EOL);
$writer = new Zend_Log_Writer_Stream(APPLICATION_LOG_PATH . 'translations.log');
$writer->setFormatter($formatter);
$logger = new Zend_Log($writer);
$frontendOptions = array('cache_id_prefix' => 'translation', 'lifetime' => 86400, 'automatic_serialization' => true);
$backendOptions = array('cache_dir' => APPLICATION_CACHE_PATH);
$cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
$options = array('adapter' => 'gettext', 'scan' => Zend_Translate::LOCALE_FILENAME, 'content' => APPLICATION_PATH . '/languages/en/en.mo', 'locale' => 'auto', 'disableNotices' => true);
$translate = new Zend_Translate($options);
if (!$translate->isAvailable($locale->getLanguage())) {
$locale->setLocale('en');
} else {
$translate->setLocale($locale);
}
$translate->setCache($cache);
Zend_Registry::set('locale', $locale->getLanguage());
Zend_Registry::set('Zend_Translate', $translate);
} catch (Exception $e) {
try {
$writer = new Zend_Log_Writer_Stream(APPLICATION_LOG_PATH . 'plugin-locale.log');
$logger = new Zend_Log($writer);
$logger->log($e->getMessage(), Zend_Log::ERR);
} catch (Exception $e) {
}
}
}
示例12: _initLog
protected function _initLog()
{
$log = new Zend_Log();
$log->setEventItem('domain', 'error');
// Non-production
if (APPLICATION_ENV !== 'production') {
$log->addWriter(new Zend_Log_Writer_Firebug());
}
// Get log config
try {
$log->addWriter(new Zend_Log_Writer_Stream(WEB_ROOT . '/temporary/log/main.log'));
} catch (Exception $e) {
// Check directory
if (!@is_dir(WEB_ROOT . '/temporary/log') && @mkdir(WEB_ROOT . '/temporary/log', 0777, true)) {
$log->addWriter(new Zend_Log_Writer_Stream(WEB_ROOT . '/temporary/log/main.log'));
} else {
// Silence ...
if (APPLICATION_ENV !== 'production') {
$log->log($e->__toString(), Zend_Log::CRIT);
} else {
// Make sure logging doesn't cause exceptions
$log->addWriter(new Zend_Log_Writer_Null());
}
}
}
// Save to registry
Zend_Registry::set('Zend_Log', $log);
return $log;
}
示例13: preDispatch
/**
* PreDispatch method for ACL Plugin. It checks if current user has privileges for resources requested
* @see Zend_Controller_Plugin_Abstract::preDispatch()
* @param Zend_Controller_Request_Abstract $request
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
try {
$module = strtolower($request->getParam('module'));
$controller = strtolower($request->getParam('controller'));
$action = strtolower($request->getParam('action'));
$resource = $module . ":" . $controller;
$acl = Zend_Registry::get('ZendACL');
$auth = Zend_Auth::getInstance();
$identity = $auth->getIdentity();
$roleID = $auth->hasIdentity() ? $auth->getIdentity()->role_id : 3;
#var_dump($acl->isAllowed( $roleID, $resource, $action), $roleID, $resource, $action);
#Zend_Debug::dump($module, $controller, $action, $roleID, $acl);
#die();
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
if ($acl->isAllowed($roleID, $resource, $action) != true) {
$redirector->gotoUrl('logout')->redirectAndExit();
} else {
return;
}
} catch (Exception $e) {
try {
$writer = new Zend_Log_Writer_Stream(APPLICATION_LOG_PATH . 'plugins.log');
$logger = new Zend_Log($writer);
$logger->log($e->getMessage(), Zend_Log::ERR);
} catch (Exception $e) {
}
}
}
示例14: log
/**
* Logs the message to the log with the given priority.
*
* This method only works if the Log Level is higher than the given priority.
* If there is no logger object than this method will instantiate it.
* In contrary to the debug statement this only logs strings.
*
* @see DocBlock_Abstract::setLogLevel()
* @see Zend_Log
* @param string $message
* @return void
*/
public function log($message, $priority = Zend_Log::INFO)
{
// is the log level is below the priority; just skip this
if ($this->getLogLevel() < $priority)
{
return;
}
if ($priority == Zend_Log::DEBUG)
{
$this->debug($message);
return;
}
if (!self::$logger)
{
$file = str_replace(array('{DATE}'), array(date('YmdHis')), $this->getConfig()->logging->paths->default);
self::$logger = new Zend_Log(new Zend_Log_Writer_Stream(fopen($file, 'w')));
}
static $priority_names = null;
if ($priority_names === null)
{
$r = new ReflectionClass('Zend_Log');
$priority_names = array_flip($r->getConstants());
}
$debug_info = ($this->getLogLevel() == Zend_Log::DEBUG) ? ', '.round(memory_get_usage() / 1024 / 1024, 2).'mb' : '';
echo '['.$priority_names[$priority].': '.date('H:i').$debug_info.']: '.$message.PHP_EOL;
self::$logger->log($message, $priority);
}
示例15: log
private function log()
{
$dir = APP_PATH . '/logs/request';
if (!is_dir($dir)) {
mkdir($dir, 0755);
}
$file = $dir . '/' . date('Y-m-d') . '.log';
$logger = new \Zend_Log();
$formatter = new \Zend_Log_Formatter_Simple("%message%\n");
$writer = new \Zend_Log_Writer_Stream($file);
$writer->setFormatter($formatter);
$logger->addWriter($writer);
$data = array();
$data[] = '[' . date('Y-m-d H:i:s') . '] ';
$url = Http::getUrl('current');
$url = substr($url, 0, strpos($url, '?')) . '?' . http_build_query($this->getRequest()->getRequest());
$data[] = $url;
$line = implode('', $data);
$debug = Application::app()->getConfig()->debug;
if ($debug) {
$res = $this->getResponse()->getBody('api');
$line .= "\n\t" . $res;
}
$logger->log($line, $logger::NOTICE);
}