MCPcopy Create free account
hub / github.com/containerd/nerdctl / LogsCommand

Function LogsCommand

cmd/nerdctl/container/container_logs.go:32–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30)
31
32func LogsCommand() *cobra.Command {
33 const shortUsage = "Fetch the logs of a container. Expected to be used with 'nerdctl run -d'."
34 const longUsage = `Fetch the logs of a container.
35
36The following containers are supported:
37- Containers created with 'nerdctl run -d'. The log is currently empty for containers created without '-d'.
38- Containers created with 'nerdctl compose'.
39- Containers created with Kubernetes (EXPERIMENTAL).
40`
41 var cmd = &cobra.Command{
42 Use: "logs [flags] CONTAINER",
43 Args: helpers.IsExactArgs(1),
44 Short: shortUsage,
45 Long: longUsage,
46 RunE: logsAction,
47 ValidArgsFunction: logsShellComplete,
48 SilenceUsage: true,
49 SilenceErrors: true,
50 }
51 cmd.Flags().BoolP("follow", "f", false, "Follow log output")
52 cmd.Flags().BoolP("timestamps", "t", false, "Show timestamps")
53 cmd.Flags().StringP("tail", "n", "all", "Number of lines to show from the end of the logs")
54 cmd.Flags().String("since", "", "Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)")
55 cmd.Flags().String("until", "", "Show logs before a timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)")
56 cmd.Flags().Bool("details", false, "Show extra details provided to logs")
57 return cmd
58}
59
60func logsOptions(cmd *cobra.Command) (types.ContainerLogsOptions, error) {
61 globalOptions, err := helpers.ProcessRootCmdFlags(cmd)

Callers 2

newAppFunction · 0.92
CommandFunction · 0.85

Calls 2

IsExactArgsFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…