Add the docker-compose logs command.
This commit is contained in:
@@ -34,6 +34,7 @@ The following commands have been implemented:
|
||||
|
||||
- docker-compose up
|
||||
- docker-compose ps
|
||||
- docker-compose logs
|
||||
- docker-compose pull
|
||||
- docker-compose exec
|
||||
- docker-compose down
|
||||
|
||||
77
src/Task/Logs.php
Normal file
77
src/Task/Logs.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Droath\RoboDockerCompose\Task;
|
||||
|
||||
use Droath\RoboDockerCompose\DockerServicesTrait;
|
||||
use Robo\Exception\TaskException;
|
||||
|
||||
/**
|
||||
* Define the docker compose logs task.
|
||||
*/
|
||||
class Logs extends Base
|
||||
{
|
||||
use DockerServicesTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected $action = 'logs';
|
||||
|
||||
/**
|
||||
* Produce monochrome output.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function noColor()
|
||||
{
|
||||
$this->option('no-color');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Follow log output.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function follow()
|
||||
{
|
||||
$this->option('follow');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show timestamps.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function timestamps()
|
||||
{
|
||||
$this->option('timestamps');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of lines to show from the end of the logs for
|
||||
* each container.
|
||||
*
|
||||
* @param string $value
|
||||
*
|
||||
* @return $this
|
||||
* @throws TaskException
|
||||
*/
|
||||
public function tail($value = 'all')
|
||||
{
|
||||
if ($value !== 'all' && !is_numeric($value)) {
|
||||
throw new TaskException(
|
||||
__CLASS__,
|
||||
'Provided argument value is invalid.'
|
||||
);
|
||||
}
|
||||
$this->option('tail', $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,14 @@ trait loadTasks
|
||||
return $this->task(Ps::class, $pathToDockerCompose);
|
||||
}
|
||||
|
||||
/**
|
||||
* Docker compose logs task.
|
||||
*/
|
||||
protected function taskDockerComposeLogs($pathToDockerCompose = null)
|
||||
{
|
||||
return $this->task(Logs::class, $pathToDockerCompose);
|
||||
}
|
||||
|
||||
/**
|
||||
* Docker compose down task.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user