开发者

Display output from a Symfony task on a template

I am executing a task from an action in Symfony. I wish to capture the output from the task & display it to 开发者_开发技巧the (admin) user. Do I extract it from the dispatcher / log or somewhere else?


This might not be the answer you're looking for, however, in a task you can log to a seperate file like so (within the execute function in the task class):

$fileLogger = new sfFileLogger($this->dispatcher, 
                               array('file' =>$this->configuration->getRootDir().'/log/foobar.log'));
$this->dispatcher->connect('command.log', array($fileLogger, 'listenToLogEvent'));

And then in your task when you use:

$this->logSection('something', 'Log whatever message you want....', 1000);

It will automatically log to the custom log file.

Hope this helps. :-)


Why not just perform the task within the action - and format the output in the template ? why are you running a separate task from an Action ? (i know this thread is old)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜