Is there a better way to handle having an application inside a container that's executed from outside pass logs up?
Ansible-Container has a CLI tool that invokes a conductor container (which contains Ansible, a bunch of deps, etc) and has to get & display logs from the executions inside. To make this work & display logs, we have kind of an odd setup that I'm not sure is right.
We're logging out a combination of structlog and plain Ansible output to stdout. This means not all the CLI output is parseable as JSON, so we format it inside the container to be shown on the host stdout.
The main CLI tool has two different loggers: plainLogger
which is a pass-through that just forwards the container's stdout
along. For logs about the actual Ansible Container CLI tool, we're using structlog as normal.
So in the CLI tool, we capture the stdout stream, then for each line plainLogger.info(log_iter.next().rstrip())
. One of the downsides is we lose all the leveling information from inside the container doing this.