MCPcopy
hub / github.com/kubernetes/kubectl / NewCmdLogs

Function NewCmdLogs

pkg/cmd/logs/logs.go:173–191  ·  view source on GitHub ↗

NewCmdLogs creates a new pod logs command

(f cmdutil.Factory, streams genericiooptions.IOStreams)

Source from the content-addressed store, hash-verified

171
172// NewCmdLogs creates a new pod logs command
173func NewCmdLogs(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command {
174 o := NewLogsOptions(streams)
175
176 cmd := &cobra.Command{
177 Use: logsUsageStr,
178 DisableFlagsInUseLine: true,
179 Short: i18n.T("Print the logs for a container in a pod"),
180 Long: logsLong,
181 Example: logsExample,
182 ValidArgsFunction: completion.PodResourceNameAndContainerCompletionFunc(f),
183 Run: func(cmd *cobra.Command, args []string) {
184 cmdutil.CheckErr(o.Complete(f, cmd, args))
185 cmdutil.CheckErr(o.Validate())
186 cmdutil.CheckErr(o.RunLogsContext(cmd.Context()))
187 },
188 }
189 o.AddFlags(cmd)
190 return cmd
191}
192
193func (o *LogsOptions) AddFlags(cmd *cobra.Command) {
194 cmd.Flags().BoolVar(&o.AllPods, "all-pods", o.AllPods, "Get logs from all pod(s). Sets prefix to true.")

Callers 4

NewKubectlCommandFunction · 0.92
TestLogCompleteFunction · 0.85

Calls 7

CompleteMethod · 0.95
ValidateMethod · 0.95
RunLogsContextMethod · 0.95
AddFlagsMethod · 0.95
TFunction · 0.92
NewLogsOptionsFunction · 0.85

Tested by 3

TestLogCompleteFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…