Esempio n. 1
0
// tail outputs logs with optional filter pattern.
func tail(project *project.Project, name []string, filter string) {
	service := cloudwatchlogs.New(session.New(aws.NewConfig()))

	// TODO(tj): refactor logs.Logs to take Project so this hack
	// can be removed, it'll also make multi-function tailing easier
	group := fmt.Sprintf("/aws/lambda/%s_%s", project.Name, name[0])

	l := logs.Logs{
		LogGroupName:  group,
		FilterPattern: filter,
		Service:       service,
		Log:           log.Log,
	}

	for event := range l.Tail() {
		fmt.Printf("%s", *event.Message)
	}

	if err := l.Err(); err != nil {
		log.Fatalf("error: %s", err)
	}
}
Esempio n. 2
0
func logsCmdRun(c *cobra.Command, args []string) {
	lv := &logsCmdLocalValues
	service := cloudwatchlogs.New(pv.session)

	// TODO(tj): refactor logs.Logs to take Project so this hack
	// can be removed, it'll also make multi-function tailing easier
	group := fmt.Sprintf("/aws/lambda/%s_%s", pv.project.Name, lv.name)

	l := logs.Logs{
		LogGroupName:  group,
		FilterPattern: lv.Filter,
		Service:       service,
		Log:           log.Log,
	}

	for event := range l.Tail() {
		fmt.Printf("%s", *event.Message)
	}

	if err := l.Err(); err != nil {
		log.Fatalf("error: %s", err)
	}
}