Comments (7)
Could we spec out some ideas about how this might work in an ideal world? We don't have to implement all right away, but I'd like to get the API right.
Here's my proposal for the final API:
cage logs [log options] [<pods_or_services>...]
This covers a number of cases:
- If it displays logs for more than one container, it annotes each line with the container name.
- With no args, it displays interleaved logs for all containers.
- With a pod name, it displays the logs for all containers in that pod.
- With either
pod/service
or a unique service name, it displays the logs for that service.
from cage.
The standard Docker tools include the following options:
Usage: docker logs [OPTIONS] CONTAINER
Fetch the logs of a container
Options:
--details Show extra details provided to logs
-f, --follow Follow log output
--help Print usage
--since string Show logs since timestamp
--tail string Number of lines to show from the end of the logs (default "all")
-t, --timestamps Show timestamps
docker-compose logs --help
View output from containers.
Usage: logs [options] [SERVICE...]
Options:
--no-color Produce monochrome output.
-f, --follow Follow log output.
-t, --timestamps Show timestamps.
--tail="all" Number of lines to show from the end of the logs
for each container.
from cage.
@dkastner Let me fix #8 first (the new argument-parsing scheme), and then you can go ahead and implement any subset of this that you want to work on.
from cage.
The fancier, multi-container versions of this might benefit from #9, which would make it easier to multiplex tagged I/O from multiple threads or external processes. But that doesn't need to block the initial implementation.
from cage.
OK, I've added a project.pod_or_service(name)
function which can be used to look up either a pod or a service to print the logs from. This will allow you to easily implement:
cage logs <POD_OR_SERVICE>
I wouldn't worry about the multi-pod / multi-service version of this command yet, because doing a good job of that depends on #9, which I want to poke at some more.
To implement this, I would recommend doing the following:
- Edit
src/cli.yml
to add a newlogs
subcommand with appropriate arguments. See the clap documentation. - Dispatch the new arguments in
src/main.rs
to your newsrc/cmd/logs.rs
. This should look like:
rust pub trait CommandLogs { /// Up all the images in the specified pods. fn logs<CR>(&self, runner: &CR, ovr: &Override, pod_or_service_name: &str) -> Result<()> where CR: CommandRunner; }
- From inside that function, call
match try!(self.pod_or_service_or_err(pod_or_service_name)) { ... }
and handle both thePodOrService::Pod
and thePodOrService::Service
case.
from cage.
Also, if you want to pass through any arguments, you can add a new args::opts::Logs
structure to src/args/opts.rs
, based on the ones already there (but ignore the Deref
hack; that's going away shortly) and implement ToArgs
and add method to ArgMatchesExt
in src/main.rs
that builds your args::opts::Logs
structure based on the ArgMatches
structure from clap.
If you have any questions, please let me know!
from cage.
There are also new goodies in 488bf19 which might be of interest. Although you probably can't use the compose
command directly, it would be easy to make a single-item wrapper around it.
from cage.
Related Issues (20)
- 0.3.x alpha: vault plugin requests tokens too often HOT 1
- Allow more complex `up --init` dependencies
- cage clean: Add a way to clean up containers, volumes, etc.
- Switch to `structopt` for arg parsing
- cage doesn't recognise cached bind-mount Docker volume setting HOT 1
- How do you set the docker-compose project HOT 2
- depends_on with health checks (requires compose.yml v3) HOT 6
- Provide arguments to cage shell label? HOT 2
- Docker warnings about orphan containers HOT 1
- Do not mount `src` directories by default
- Add `pull --quiet` flag, or something like that HOT 1
- Cage for compiled languages HOT 1
- `cage` sets `version: "2.4"` when merging targets into base
- docker-compose.yml `version` is not preserved HOT 5
- `cage up` does not work with URL as build context HOT 5
- Can't use ipv4_address in backend.yml HOT 1
- OpenSSL compilation error via `cargo install cage` HOT 5
- How to use `cage source mount` HOT 1
- Allow skipping placeholder pods when issuing vault tokens
- 0.3.x alpha: auto-mounts everything HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cage.