Skip to content

Commit

Permalink
Support for Compute@Edge Log Tailing
Browse files Browse the repository at this point in the history
- Adds command: fastly logs tail --service-id=<sid>
  • Loading branch information
jaredmorrow committed Jan 19, 2021
1 parent f10c4fc commit db4bfe0
Show file tree
Hide file tree
Showing 10 changed files with 1,057 additions and 0 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ require (
github.com/nicksnyder/go-i18n v1.10.1 // indirect
github.com/pierrec/lz4 v2.3.0+incompatible // indirect
github.com/segmentio/textio v1.2.0
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoH
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 h1:nrZ3ySNYwJbSpD6ce9duiP+QkD3JuLCcWkdaehUS/3Y=
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80/go.mod h1:iFyPdL66DjUD96XmzVL3ZntbzcflLnznH0fr99w5VqE=
github.com/ulikunitz/xz v0.5.6 h1:jGHAfXawEGZQ3blwU5wnWKQJvAraT7Ftq9EXjnXYgt8=
github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ type Interface interface {

GetRegions() (*fastly.RegionsResponse, error)
GetStatsJSON(*fastly.GetStatsInput, interface{}) error

CreateManagedLogging(*fastly.CreateManagedLoggingInput) (*fastly.ManagedLogging, error)
}

// RealtimeStatsInterface is the subset of go-fastly's realtime stats API used here.
Expand Down
7 changes: 7 additions & 0 deletions pkg/app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
"github.com/fastly/cli/pkg/logging/splunk"
"github.com/fastly/cli/pkg/logging/sumologic"
"github.com/fastly/cli/pkg/logging/syslog"
"github.com/fastly/cli/pkg/logs"
"github.com/fastly/cli/pkg/service"
"github.com/fastly/cli/pkg/serviceversion"
"github.com/fastly/cli/pkg/stats"
Expand Down Expand Up @@ -351,6 +352,9 @@ func Run(args []string, env config.Environment, file config.File, configFilePath
openstackUpdate := openstack.NewUpdateCommand(openstackRoot.CmdClause, &globals)
openstackDelete := openstack.NewDeleteCommand(openstackRoot.CmdClause, &globals)

logsRoot := logs.NewRootCommand(app, &globals)
logsTail := logs.NewTailCommand(logsRoot.CmdClause, &globals)

statsRoot := stats.NewRootCommand(app, &globals)
statsRegions := stats.NewRegionsCommand(statsRoot.CmdClause, &globals)
statsHistorical := stats.NewHistoricalCommand(statsRoot.CmdClause, &globals)
Expand Down Expand Up @@ -598,6 +602,9 @@ func Run(args []string, env config.Environment, file config.File, configFilePath
openstackUpdate,
openstackDelete,

logsRoot,
logsTail,

statsRoot,
statsRegions,
statsHistorical,
Expand Down
2 changes: 2 additions & 0 deletions pkg/logs/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package logs contains commands to view Fastly managed logs.
package logs
28 changes: 28 additions & 0 deletions pkg/logs/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package logs

import (
"io"

"github.com/fastly/cli/pkg/common"
"github.com/fastly/cli/pkg/config"
)

// RootCommand is the parent command for all subcommands in this package.
// It should be installed under the primary root command.
type RootCommand struct {
common.Base
// no flags
}

// NewRootCommand returns a new command registered in the parent.
func NewRootCommand(parent common.Registerer, globals *config.Data) *RootCommand {
var c RootCommand
c.Globals = globals
c.CmdClause = parent.Command("logs", "Compute@Edge Log tailing")
return &c
}

// Exec implements the command interface.
func (c *RootCommand) Exec(in io.Reader, out io.Writer) error {
panic("unreachable")
}
Loading

0 comments on commit db4bfe0

Please sign in to comment.