Attach to a container's log_stream before they're started
So we're not displaying output of all previous logs for a container, we attach, if possible, to a container before the container is started. LogPrinter checks if a container has a log_stream already attached and print from that rather than always attempting to attach one itself. Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
This commit is contained in:
parent
a4b002a76e
commit
7603ebea9b
6 changed files with 66 additions and 27 deletions
|
|
@ -565,16 +565,18 @@ class TopLevelCommand(DocoptCommand):
|
|||
start_deps = not options['--no-deps']
|
||||
service_names = options['SERVICE']
|
||||
timeout = int(options.get('--timeout') or DEFAULT_TIMEOUT)
|
||||
detached = options.get('-d')
|
||||
|
||||
to_attach = project.up(
|
||||
service_names=service_names,
|
||||
start_deps=start_deps,
|
||||
strategy=convergence_strategy_from_opts(options),
|
||||
do_build=not options['--no-build'],
|
||||
timeout=timeout
|
||||
timeout=timeout,
|
||||
detached=detached
|
||||
)
|
||||
|
||||
if not options['-d']:
|
||||
if not detached:
|
||||
log_printer = build_log_printer(to_attach, service_names, monochrome)
|
||||
attach_to_logs(project, log_printer, service_names, timeout)
|
||||
|
||||
|
|
@ -636,7 +638,10 @@ def convergence_strategy_from_opts(options):
|
|||
|
||||
def build_log_printer(containers, service_names, monochrome):
|
||||
if service_names:
|
||||
containers = [c for c in containers if c.service in service_names]
|
||||
containers = [
|
||||
container
|
||||
for container in containers if container.service in service_names
|
||||
]
|
||||
return LogPrinter(containers, monochrome=monochrome)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue