Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a watchdog tail command #4767

Merged
merged 2 commits into from Jun 14, 2021
Merged

Add a watchdog tail command #4767

merged 2 commits into from Jun 14, 2021

Conversation

beejeebus
Copy link
Contributor

WIP, feedback welcome.

Only tested with composer functional -- --filter testWatchdogTail.

// TODO: how should the output string be built?
// Just printing stuff to show it doing something.
$row = $this->formatResult($result, $options['extended']);
print "\n " . $row->wid . "\t";
Copy link
Member

Choose a reason for hiding this comment

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

I think $this->writeln($string) would be appropriate instead of print.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack. @greg-1-anderson gave me some pointers re. output in Slack. one idea was to create another command for the tail case. thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

It's super weird when a command returns RowsOfFields sometimes, and nothing (or some completely different type) at other times, but since --tail never returns at all, I guess it's not so bad that the behavior is inconsistent.

I'm trying to deprecated $this->io() and $this->writeln() et. al. in Robo; the better way is to add an OutputInterface as the first parameter. Then you'll get an object you can writeln() on.

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've update the PR to use an injected OutputInterface object.

* @param string $input
* A string representing the STDIN that is piped to the command.
*/
public function startExecute($command, $cd = null, $env = null, $input = null)
Copy link
Member

Choose a reason for hiding this comment

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

Is there no way to use $this->execute()? Would save a lot of duplicated code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there is a lot of duplicated code, and i'm open to ways to reduce it.

the main new capability needed is 'run child process in the background, without blocking on it's completion, with access to output for tests'.

my first thought was that should be a separate method, rather than another flag and return type from execute(). so i was planning to reduce duplicate code by factoring out the shared bits in execute() and startExecute(). i also don't love the name startExecute(), happy to get better suggestions.

make sense?

Copy link
Member

Choose a reason for hiding this comment

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

How about we sadd a $timeout param and stop hardocding 0 as timeout in this line. And we add the same timeout param to drush() method which thencalls execute(). Then the test can just call something like $this->drush(watchdog:show --tail, $timeout)

Copy link
Contributor Author

@beejeebus beejeebus Jun 12, 2021

Choose a reason for hiding this comment

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

I think that's a useful but slightly different improvement.

To feel confident that this works, I'd like to create multiple watchdog entries while the process running watchdog:show --tail is running. That requires interactivity in the test process, so we can't block on the $this->drush() call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated the PR to factor out much of the duplicated code.

@beejeebus beejeebus marked this pull request as ready for review June 13, 2021 14:39
@beejeebus beejeebus changed the title WIP: add tail support to watchdog show. Add a watchdog tail command Jun 13, 2021
@beejeebus
Copy link
Contributor Author

I get the same failures on master locally as in CI. Could use some pointers for figuring out the tests.

@weitzman weitzman merged commit 09c3314 into drush-ops:10.x Jun 14, 2021
@weitzman
Copy link
Member

The test failure is unrelated and is being fixed elsewhere.

@maskedjellybean
Copy link

Is this available in any release yet, and if so, which versions?

@weitzman
Copy link
Member

weitzman commented Mar 1, 2022

Its available since 10.6. FYI this info is now viewable on the command's doc page https://www.drush.org/latest/commands/watchdog_tail/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants