Skip to content

Commit

Permalink
use log package instead of fmt to output timestamp
Browse files Browse the repository at this point in the history
Signed-off-by: Yuji Ito <llamerada.jp@gmail.com>
  • Loading branch information
llamerada-jp committed May 20, 2023
1 parent 1d59515 commit 2a2271b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

import (
"fmt"
"log"
"os"

"github.com/spf13/cobra"
Expand All @@ -13,7 +13,7 @@ var rootCmd = &cobra.Command{

func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
log.Println(err)
os.Exit(1)
}
}
12 changes: 6 additions & 6 deletions pkg/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ type build struct {
}

func command(path, name string, args ...string) {
fmt.Printf("\x1b[36m%s\x1b[0m$ %s", path, name)
cmdStr := fmt.Sprintf("\x1b[36m%s\x1b[0m$ %s", path, name)
for _, v := range args {
fmt.Print(" ", v)
cmdStr = cmdStr + fmt.Sprint(" ", v)
}
fmt.Println()
log.Println(cmdStr)

cmd := exec.Command(name, args...)
cmd.Dir = path
Expand All @@ -86,11 +86,11 @@ func command(path, name string, args ...string) {
}

func commandStdin(path, input, name string, args ...string) {
fmt.Printf("\x1b[36m%s\x1b[0m$ %s", path, name)
cmdStr := fmt.Sprintf("\x1b[36m%s\x1b[0m$ %s", path, name)
for _, v := range args {
fmt.Print(" ", v)
cmdStr = cmdStr + fmt.Sprint(" ", v)
}
fmt.Println()
log.Println(cmdStr)

cmd := exec.Command(name, args...)
cmd.Dir = path
Expand Down
9 changes: 5 additions & 4 deletions pkg/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package test

import (
"fmt"
"log"
"os"
"os/exec"
"path"
Expand All @@ -10,11 +11,11 @@ import (
func make(target string, args ...string) {
pwd, _ := os.Getwd()
testDir := path.Join(pwd, "test")
fmt.Printf("\x1b[36m%s\x1b[0m$ make -C %s", pwd, testDir)
cmdStr := fmt.Sprintf("\x1b[36m%s\x1b[0m$ make -C %s", pwd, testDir)
for _, v := range args {
fmt.Print(" ", v)
cmdStr = cmdStr + fmt.Sprint(" ", v)
}
fmt.Println()
log.Println(cmdStr)

tmpArgs := []string{
target,
Expand All @@ -29,7 +30,7 @@ func make(target string, args ...string) {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
fmt.Errorf("Run", err)
log.Print(err)
os.Exit(1)
}
}
Expand Down

0 comments on commit 2a2271b

Please sign in to comment.