本文整理汇总了PHP中Zend_Log::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Log::__construct方法的具体用法?PHP Zend_Log::__construct怎么用?PHP Zend_Log::__construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Log
的用法示例。
在下文中一共展示了Zend_Log::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$writer = new Log_Writer_Console();
parent::__construct($writer);
$enable = Zend_Registry::get("configuration")->log->enable;
$this->setEnable($enable);
}
示例2: __construct
/**
* Class constructor. Create a new logger.
*
* @param Streamwide_Log_Writer_Abstract $writer (optional) Default writer.
*/
public function __construct($writer = null)
{
parent::__construct($writer);
$this->_priorities[Zend_Log::ERR] = 'ERROR';
$this->_priorities[Zend_Log::WARN] = 'WARNING';
$this->_start = $this->_last = $this->_getmicrotime();
$this->_memMin = $this->_memMax = memory_get_usage();
}
示例3: __construct
/**
* Class constructor. Create a new logger
*
* @param Zend_Log_Writer_Abstract|null $writer default writer
* @return void
*/
public function __construct(Zend_Log_Writer_Abstract $writer = null)
{
parent::__construct($writer);
if ($pid = getmypid()) {
$this->stamp = 'p' . $pid;
} else {
$this->stamp = substr(md5($_SERVER['REQUEST_TIME'] . rand(0, 100)), 0, 7);
}
}
示例4:
function __construct($logToFileFilename, $fileFormatter, $screenFormatter, $logToDatabaseTableName, $logToDatabaseColumnMapping)
{
parent::__construct();
$this->logToFileFilename = Zend_Registry::get('config')->path->log . $logToFileFilename;
$this->fileFormatter = $fileFormatter;
$this->screenFormatter = $screenFormatter;
$this->logToDatabaseTableName = Piwik::prefixTable($logToDatabaseTableName);
$this->logToDatabaseColumnMapping = $logToDatabaseColumnMapping;
}
示例5:
function __construct($logToFileFilename, $fileFormatter, $screenFormatter, $logToDatabaseTableName, $logToDatabaseColumnMapping)
{
parent::__construct();
$this->logToFileFilename = PIWIK_INCLUDE_PATH . '/' . Zend_Registry::get('config')->log->logger_file_path . $logToFileFilename;
$this->fileFormatter = $fileFormatter;
$this->screenFormatter = $screenFormatter;
$this->logToDatabaseTableName = Piwik::prefixTable($logToDatabaseTableName);
$this->logToDatabaseColumnMapping = $logToDatabaseColumnMapping;
}
示例6: __construct
public function __construct($logFilename = null, $description = null, $logDirectory = null)
{
// If no directory entered, user the default log folder
if ($logDirectory === null) {
$logDirectory = realpath(PUBLIC_PATH . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'temp' . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR;
} else {
$logDirectory = realpath($logDirectory) . DIRECTORY_SEPARATOR;
}
if ($logDirectory !== false) {
// If no filename entered, create a new name
$this->_filename = $logFilename;
if ($logFilename === null) {
$this->_filename = 'log';
}
$currentDate = new Zend_Date();
// Get the microtime
$microtime = microtime();
$microtime = str_replace('.', '', $microtime);
$microtime = str_replace(' ', '', $microtime);
// Prepend the current date and time to the filename
$this->_filename = $currentDate->toString('yyyy-MM-dd-HH-mm-ss') . '_' . $microtime . '_' . $this->_filename;
// Build the complete filename (including the complete path)
$this->_filename = $logDirectory . $this->_filename . '.txt';
// If the log file allready exists, try to create a unique filename by
// appending a number to the filename
$i = 1;
while (is_file($this->_filename) && $i < 100) {
$this->_filename = $logDirectory . '_' . $i . '.txt';
$i++;
}
// If it is not possible to create a unique filename, throw an error
if (is_file($this->_filename)) {
throw new Zend_Controller_Action_Exception('Cannot create the log file. The log file allready exists.');
}
// Add a stream writer to the log object
$logWriter = new Zend_Log_Writer_Stream($this->_filename);
// Construct the parent log object
parent::__construct($logWriter);
// Set the timestamp format in the log
$this->setTimestampFormat('Y-m-d H:i:s');
// Calculate the start time
$mtime = microtime();
$mtime = explode(' ', $mtime);
$mtime = $mtime[1] + $mtime[0];
$this->_startTime = $mtime;
$currentDate = new Zend_Date();
// Write the import header to the log
$this->log('------------------------------------', 6);
if ($description !== null) {
$this->log(' Description: ' . $description, 6);
}
$this->log(' Log File: ' . $this->_filename, 6);
$this->log(' Start: ' . $currentDate->toString('yyyy-MM-dd HH:mm:ss:S'), 6);
$this->log('------------------------------------', 6);
}
}
示例7: __construct
public function __construct()
{
// set formatter, disini ditambahkan %class% untuk informasi
// log message dihasilkan dari class mana
$format = '%timestamp% (%priorityName%) %priority% %class%: %message%' . PHP_EOL;
$this->_formatter = new Zend_Log_Formatter_Simple($format);
parent::addWriter($this->_errorWriter());
parent::addWriter($this->_allWriter());
parent::__construct();
}
示例8: __construct
/**
* Constructor, we added some interesting info to log
*/
public function __construct(Zend_Log_Writer_Abstract $writer = null)
{
if ($this->debugLevel > 0) {
$writer = new Zend_Log_Writer_Mock();
} else {
$writer = new Zend_Log_Writer_Null();
}
parent::__construct($writer);
$this->initNewProps();
if ($this->debugLevel >= 2) {
$this->addFirebugWriter();
}
}
示例9:
function __construct($logToFileFilename, $fileFormatter, $screenFormatter, $logToDatabaseTableName, $logToDatabaseColumnMapping)
{
parent::__construct();
$log_dir = Zend_Registry::get('config')->log->logger_file_path;
if ($log_dir[0] != '/' && $log_dir[0] != DIRECTORY_SEPARATOR) {
$log_dir = PIWIK_USER_PATH . '/' . $log_dir;
}
$this->logToFileFilename = $log_dir . '/' . $logToFileFilename;
$this->fileFormatter = $fileFormatter;
$this->screenFormatter = $screenFormatter;
$this->logToDatabaseTableName = Piwik::prefixTable($logToDatabaseTableName);
$this->logToDatabaseColumnMapping = $logToDatabaseColumnMapping;
}
示例10: substr
function __construct($logToFileFilename, $fileFormatter, $screenFormatter, $logToDatabaseTableName, $logToDatabaseColumnMapping)
{
parent::__construct();
$this->currentRequestKey = substr(Piwik_Common::generateUniqId(), 0, 8);
$log_dir = Piwik_Config::getInstance()->log['logger_file_path'];
if ($log_dir[0] != '/' && $log_dir[0] != DIRECTORY_SEPARATOR) {
$log_dir = PIWIK_USER_PATH . '/' . $log_dir;
}
$this->logToFileFilename = $log_dir . '/' . $logToFileFilename;
$this->fileFormatter = $fileFormatter;
$this->screenFormatter = $screenFormatter;
$this->logToDatabaseTableName = Piwik_Common::prefixTable($logToDatabaseTableName);
$this->logToDatabaseColumnMapping = $logToDatabaseColumnMapping;
}
示例11: __construct
/**
* Cunstructor takes a Zend_Log_Writer_Db instance
*
* @param Zend_Log_Writer_Db $writer
* @param string $projectName
* @param bool $registerMonitor
*/
public function __construct(Zend_Log_Writer_Abstract $writer, $projectName = NULL, $registerMonitor = TRUE)
{
parent::__construct($writer);
if (defined('APPLICATION_ENV')) {
$this->environment = APPLICATION_ENV;
}
if (isset($projectName)) {
$this->projectName = (string) $projectName;
}
if (TRUE == $registerMonitor) {
//Register the monitor for application wide usage
Zend_Registry::set('monitor', $this);
}
}
示例12: __construct
/**
* Constructor function.
*
* For all the defined filenames for log constant,
* will create a Zend_Log object
* with the path to the filename and a filter for these log.
*
* @param Zend_Config $config Object contain the user configuration.
*
* @return void
*/
public function __construct(Zend_Config $config)
{
parent::__construct();
$this->_loggers = array();
if (isset($config->log)) {
foreach ($config->log as $key => $val) {
$constant = "self::" . strtoupper($key);
if (defined($constant)) {
$priority = constant($constant);
$logger = new Zend_Log(new Zend_Log_Writer_Stream($val->filename));
$logger->addFilter(new Zend_Log_Filter_Priority($priority));
$this->_loggers[] = $logger;
}
}
}
}
示例13: __construct
/**
* @return void
*/
public function __construct()
{
parent::__construct(new Zend_Log_Writer_Db(Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('multidb')->getDb('log'), 'log.sms', array('smsid' => 'smsId', 'errorcode' => 'errorCode', 'errormessage' => 'errorMessage')));
}
示例14: __construct
/**
* Class constructor. Create a new logger
*
* @param Zend_Log_Writer_Abstract|null $writer default writer
*/
public function __construct(Zend_Log_Writer_Abstract $writer = null)
{
parent::__construct($writer);
$this->_flippedPriorities = array_flip($this->_priorities);
}
示例15: __construct
/**
* Construct a logger with filename depending on $logRotate
*
* @param mixed $filename Start of the filename minus .log extension
* @param mixed $logRotate One of the cosntants for log rotate
* @param int One of the \Zend_Log constants
*/
public function __construct($filename, $logRotate = null, $priority = null)
{
$this->_logFileRoot = $filename;
$this->_logRotate = $logRotate;
$this->_logFileName = $this->_getLogFileName();
// Empty the file if it is on rotation after a year
$this->_checkLogOverwrite();
try {
$writer = new \Zend_Log_Writer_Stream($this->_logFileName);
} catch (\Exception $exc) {
try {
// Try to solve the problem, otherwise fail heroically
\MUtil_File::ensureDir(dirname($this->_logFileName));
$writer = new \Zend_Log_Writer_Stream($this->_logFileName);
} catch (\Exception $exc) {
$this->bootstrap(array('locale', 'translate'));
die(sprintf($this->translate->_('Path %s not writable'), dirname($this->_logFileName)));
}
}
parent::__construct($writer);
if (null !== $priority) {
$this->setLogPriority($priority);
}
}