summaryrefslogtreecommitdiff
path: root/compose/container.py
diff options
context:
space:
mode:
authorMazz Mosley <mazz@houseofmnowster.com>2015-10-21 17:28:16 +0100
committerMazz Mosley <mazz@houseofmnowster.com>2015-10-27 17:12:18 +0000
commit7603ebea9b2f484f3cf8f193f64748fb91b67bf6 (patch)
treecd52e1b99ce954c162aff456255be12d83dba763 /compose/container.py
parenta4b002a76ead00ab11f98563177f0706f03d8402 (diff)
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>
Diffstat (limited to 'compose/container.py')
-rw-r--r--compose/container.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/compose/container.py b/compose/container.py
index a03acf56..64773b9e 100644
--- a/compose/container.py
+++ b/compose/container.py
@@ -19,6 +19,7 @@ class Container(object):
self.client = client
self.dictionary = dictionary
self.has_been_inspected = has_been_inspected
+ self.log_stream = None
@classmethod
def from_ps(cls, client, dictionary, **kwargs):
@@ -146,6 +147,13 @@ class Container(object):
log_type = self.log_driver
return not log_type or log_type == 'json-file'
+ def attach_log_stream(self):
+ """A log stream can only be attached if the container uses a json-file
+ log driver.
+ """
+ if self.has_api_logs:
+ self.log_stream = self.attach(stdout=True, stderr=True, stream=True)
+
def get(self, key):
"""Return a value from the container or None if the value is not set.