Giter Club home page Giter Club logo

Comments (7)

emk avatar emk commented on July 28, 2024

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.

emk avatar emk commented on July 28, 2024

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.

emk avatar emk commented on July 28, 2024

@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.

emk avatar emk commented on July 28, 2024

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.

emk avatar emk commented on July 28, 2024

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:

  1. Edit src/cli.yml to add a new logs subcommand with appropriate arguments. See the clap documentation.
  2. Dispatch the new arguments in src/main.rs to your new src/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; }
  3. From inside that function, call match try!(self.pod_or_service_or_err(pod_or_service_name)) { ... } and handle both the PodOrService::Pod and the PodOrService::Service case.

from cage.

emk avatar emk commented on July 28, 2024

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.

emk avatar emk commented on July 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.