2

I have a symfony task, with a context instance creation :

sfContext::createInstance($this->configuration);

The context is needed because of a call to the get_component helper function (in order to generate the body of an email). I know sfContext::getInstance() is bad, but I did not write it and can't remove it.

My problem is this line triggers the logging of routing - related messages:

  >> sfPatternRouting Match route "homepage" (/) for / with parameters array (  'module' => 'default',  'action' => 'index',)

How can I get sfRouting to shut up? I keep getting email from my crontab repeating this useless piece of information.

How would I change the configuration so that the options passed to the routing constructor do not contain "logging" => "true" ?

I would like the routing to shut up no matter what my factories.yml files contain.

Of course, it there is an error, be it logged to STDOUT or STDERR, I still want to get an email.

Vlad asked me for my code, so I created a tiny project so you can easily reproduce the bug. Here it is: https://github.com/greg0ire/pwet

If you want to easily reproduce the bug, I created a brand new dummy project, which you can clone. Here are the steps to reproduce the bug:

git clone git://github.com/greg0ire/pwet.git
cd pwet
git submodule init
git submodule update
php web/frontend_dev.php
./symfony pwet --application="frontend"

Notice how php web/frontend_dev.php is important. It does not generate the same cache files as the CLI would

4

3 回答 3

2

我能够通过创建一个名为“task”的新环境并将“路由”类配置为我创建的名为“DummyRouting”的新类来实现这一点。

应用程序/前端/配置/factories.yml:

task:
  routing:
     class: DummyRouting

DummyRouting.class.php

class DummyRouting extends sfPatternRouting
{
  public function connect($name, $route)
  {
  }

  public function parse($url)
  {
    return false;
  }
}

当然,为了方便起见,请确保将“任务”环境指定为默认环境。

configure() 中的 YourTask.class.php

...
new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'task'),
...
于 2013-05-30T16:22:04.450 回答
0

仅当您在(默认情况下为开发环境)上进行调试时才会发生这种情况

环境的默认值在任务的配置方法中定义(类似于我的上一条消息中的行)。--env=dev/prod/stage/etc在执行任务时,您可以通过在命令行中使用参数来覆盖它。您可能想要切换到生产环境 (prod),这样您就不会看到与路由相关的消息(或其他相关的调试消息)。这是我的一项任务的示例:

protected function configure()
{
    $this->addOptions(array(
      new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'frontend'),
      new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'prod'), 
      new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'),
    ));

   // other stuff here      
}
于 2012-12-06T14:18:29.703 回答
-1

logging可以设置为的唯一方法false是在您的factories.yml

prod:
  routing:
    param:
      logging: false

使用这个解决方案我的任务现在很安静!

于 2014-03-29T16:47:02.920 回答