diff --git a/README.md b/README.md index 065df9a..4d25c6d 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/Task/Logs.php b/src/Task/Logs.php new file mode 100644 index 0000000..dc12767 --- /dev/null +++ b/src/Task/Logs.php @@ -0,0 +1,77 @@ +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; + } +} diff --git a/src/Task/loadTasks.php b/src/Task/loadTasks.php index 92aa453..87e3fcd 100755 --- a/src/Task/loadTasks.php +++ b/src/Task/loadTasks.php @@ -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. */