Skip to content
This repository was archived by the owner on Nov 27, 2020. It is now read-only.

Add hello world command to demo bundle and configure new log to console handler #557

Merged
merged 4 commits into from
Jun 14, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/check.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@

echo_title('Mandatory requirements');

$checkPassed = true;
foreach ($symfonyRequirements->getRequirements() as $req) {
/** @var $req Requirement */
echo_requirement($req);
if (!$req->isFulfilled()) {
$checkPassed = false;
}
}

echo_title('Optional recommendations');
Expand All @@ -35,6 +40,8 @@
echo_requirement($req);
}

exit($checkPassed ? 0 : 1);

/**
* Prints a Requirement instance
*/
Expand Down
17 changes: 10 additions & 7 deletions app/config/config_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ web_profiler:
monolog:
handlers:
main:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: debug
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: debug
console:
type: console
bubble: false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this increases performance so the firephp and chromephp handler are not executed for console commands

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the meaning of "bubble" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello.

I just hit an issue here with bubble and I would like to discuss about it

I was trying to debug my application, and so I added a new handler to push all my logs to the Elasticsearch/Heka/Kibana stack (to get a better visualisation / filter system for my logs...) . I did not really think about the order of the handlers and so I added my new handler after the previous handlers. And so I ended-up with the following config:

monolog:
    handlers:
        main:
            type:   stream
            path:   "%kernel.logs_dir%/%kernel.environment%.log"
            level:  debug
            channels: ["!event", "!consumer_status", "!beberlei_metrics"]
        console:
            type:   console
            bubble: false
            channels: ["!doctrine", "!event", "!consumer_status", "!beberlei_metrics"]
        heka:
            type: socket
            level:  debug
            connection_string: "udp://heka.lxc:5565"
            timeout: 1
            connection_timeout: 1
            formatter: monolog.formatter.json

After that, I tried to debug my code and noticed I missed lot of logs. I try to understand why (is it an issue with ES or heka or kibana ? ; It is an issue with my code ? ; etc ?). And I finally understood my issue.

So finally, I really think the console handler should bubble all logs, because It's "just" a nice to have feature (A very good one BTW, thanks again). But it should not "eat" logs. All handlers registered after the handler should also be able to get all logs. So, IMHO, we should turn on the bubble here.

WDTY ?

ping @Tobion @Seldaek

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesnt really matter if bubble is enabled or not as the firephp and chromephp handler are not enabled anymore by default in SE.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tobion Yes I know and my "issue" was not about firephp. It was about DX ; to remove a possible WTF effect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to change it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already changed it in my app ; But I wanted to know if you think it's a good idea to change it in symfony too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok to change it

firephp:
type: firephp
level: info
type: firephp
level: info
chromephp:
type: chromephp
level: info
type: chromephp
level: info

assetic:
use_controller: true
Expand Down
2 changes: 2 additions & 0 deletions app/config/config_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ monolog:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: debug
console:
type: console
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.3.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.2.*",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "2.3.*",
"symfony/swiftmailer-bundle": "2.3.*",
"symfony/monolog-bundle": "2.3.*",
"sensio/distribution-bundle": "2.3.*",
"sensio/framework-extra-bundle": "2.3.*",
"sensio/generator-bundle": "2.3.*",
"symfony/symfony": "~2.4",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~2.3",
"sensio/framework-extra-bundle": "~2.3",
"sensio/generator-bundle": "~2.3",
"incenteev/composer-parameter-handler": "~2.0"
},
"scripts": {
Expand All @@ -39,7 +39,7 @@
"config": {
"bin-dir": "bin"
},
"minimum-stability": "RC",
"minimum-stability": "dev",
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
Expand Down
48 changes: 48 additions & 0 deletions src/Acme/DemoBundle/Command/HelloWorldCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace Acme\DemoBundle\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
* Hello World command for demo purposes.
*
* You could also extend from Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand
* to get access to the container via $this->getContainer().
*
* @author Tobias Schultze <http://tobion.de>
*/
class HelloWorldCommand extends Command
{
/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('acme:hello')
->setDescription('Hello World example command')
->addArgument('who', InputArgument::OPTIONAL, 'Who to greet.', 'World')
->setHelp(<<<EOF
The <info>%command.name%</info> command greets somebody or everybody:

<info>php %command.full_name%</info>

The optional argument specifies who to greet:

<info>php %command.full_name%</info> Fabien
EOF
);
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln(sprintf('Hello <comment>%s</comment>!', $input->getArgument('who')));
}
}