本文整理汇总了PHP中sfLogger::initialize方法的典型用法代码示例。如果您正苦于以下问题:PHP sfLogger::initialize方法的具体用法?PHP sfLogger::initialize怎么用?PHP sfLogger::initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfLogger
的用法示例。
在下文中一共展示了sfLogger::initialize方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
/**
* Initializes this logger.
*
* Available options:
*
* - file: The file path or a php wrapper to log messages
* You can use any support php wrapper. To write logs to the Apache error log, use php://stderr
* - format: The log line format (default to %time% %type% [%priority%] %message%%EOL%)
* - time_format: The log time strftime format (default to %b %d %H:%M:%S)
* - dir_mode: The mode to use when creating a directory (default to 0777)
* - file_mode: The mode to use when creating a file (default to 0666)
*
* @param sfEventDispatcher $dispatcher A sfEventDispatcher instance
* @param array $options An array of options.
*
* @return Boolean true, if initialization completes successfully, otherwise false.
*/
public function initialize(sfEventDispatcher $dispatcher, $options = array())
{
if (!isset($options['file'])) {
throw new sfConfigurationException('You must provide a "file" parameter for this logger.');
}
if (isset($options['format'])) {
$this->format = $options['format'];
}
if (isset($options['time_format'])) {
$this->timeFormat = $options['time_format'];
}
if (isset($options['type'])) {
$this->type = $options['type'];
}
$dir = dirname($options['file']);
if (!is_dir($dir)) {
mkdir($dir, isset($options['dir_mode']) ? $options['dir_mode'] : 0777, true);
}
$fileExists = file_exists($options['file']);
if (!is_writable($dir) || $fileExists && !is_writable($options['file'])) {
throw new sfFileException(sprintf('Unable to open the log file "%s" for writing.', $options['file']));
}
$this->fp = fopen($options['file'], 'a');
if (!$fileExists) {
chmod($options['file'], isset($options['file_mode']) ? $options['file_mode'] : 0666);
}
return parent::initialize($dispatcher, $options);
}
示例2: initialize
public function initialize(sfEventDispatcher $dispatcher, $options = array())
{
parent::initialize($dispatcher, $options);
$ops = array_merge($this->defaults, $options);
$this->r = new Redis($ops['host'], $ops['port']);
$this->maxlogs = $ops['maxlogs'];
}
示例3: initialize
public function initialize(sfEventDispatcher $dispatcher, $options = array())
{
if (isset($options['ident'])) {
$this->ident = $options['ident'];
}
openlog($this->ident, LOG_PID | LOG_PERROR, LOG_KERN);
return parent::initialize($dispatcher, $options);
}
示例4: initialize
/**
* Initializes this logger.
*
* Available options:
*
* - xdebug_logging: Whether to add xdebug trace to the logs (false by default).
*
* @param sfEventDispatcher $dispatcher A sfEventDispatcher instance
* @param array $options An array of options.
*
* @return Boolean true, if initialization completes successfully, otherwise false.
*/
public function initialize(sfEventDispatcher $dispatcher, $options = array())
{
$this->xdebugLogging = isset($options['xdebug_logging']) ? $options['xdebug_logging'] : false;
// disable xdebug when an HTTP debug session exists (crashes Apache, see #2438)
if (isset($_GET['XDEBUG_SESSION_START']) || isset($_COOKIE['XDEBUG_SESSION'])) {
$this->xdebugLogging = false;
}
return parent::initialize($dispatcher, $options);
}
示例5: initialize
/**
* Initializes this logger.
*
* Available options:
*
* - logger_service_id: The service id to use as the logger. Default: logger.psr
* - auto_connect: If we must connect automatically to the context.load_factories to set the logger. Default: true
*
* @param sfEventDispatcher $dispatcher
* @param array $options
*
* @return void
*/
public function initialize(sfEventDispatcher $dispatcher, $options = array())
{
if (isset($options['logger_service_id'])) {
$this->loggerServiceId = $options['logger_service_id'];
}
if (!isset($options['auto_connect']) || $options['auto_connect']) {
$dispatcher->connect('context.load_factories', array($this, 'listenContextLoadFactoriesEvent'));
}
parent::initialize($dispatcher, $options);
}
示例6: initialize
/**
* Initializes this logger.
*
* Available options:
*
* - loggers: Logger objects that extends sfLogger.
*
* @param sfEventDispatcher $dispatcher A sfEventDispatcher instance
* @param array $options An array of options.
*
* @return Boolean true, if initialization completes successfully, otherwise false.
*/
public function initialize(sfEventDispatcher $dispatcher, $options = array())
{
$this->dispatcher = $dispatcher;
if (isset($options['loggers'])) {
if (!is_array($options['loggers'])) {
$options['loggers'] = array($options['loggers']);
}
$this->addLoggers($options['loggers']);
}
return parent::initialize($dispatcher, $options);
}
示例7: initialize
/**
* Initializes this logger.
*
* Available options:
*
* - stream: A PHP stream
*
* @param sfEventDispatcher $dispatcher A sfEventDispatcher instance
* @param array $options An array of options.
*
* @return Boolean true, if initialization completes successfully, otherwise false.
*/
public function initialize(sfEventDispatcher $dispatcher, $options = array())
{
if (!isset($options['stream'])) {
throw new sfConfigurationException('You must provide a "stream" option for this logger.');
} else {
if (is_resource($options['stream']) && 'stream' != get_resource_type($options['stream'])) {
throw new sfConfigurationException('The provided "stream" option is not a stream.');
}
}
$this->stream = $options['stream'];
return parent::initialize($dispatcher, $options);
}
示例8: initialize
/**
* Initializes this logger.
*
* Available options:
*
* - file: The file path or a php wrapper to log messages
* You can use any support php wrapper. To write logs to the Apache error log, use php://stderr
* - format: The log line format (default to %time% %type% [%priority%] %message%%EOL%)
* - time_format: The log time strftime format (default to %b %d %H:%M:%S)
* - dir_mode: The mode to use when creating a directory (default to 0777)
* - file_mode: The mode to use when creating a file (default to 0666)
*
* @param sfEventDispatcher $dispatcher A sfEventDispatcher instance
* @param array $options An array of options.
*
* @return Boolean true, if initialization completes successfully, otherwise false.
*/
public function initialize(sfEventDispatcher $dispatcher, $options = array())
{
$this->host = isset($options['host']) ? $options['host'] : Mongo::DEFAULT_HOST;
$this->port = isset($options['port']) ? $options['port'] : Mongo::DEFAULT_PORT;
if (isset($options['type'])) {
$this->type = $options['type'];
}
if (isset($options['db_name'])) {
$this->db_name = $options['db_name'];
}
$this->connection = MongoDBConnection::getInstance()->getConnection();
$this->collection = $this->connection->selectDB($this->db_name)->selectCollection(date('Y-m-d'));
return parent::initialize($dispatcher, $options);
}
示例9: initialize
/**
* Initializes this logger.
*
* @param sfEventDispatcher $dispatcher A sfEventDispatcher instance
* @param array $options An array of options.
*
* @return Boolean true, if initialization completes successfully, otherwise false.
*/
public function initialize(sfEventDispatcher $dispatcher, $options = array())
{
$this->context = sfContext::getInstance();
$this->dispatcher = $dispatcher;
$class = isset($options['web_debug_class']) ? $options['web_debug_class'] : 'sfWebDebug';
$this->webDebug = new $class($dispatcher);
$dispatcher->connect('response.filter_content', array($this, 'filterResponseContent'));
if (isset($options['xdebug_logging'])) {
$this->xdebugLogging = $options['xdebug_logging'];
}
// disable xdebug when an HTTP debug session exists (crashes Apache, see #2438)
if (isset($_GET['XDEBUG_SESSION_START']) || isset($_COOKIE['XDEBUG_SESSION'])) {
$this->xdebugLogging = false;
}
return parent::initialize($dispatcher, $options);
}
示例10: initialize
/**
* Initializes this logger.
*
* @throws sfInitializationException
*
* @param sfEventDispatcher $dispatcher A sfEventDispatcher instance
* @param array $options An array of options.
*
* @return bool
*/
public function initialize(sfEventDispatcher $dispatcher, $options = array())
{
if (!class_exists('Mongo')) {
throw new sfInitializationException('The MongoDB extension is not installed or enabled.');
}
foreach ($this->getRequiredOptions() as $eachOption) {
if (!isset($options[$eachOption])) {
throw new sfInitializationException(sprintf('The required option "%s" is missing.', $eachOption));
}
}
$this->options = array_merge($this->getDefaultOptions(), $options);
if ($this->options['username'] and $this->options['password']) {
$this->handler = new Mongo(sprintf('mongodb://%s:%s@%s:%d/%s', $this->options['username'], $this->options['password'], $this->options['host'], $this->options['port'], $this->options['database']));
} else {
$this->handler = new Mongo(sprintf('mongodb://%s:%d', $this->options['host'], $this->options['port']));
}
if (!empty($this->options['create'])) {
$this->handler->selectDB($this->options['database'])->createCollection($this->options['collection'], $this->options['create']['capped'], $this->options['create']['size'], $this->options['create']['max']);
}
$this->collection = $this->handler->selectCollection($this->options['database'], $this->options['collection']);
return parent::initialize($dispatcher, $this->options);
}