docker-compose icon indicating copy to clipboard operation
docker-compose copied to clipboard

Add a way to view logs

Open devshawn opened this issue 6 years ago • 8 comments
trafficstars

I'm using this project to create a CLI that wraps some docker-compose stuff to spin up a local environment. It would be nice to be able to have a command that would stream docker-compose logs.

Would this be possible, or is there an alternative you recommend?

devshawn avatar Jan 14 '19 03:01 devshawn

@devshawn Thanks for using docker-compose. Would you like to implement this feature and send a PR or do you expect it to be available eventually?

AlexZeitler avatar Jan 14 '19 16:01 AlexZeitler

I'd be happy to take a stab at it if no one has time for it. It'd be nice to have the option to view logs to the current point as well as streaming it. docker-compose logs vs docker-compose logs --follow.

The latter means the process wouldn't end until the user stops/kills it, but in my case, that's useful. What are your thoughts on this? It appears most commands here run in -d without any user interaction.

devshawn avatar Jan 15 '19 04:01 devshawn

Makes sense to me, get going 👍

AlexZeitler avatar Jan 15 '19 07:01 AlexZeitler

@devshawn is #38 what you're looking for?

AlexZeitler avatar Feb 03 '19 19:02 AlexZeitler

@AlexZeitler - Yes, I believe this would work great! Sorry for not responding, I haven't had time for the project I'm using this for in the past couple of weeks. 👍

devshawn avatar Feb 05 '19 01:02 devshawn

@devshawn Great to hear! I've just released it on npm (v0.12.0). Please let me know if it works for you.

AlexZeitler avatar Feb 05 '19 01:02 AlexZeitler

@AlexZeitler I've read through the code and noticed that --follow flag will probably not work when one asks for a container that simply does not end. After all, promises are only resolved when process ends, which practically means there is no way to actually "follow" logs for a running process and - especially - multiple containers.

There is a possibility to handle following logs (or uping a container without actually detaching) if instead of working with a promise we would use JS generators and/or EventEmitters. This can potentially lead to reduction in memory usage, since there might no longer be need to store process output in a variable, but instead rely on user handling our event emission or reading directly from subprocess stdout/stderr (if yielded from generator at some point). This would constitute a major BC tho. WDYT?

btw, do you have any slack or gitter channel?

I've added #60 as work-in-progress / proof-of-concept.

Steveb-p avatar Apr 17 '19 14:04 Steveb-p

@Steveb-p I created a Slack workspace at https://pdmlab-oss.slack.com.

Just drop me a line with your email address at [email protected] so I can invite you.

AlexZeitler avatar Apr 17 '19 21:04 AlexZeitler