本文整理汇总了PHP中Zend_Log_Writer_Stream类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Log_Writer_Stream类的具体用法?PHP Zend_Log_Writer_Stream怎么用?PHP Zend_Log_Writer_Stream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Log_Writer_Stream类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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) {
}
}
}
开发者ID:rogercastaneda,项目名称:owlsys,代码行数:33,代码来源:Locale.php
示例2: 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);
}
开发者ID:ares333,项目名称:php-api-system,代码行数:25,代码来源:Index.php
示例3: addWriteToScreen
function addWriteToScreen()
{
parent::addWriteToScreen();
$writerScreen = new Zend_Log_Writer_Stream('php://stderr');
$writerScreen->setFormatter( $this->screenFormatter );
$this->addWriter($writerScreen);
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:7,代码来源:Exception.php
示例4: init
/**
* @return Zend_Log
*/
public function init()
{
$bootstrap = $this->getBootstrap();
$bootstrap->bootstrap('Config');
$config = $bootstrap->getResource('Config');
if (!$config->log->errors && !$config->log->sql) {
return;
}
$logFile = LOGS_DIR . '/' . 'errors.log';
if (!is_writable($logFile)) {
throw new RuntimeException('Error log file cannot be written to. Please give this file read/write permissions for the web server.');
}
$writer = new Zend_Log_Writer_Stream($logFile);
$logger = new Zend_Log($writer);
if (isset($config->log->priority)) {
$priority = $config->log->priority;
if (defined($priority)) {
$writer->addFilter(constant($priority));
}
}
if (!empty($config->debug->email)) {
$bootstrap->bootstrap('Mail');
$this->_addMailWriter($logger, (string) $config->debug->email, $config->debug->emailLogPriority);
}
return $logger;
}
开发者ID:lchen01,项目名称:STEdwards,代码行数:29,代码来源:Logger.php
示例5: setup
/**
* Setup db
*
*/
public function setup(Zend_Config $config)
{
// Get resource config
$writerConfig = $config->writer;
$filterConfig = $config->filter;
// Log instance
$log = new Zend_Log();
// Enable database writer?
if ($writerConfig->database->enabled) {
$db = $this->getRegistry()->get($writerConfig->database->key, 'Zend_Db_Adapter_Abstract');
// Make sure it's a right object
if (!$db instanceof Zend_Db_Adapter_Abstract) {
require_once 'Zym/App/Resource/Exception.php';
throw new Zym_App_Resource_Exception('Resource ' . get_class($this) . ' requires the internal registry item "db" to contain a Zend_Db_Adapter_Abstract object');
}
$dbWriter = new Zend_Log_Writer_Db($db, $writerConfig->database->table);
$log->addWriter($dbWriter);
}
// Enable stream writer?
if ($writerConfig->stream->enabled) {
$streamWriter = new Zend_Log_Writer_Stream($writerConfig->stream->stream, $writerConfig->stream->mode);
$streamWriter->setFormatter(new Zend_Log_Formatter_Simple('%timestamp% %ipAddr% %priorityName% (%priority%): %message%' . PHP_EOL));
$log->addWriter($streamWriter);
}
// Enable null writer
$log->addWriter(new Zend_Log_Writer_Null());
// Setup filters
// Priority filter
if ($filterConfig->priority->enabled) {
$log->addFilter(new Zend_Log_Filter_Priority((int) $filterConfig->priority->level));
}
// Setup events
// Log user ip address
//$log->setEventItem('ipAddr', $_SERVER['REMOTE_ADDR']);
}
开发者ID:BGCX262,项目名称:zym-svn-to-git,代码行数:39,代码来源:Log.php
示例6: addStreamWriter
/**
* Add a stream writer
*
* @param array $params
* @param object $formatter
* @return void
*/
public function addStreamWriter($params = array(), Zend_Log_Formatter_Interface $formatter = null)
{
$writer = new Zend_Log_Writer_Stream($params['file_path_url'], $params['mode']);
if ($formatter) {
$writer->setFormatter($formatter);
}
$this->addWriter($writer);
}
开发者ID:sarwarzahan,项目名称:multi-logging,代码行数:15,代码来源:Log.php
示例7: initDefault
public static function initDefault($logFilePath)
{
$writer = new Zend_Log_Writer_Stream($logFilePath);
$format = '[%timestamp%] [%priorityName% %priority%] %message%' . PHP_EOL;
$formatter = new Zend_Log_Formatter_Simple($format);
$writer->setFormatter($formatter);
Logger::registerLogger('default', $writer, null, true);
}
开发者ID:uning,项目名称:backend_common,代码行数:8,代码来源:Logger.php
示例8: initLogger
/**
* Initialise the logger with the given file.
*/
private function initLogger($logfileName)
{
$logfile = @fopen($logfileName, 'a', false);
$writer = new Zend_Log_Writer_Stream($logfile);
$formatter = new Zend_Log_Formatter_Simple('%priorityName%: %message%' . PHP_EOL);
$writer->setFormatter($formatter);
$this->logger = new Zend_Log($writer);
}
开发者ID:alexukua,项目名称:opus4,代码行数:11,代码来源:MigrateSeriesCollections.php
示例9: _initLog
/**
* set logger
* @return void
*/
protected function _initLog()
{
// Error log
$writer = new Zend_Log_Writer_Stream($this->_config->logpath);
$format = '%timestamp% %priorityName% (%priority%): ' . '[%module%] [%controller%] %message%' . PHP_EOL;
$formatter = new Zend_Log_Formatter_Simple($format);
$writer->setFormatter($formatter);
$logger = new Zend_Log($writer);
Zend_Registry::getInstance()->set('logger', $logger);
}
开发者ID:abtris,项目名称:retreatin,代码行数:14,代码来源:Bootstrap.php
示例10: saveCdrDedicatorias
public function saveCdrDedicatorias($resultado)
{
$name = date('YmdH');
$datos = $this->registerCdr();
$writer = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../logs/cdr/' . $name . ".dedicatoria");
$formatter = new Zend_Log_Formatter_Simple('%message%' . PHP_EOL);
$writer->setFormatter($formatter);
$log = new Zend_Log($writer);
$mensaje = $datos['fecha'] . "," . $datos['hora'] . "," . $_SERVER['REMOTE_ADDR'] . "," . $datos['telefono'] . "," . 'perfil:' . $datos['perfil'] . "," . $resultado;
$log->info($mensaje);
}
开发者ID:josmel,项目名称:DevelEntretenimientoEntel,代码行数:11,代码来源:ConfigPerfil.php
示例11: saveCdrBanners
private function saveCdrBanners($datos, $id, $name)
{
$writer = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../logs/cdr/' . $name . ".banners");
// $writer = new Zend_Log_Writer_Stream('/var/log/portalwap/'.$name.".banners");
$formatter = new Zend_Log_Formatter_Simple('%message%' . PHP_EOL);
$writer->setFormatter($formatter);
$log = new Zend_Log($writer);
$banners = 'banner1.' . $datos['url'][0] . "," . 'banner2.' . $datos['url'][1] . "," . 'banner3.' . $datos['url'][2] . "," . 'banner4.' . $datos['url'][3] . "," . 'banner5.' . $datos['url'][4];
$mensaje = $datos['fecha'] . "," . $datos['hora'] . "," . $_SERVER['REMOTE_ADDR'] . "," . $datos['telefono'] . ",perfil:" . $datos['perfil'] . "," . $banners;
$log->info($mensaje);
}
开发者ID:josmel,项目名称:PortalWapMovistar,代码行数:11,代码来源:Cdr.php
示例12: _setupLog
/**
* Initialize the logger. You may want to override the function
*
* @return void
*/
protected function _setupLog()
{
$this->logger = new Streamwide_Log();
$this->logger->setEventItem("class", get_class($this));
$writer = new Zend_Log_Writer_Stream("php://output");
$format = "SW | %class% | %timestamp% | %pid% | %memory% | %duration% | %priorityName%: %message%<br/>" . PHP_EOL;
$formater = new Zend_Log_Formatter_Simple($format);
$writer->setFormatter($formater);
//$writer->addFilter(new Streamwide_Log_Filter_Priority(LOGGER_INFO));
$this->logger->addWriter($writer);
}
开发者ID:cwcw,项目名称:cms,代码行数:16,代码来源:Abstract.php
示例13: saveCdrLog
public function saveCdrLog($url, $message, $portal)
{
$datos = $this->obtenerPerfilNumero();
$name = date('YmdH');
$writer = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../data/cdr/' . $portal . '/' . $name . ".log");
$formatter = new Zend_Log_Formatter_Simple('%message%' . PHP_EOL);
$writer->setFormatter($formatter);
$log = new Zend_Log($writer);
$mensaje = $datos['fecha'] . "," . $datos['hora'] . "," . 'PERFIL:' . $datos['perfil'] . "," . $url . "," . $message . "," . $datos['telefono'];
$log->info($mensaje);
}
开发者ID:josmel,项目名称:DevelEntelBipPe,代码行数:11,代码来源:ConfigPerfil.php
示例14: saveLog
protected function saveLog($errors)
{
$logger = new Zend_Log();
$writer = new Zend_Log_Writer_Stream('application/tmp/erro/error.xml');
$formatter = new Zend_Log_Formatter_Xml();
$writer->setFormatter($formatter);
$logger->addWriter($writer);
$exception = $errors->exception;
$exception->getTraceAsString();
$logger->debug($exception->getMessage() . "\r\n");
}
开发者ID:erickosma,项目名称:e-ong,代码行数:11,代码来源:ErrorController.php
示例15: _allWriter
/**
* Writer untuk log message yang lainnya
* Log message yang lainnya akan dituliskan ke dalam file system.log
*/
protected function _allWriter()
{
$log = ROOT_DIR . '/data/log/system.log';
$stream = fopen($log, 'a', false);
if (!$stream) {
throw new Exception('Failed to open _writer stream');
}
$writer = new Zend_Log_Writer_Stream($stream);
$writer->setFormatter($this->_formatter);
return $writer;
}
开发者ID:hukumonline,项目名称:pmg,代码行数:15,代码来源:Log.php
示例16: 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);
}
开发者ID:aimeos,项目名称:ai-zend,代码行数:19,代码来源:ZendTest.php
示例17: getLog
/**
* Retrieves the logger object
*
* @return Zend_Log
* @throws Glitch_Application_Resource_Exception
*/
public function getLog()
{
if (null === $this->_log) {
$options = $this->getOptions();
// Force these options to be set - don't rely on the defaults!
if (!isset($options['level'])) {
throw new Glitch_Application_Resource_Exception('Undefined log option: "level"');
}
// Validate the log level
$level = constant('Zend_Log::' . $options['level']);
if (null === $level) {
throw new Glitch_Application_Resource_Exception('Unknown log level: "' . $options['level'] . '"');
}
// Ensure the request is initialized
$this->_bootstrap->bootstrap('Request');
$request = $this->_bootstrap->getResource('Request');
$isHttpRequest = $request instanceof Zend_Controller_Request_Http;
// Use localhost as name if not running in HTTP mode
$host = $isHttpRequest ? $request->getHttpHost() : 'localhost';
if (strncasecmp($host, 'www.', 4) == 0) {
$host = substr($host, 4);
// Remove "www." prefix for readability
}
$this->_log = new Zend_Log();
// Build filename, e.g. "20090601_localhost.log"
$file = Zend_Date::now()->toString('yyyyMMdd') . '_' . $host . '.log';
$file = GLITCH_LOGS_PATH . DIRECTORY_SEPARATOR . $file;
$writer = new Zend_Log_Writer_Stream($file);
// Use custom logging format, e.g.
// [2010-08-07T17:03:18+02:00] ERR (/account/login): Method "_getParams" does not exist
$format = '[%timestamp%] %priorityName%';
if ($isHttpRequest) {
$format .= ' (%requestUri%)';
$this->_log->setEventItem('requestUri', $request->getRequestUri());
}
$format .= ': %message%';
$formatter = new Zend_Log_Formatter_Simple($format . PHP_EOL);
$writer->setFormatter($formatter);
$this->_log->addWriter($writer);
// Also send log output to browser console?
if ($isHttpRequest && (isset($options['toFirebug']) && $options['toFirebug'])) {
$this->_log->addWriter(new Zend_Log_Writer_Firebug());
}
$filter = new Zend_Log_Filter_Priority($level);
$this->_log->addFilter($filter);
// Allow application-wide access
Glitch_Registry::setLog($this->_log);
}
return $this->_log;
}
开发者ID:nstapelbroek,项目名称:Glitch_Lib,代码行数:56,代码来源:Log.php
示例18: _initSystemLog
protected function _initSystemLog()
{
$sysLogFile = Agana_Util_Log::getSystemLogPath($this);
$fp = @fopen($sysLogFile, 'a+', false);
if ($fp) {
$sysLog = new Zend_Log_Writer_Stream($fp);
$formatter = new Zend_Log_Formatter_Xml();
$sysLog->setFormatter($formatter);
} else {
// TODO improve this
die('App error log file or directory is not writable');
}
$systemLogger = new Zend_Log($sysLog);
Zend_Registry::set(self::APP_ERROR_LOGGER, $systemLogger);
}
开发者ID:brunopbaffonso,项目名称:ongonline,代码行数:15,代码来源:Bootstrap.php
示例19: _initDefaultWriter
/**
* Init default logger
*
* @return Zend_Log_Writer_Abstract
*/
private function _initDefaultWriter()
{
$writer = Zend_Log_Writer_Stream::factory(['stream' => Mage::getBaseDir('log') . DS . Mage::getStoreConfig('messenger/log/file')]);
$formatter = Mage::getModel('messenger/log_formatter')->factory(Mage::getStoreConfig('messenger/log/format'));
$writer->setFormatter($formatter);
return $writer;
}
开发者ID:rockxcn,项目名称:messenger,代码行数:12,代码来源:Logger.php
示例20: _initLogger
/**
* Setup console logger
*
* @return void
*/
private function _initLogger()
{
$writer = Zend_Log_Writer_Stream::factory(['stream' => 'php://stdout']);
$formatter = Mage::getModel('messenger/log_formatter')->factory($this->getArg('log-format'));
$writer->setFormatter($formatter);
Mage::getSingleton('messenger/di')->container()->instanceManager()->setParameters('log', ['writer' => $writer]);
}
开发者ID:rockxcn,项目名称:messenger,代码行数:12,代码来源:abstract.php
注:本文中的Zend_Log_Writer_Stream类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论