Skip to content

Small refactorings #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
When logging command output add also the command line args
  • Loading branch information
cmaglie committed Nov 6, 2020
commit e9ee2675760195c97ffd697c4277d7b22cc2c0c7
8 changes: 4 additions & 4 deletions handler/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func generateCompileFlags(tempDir, inoPath, sourcePath, fqbn string) (string, er
propertiesCmd := exec.Command(globalCliPath, cliArgs...)
output, err := propertiesCmd.Output()
if err != nil {
err = logCommandErr(globalCliPath, output, err, errMsgFilter(tempDir))
err = logCommandErr(propertiesCmd, output, err, errMsgFilter(tempDir))
return "", err
}
buildProps, err := properties.LoadFromBytes(output)
Expand Down Expand Up @@ -171,7 +171,7 @@ func generateTargetFile(tempDir, inoPath, cppPath, fqbn string) (cppCode []byte,
preprocessCmd := exec.Command(globalCliPath, cliArgs...)
cppCode, err = preprocessCmd.Output()
if err != nil {
err = logCommandErr(globalCliPath, cppCode, err, errMsgFilter(tempDir))
err = logCommandErr(preprocessCmd, cppCode, err, errMsgFilter(tempDir))
return
}

Expand Down Expand Up @@ -331,9 +331,9 @@ func splitFlags(flags string) string {
return string(result)
}

func logCommandErr(command string, stdout []byte, err error, filter func(string) string) error {
func logCommandErr(command *exec.Cmd, stdout []byte, err error, filter func(string) string) error {
message := ""
log.Println("Command error:", command, err)
log.Println("Command error:", command.Args, err)
if len(stdout) > 0 {
stdoutStr := string(stdout)
log.Println("------------------------------BEGIN STDOUT\n", stdoutStr, "------------------------------END STDOUT")
Expand Down