logs

package
v1.8.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Example (Logs_help)
package main

import (
	"os"

	"github.com/aws-cloudformation/rain/internal/cmd/logs"
)

func main() {
	os.Args = []string{
		os.Args[0],
		"--help",
	}

	logs.Cmd.Execute()
}
Output:

Shows the event log for a stack and its nested stack. Optionally, filter by a specific resource by name, or see a gantt chart of the most recent stack action.

By default, only show log entries that contain a useful message (e.g. a failure message).
You can use the --all flag to change this behaviour.

Usage:
  logs <stack> (<resource>)

Aliases:
  logs, log

Flags:
  -a, --all           include uninteresting logs
  -c, --chart         Output a gantt chart of the most recent action as an html file
  -d, --days uint     Age of the logs to display in days
      --debug         Output debugging information
  -h, --help          help for logs
  -l, --length uint   Number of logs to display

Index

Examples

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "logs <stack> (<resource>)",
	Short: "Show the event log for the named stack",
	Long: `Shows the event log for a stack and its nested stack. Optionally, filter by a specific resource by name, or see a gantt chart of the most recent stack action.

By default, only show log entries that contain a useful message (e.g. a failure message).
You can use the --all flag to change this behaviour.`,
	Args:                  cobra.RangeArgs(1, 2),
	Aliases:               []string{"log"},
	DisableFlagsInUseLine: true,
	Run: func(cmd *cobra.Command, args []string) {
		stackName := args[0]
		resourceName := ""
		if len(args) > 1 {
			resourceName = args[1]
		}

		if !chart {

			logs, err := getLogs(stackName, resourceName)
			if err != nil {
				panic(ui.Errorf(err, "failed to get logs for stack '%s'", stackName))
			}

			if len(logs) == 0 {
				if allLogs {
					fmt.Println("No interesting log messages to display.")
				} else {
					fmt.Println("No interesting log messages to display. To see everything, use the --all flag")
				}
			} else {
				printLogs(logsLength, logsDays, logs)
			}
		} else {
			err := createChart(stackName)
			if err != nil {
				panic(ui.Errorf(err, "failed to generate chart for stack '%s'", stackName))
			}
		}
	},
}

Cmd is the logs command's entrypoint

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL