protected function _initLogger() { $logger = $this->bootstrapLog()->getResource('Log'); /*if (! $this->hasPluginResource ( 'Log' )) { return false; }*/ switch (strtolower(APPLICATION_ENV)) { case 'production': $writer = new Zend_Log_Writer_Firebug(); $filter = new Zend_Log_Filter_Priority(5, '>='); $writer->addFilter($filter); // Uncomment and alter following line if you want to get more then message. //$writer->setPriorityStyle(Zend_Log::WARN, 'TRACE'); $logger->addWriter($writer); break; case 'staging': //Not considered yet. break; case 'testing': //Not considered yet. break; case 'development': $writer = new Zend_Log_Writer_Firebug(); $filter = new Zend_Log_Filter_Priority(2, '>='); $writer->addFilter($filter); // Uncomment and alter following line if you want to get more then message. //$writer->setPriorityStyle(Zend_Log::WARN, 'TRACE'); $logger->addWriter($writer); break; default: throw new Zend_Exception('Unknown <b>Application Environment</b> to create log writer in bootstrap.', Zend_Log::WARN); } // Now set logger globally in application. Zend_Registry::set("logger", $logger); }
/** * Logging Initialization * KBBTODO:Move to application.ini * @return void */ protected function _initLogging() { $this->_logging = new Zend_Log(); if ($this->_config->kebab->logging->enable) { //Stream Writer if ($this->_config->kebab->logging->stream->enable) { $logFile = APPLICATION_PATH . '/variables/logs/application.log'; $streamWriter = new Zend_Log_Writer_Stream($logFile); $this->_logging->addWriter($streamWriter); } //Firebug Writer if ($this->_config->kebab->logging->firebug->enable) { $firebugWriter = new Zend_Log_Writer_Firebug(); $firebugWriter->setFormatter(new Zend_Log_Formatter_Simple()); $this->_logging->addWriter($firebugWriter); } } else { //Empty Writer $nullWriter = new Zend_Log_Writer_Null(); $this->_logging->addWriter($nullWriter); } Zend_Registry::set('logging', $this->_logging); // Info Log $this->_logging->log('Logging initialized...', Zend_Log::INFO); return $this->_logging; }
/** * 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; }
public function initLog() { $options = $this->getOptions(); if (isset($options['cosmos']['logToFirebug']) && $options['cosmos']['logToFirebug'] == true) { $writer = new Zend_Log_Writer_Firebug(); $logger = new Zend_Log($writer); $writer->setPriorityStyle(8, 'TABLE'); } else { if ($this->getPluginResource('log')) { $logger = $this->getPluginResource('log')->getLog(); } } $logger->addPriority('TABLE', 8); Zend_Registry::set('log', $logger); }
/** * * constructs the helper */ protected function __construct() { if (APPLICATION_ENV != 'production') { $writer = new Zend_Log_Writer_Firebug(); $writer->setDefaultPriorityStyle('EXCEPTION'); } else { $mailConfig = Zend_Registry::get('emailSettings'); if ($mtconf->sendmail) { $mtconf = array('auth' => 'login', 'username' => $mailConfig->smtp->user, 'password' => $mailConfig->smtp->password, 'port' => $mailConfig->smtp->port); if ($mailConfig->smtp->ssl) { $mtconf['ssl'] = 'tls'; } $transport = new Zend_Mail_Transport_Smtp($mailConfig->smtp->host, $mtconf); } else { $transport = new Zend_Mail_Transport_Sendmail(); } Zend_Mail::setDefaultTransport($transport); $mail = new Zend_Mail('UTF-8'); $mail->setFrom($mailConfig->email->noreply, 'FansubCMS Error Report'); $mail->addTo($mailConfig->email->admin, 'FansubCMS Technical Administrator at' . $_SERVER['HTTP_HOST']); $mail->addHeader('X-MailGenerator', 'Log handler on FansubCMS'); $mail->addHeader('X-Mailer', 'FansubCMS'); $mail->addHeader('X-Priority', '3'); $writer = new Zend_Log_Writer_Mail($mail); $writer->setSubjectPrependText('FansubCMS Error: '); } switch (APPLICATION_ENV) { case 'debug': // is handled by dev bar through $writer->addFilter(Zend_Log::DEBUG); break; case 'testing': $writer->addFilter(Zend_Log::NOTICE); break; default: $writer->addFilter(Zend_Log::ERR); break; } $logger = new Zend_Log($writer); self::$_logger = $logger; }
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; }
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'))))); }
* obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. * * @category Zend * @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);
/** * Initialize logging to firebug. Disabled on production. */ protected function _initLogging() { $logger = new Zend_Log(); if (defined('HMD_CLI')) { $writer = new Zend_Log_Writer_Stream('php://stderr'); } else { $writer = new Zend_Log_Writer_Firebug(); $writer->setEnabled(APPLICATION_ENV != 'production'); } $logger->addWriter($writer); Zend_Registry::set('logger', $logger); return $logger; }
/** * get Logger * * @return OSS_Log */ public function getLogger() { if (null === $this->_logger) { // Get Doctrine configuration options from the application.ini file $options = $this->getOptions(); $logger = new OSS_Log(); if (isset($options['enabled']) && $options['enabled']) { foreach ($options['writers'] as $writer => $writerOptions) { switch ($writer) { case 'stream': if (isset($writerOptions['mode']) && ($writerOptions['mode'] = 'single')) { $log_path = $writerOptions['path']; $log_file = $log_path . DIRECTORY_SEPARATOR . (isset($writerOptions['logname']) ? $writerOptions['logname'] : 'log.log'); } else { $log_path = $writerOptions['path'] . DIRECTORY_SEPARATOR . date('Y') . DIRECTORY_SEPARATOR . date('m'); $log_file = $log_path . DIRECTORY_SEPARATOR . date('Ymd') . '.log'; } if (file_exists($log_path) == false) { mkdir($log_path, 0755, true); @chmod($log_path, 0755); @chown($log_path, $writerOptions['owner']); @chgrp($log_path, $writerOptions['group']); } if (file_exists($log_file) == false) { touch($log_file); @chmod($log_file, 0777); @chown($log_file, $writerOptions['owner']); @chgrp($log_file, $writerOptions['group']); } $streamWriter = new Zend_Log_Writer_Stream($log_file); $streamWriter->setFormatter(new Zend_Log_Formatter_Simple('%timestamp% %priorityName% (%priority%) ' . (isset($_SERVER['REMOTE_ADDR']) == true ? "[{$_SERVER['REMOTE_ADDR']}]" : "") . ': %message%' . PHP_EOL)); $logger->addWriter($streamWriter); if (isset($writerOptions['level'])) { $logger->addFilter((int) $writerOptions['level']); } break; case 'email': $mail = new Zend_Mail(); $mail->setFrom($writerOptions['from'])->addTo($writerOptions['to']); $mailWriter = new Zend_Log_Writer_Mail($mail); // Set subject text for use; summary of number of errors is appended to the // subject line before sending the message. $mailWriter->setSubjectPrependText("[{$writerOptions['prefix']}]"); // Only email entries with level requested and higher. $mailWriter->addFilter((int) $writerOptions['level']); $logger->addWriter($mailWriter); break; case 'firebug': if ($writerOptions['enabled']) { $firebugWriter = new Zend_Log_Writer_Firebug(); $firebugWriter->addFilter((int) $writerOptions['level']); $logger->addWriter($firebugWriter); } break; default: try { $logger->log("Unknown log writer: {$writer}", Zend_Log::WARN); } catch (Zend_Log_Exception $e) { die("Unknown log writer [{$writer}] during application bootstrap"); } break; } } } else { $logger->addWriter(new Zend_Log_Writer_Null()); } try { $logger->debug('Logger instantiated', Zend_Log::INFO); } catch (Zend_Log_Exception $e) { die("Unknown log writer [{$writer}] during application bootstrap"); } $this->_logger = $logger; } return $this->_logger; }
/** * Add a Firebug writer * * @return void */ public function addFirebugWriter() { $writer = new Zend_Log_Writer_Firebug(); $writer->setEnabled(true); $this->addWriter($writer); }
<?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();
protected function _initLog() { /** * FirePHP */ if ($this->getEnvironment() == 'development') { $writer = new Zend_Log_Writer_Firebug(); $writer->setPriorityStyle(8, 'TABLE'); $writer->setPriorityStyle(9, 'TRACE'); $logger = new Zend_Log($writer); Zend_Registry::set('logger', $logger); } }
public function initFirebug() { $writer = new Zend_Log_Writer_Firebug(); if (APPLICATION_ENV == 'production') { $writer->setEnabled($this->_config->system->debug->firebug && $this->_config->system->debug->ip == $this->getRequest()->getClientIp() ? true : false); } else { $writer->setEnabled($this->_config->system->debug->firebug ? true : false); } $logger = new Zend_Log($writer); Zend_Registry::set('logger', $logger); }