Skip to content

Commit

Permalink
fix: clean up log output for build failures (#1094)
Browse files Browse the repository at this point in the history
  • Loading branch information
wesbillman authored Mar 15, 2024
1 parent 34b5a3f commit 6adba1b
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion buildengine/build_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func buildGo(ctx context.Context, sch *schema.Schema, module Module) error {
if err := compile.Build(ctx, module.Dir, sch); err != nil {
return fmt.Errorf("failed to build module: %w", err)
return fmt.Errorf("failed to build module %s: %w", module.Module, err)
}
return nil
}
2 changes: 1 addition & 1 deletion buildengine/build_kotlin.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func buildKotlin(ctx context.Context, sch *schema.Schema, module Module) error {
logger.Debugf("Using build command '%s'", module.Build)
err := exec.Command(ctx, log.Debug, module.Dir, "bash", "-c", module.Build).RunBuffered(ctx)
if err != nil {
return fmt.Errorf("failed to build module: %w", err)
return fmt.Errorf("failed to build module %s: %w", module.Module, err)
}

return nil
Expand Down
1 change: 1 addition & 0 deletions buildengine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ func (e *Engine) build(ctx context.Context, name string, built map[string]*schem
module := e.modules[name]
err := Build(ctx, sch, module)
if err != nil {

return err
}
moduleSchema, err := schema.ModuleFromProtoFile(filepath.Join(module.Dir, module.DeployDir, module.Schema))
Expand Down
2 changes: 1 addition & 1 deletion cmd/ftl/cmd_dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (d *devCmd) Run(ctx context.Context) error {
d.ServeCmd.Stop = false
}
if d.ServeCmd.isRunning(ctx, client) {
return errors.New("FTL is already running")
return errors.New(ftlRunningErrorMsg)
}

g.Go(func() error {
Expand Down
5 changes: 3 additions & 2 deletions cmd/ftl/cmd_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type serveCmd struct {
}

const ftlContainerName = "ftl-db-1"
const ftlRunningErrorMsg = "FTL is already running. Use 'ftl serve --stop' to stop it"

func (s *serveCmd) Run(ctx context.Context) error {
logger := log.FromContext(ctx)
Expand Down Expand Up @@ -71,7 +72,7 @@ func (s *serveCmd) Run(ctx context.Context) error {
}

if s.isRunning(ctx, client) {
return errors.New("FTL is already running")
return errors.New(ftlRunningErrorMsg)
}

logger.Infof("Starting FTL with %d controller(s)", s.Controllers)
Expand Down Expand Up @@ -131,7 +132,7 @@ func (s *serveCmd) Run(ctx context.Context) error {

func runInBackground(logger *log.Logger) {
if running, _ := isServeRunning(logger); running {
logger.Warnf("'ftl serve' is already running in the background. Use --stop to stop it.")
logger.Warnf(ftlRunningErrorMsg)
return
}

Expand Down
1 change: 0 additions & 1 deletion internal/exec/circularbuffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func (cb *CircularBuffer) Bytes() []byte {
defer cb.mu.Unlock()

if cb.size == 0 {
fmt.Println("Buffer is empty.")
return []byte{}
}

Expand Down

0 comments on commit 6adba1b

Please sign in to comment.